Skip to main content

mlx2coreai

Experimental MLX to CoreAI conversion.

mlx2coreai captures MLX graphs, lowers supported ops to CoreAI MLIR, and writes .aimodel assets or coreai-models-style LLM bundles.

Install

pip install mlx2coreai

Convert an mlx-lm Model

For autoregressive language models, use the stateful converter. It writes a bundle containing metadata.json, tokenizer/, and a nested .aimodel.

mlx2coreai convert-mlx-lm-stateful mlx-community/Qwen3-0.6B-bf16 \
  --output qwen \
  --max-context-length 256

The exported model has one main entrypoint with input_ids, position_ids, and mutable keyCache / valueCache state.

Benchmark Sampling

python scripts/benchmark_aimodel_sampling.py qwen \
  --contexts 16,32,64,128,256 \
  --steps 16 \
  --decode

The benchmark accepts either the bundle directory (qwen) or the nested asset path (qwen/qwen.aimodel). It uses the embedded tokenizer when present.

Convert a Generic MLX Function

import mlx.core as mx
import numpy as np

from mlx2coreai import ConversionConfig, convert_mlx_to_coreai


def model(x, w):
    return mx.tanh(mx.matmul(x, w))


converted = convert_mlx_to_coreai(
    model,
    {
        "x": np.ones((2, 3), dtype=np.float32),
        "w": np.ones((3, 4), dtype=np.float32),
    },
    config=ConversionConfig(optimize=True),
    output_path="model.aimodel",
)

print(converted.asset_path)

Run an Asset

When the local CoreAI runtime is available:

import asyncio
import numpy as np

from mlx2coreai import run_aimodel


async def main():
    result = await run_aimodel(
        "model.aimodel",
        {"x": np.ones((2, 3), dtype=np.float32)},
    )
    print(result.outputs)


asyncio.run(main())

Release files for mlx2coreai 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for mlx2coreai 0.1.1
File Size Uploaded
mlx2coreai-0.1.1.tar.gz 74.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for mlx2coreai 0.1.1
File Interpreter ABI Platform
mlx2coreai-0.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 148.3 kB

Release files / mlx2coreai-0.1.1.tar.gz

Download URL mlx2coreai-0.1.1.tar.gz
Size 74.8 kB
Tags Source
SHA-256 checksum
How to use checksums
05027e6c8bd03b4d02d9b6c40f8a1a845c7b81f526ad06cc916aa492797c7437
BLAKE2b-256 checksum
How to use checksums
3c543fd055912447dcdc429cc807bbe6cf07ae1a114cef1f9062d3b3b0c8e5d1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.12

Release files / mlx2coreai-0.1.1-py3-none-any.whl

Download URL mlx2coreai-0.1.1-py3-none-any.whl
Size 73.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c6aba409198fb4a24c714296b38ff41d8f664c43b00f92cdeb5b3359f0c20765
BLAKE2b-256 checksum
How to use checksums
6b72c242d556a041f219e7fda0a36f9cc42d0f66a2789f54612256b3165d784b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.12

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page