Instructions to use balllvin/Inkling-2-Mini-MLX with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- MLX
How to use balllvin/Inkling-2-Mini-MLX with MLX:
# Make sure mlx-lm is installed # pip install --upgrade mlx-lm # if on a CUDA device, also pip install mlx[cuda] # Generate text with mlx-lm from mlx_lm import load, generate model, tokenizer = load("balllvin/Inkling-2-Mini-MLX") prompt = "Once upon a time in" text = generate(model, tokenizer, prompt=prompt, verbose=True) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- LM Studio
- MLX LM
How to use balllvin/Inkling-2-Mini-MLX with MLX LM:
Generate or start a chat session
# Install MLX LM uv tool install mlx-lm # Generate some text mlx_lm.generate --model "balllvin/Inkling-2-Mini-MLX" --prompt "Once upon a time"
- Atomic Chat
- Inkling 2 Mini MLX
- Why Use
inkling-mlx? - Getting Started
- Verified Benchmarks (Before vs After on Apple M5 Pro 64 GB)
- 1. Interactive & Low-Concurrency Local Agents (
B = 1..4,ctx=512, Cold Prefill) - 2. High-Concurrency Batched Throughput (
B = 8..64, Cold Prefill) - 3. Long Context (
4k,16k,250k) & Cold Prefill / TTFT - 4. End-to-End Multi-Turn Agentic Coding Suite (
20Real Tool-Using Tasks) - 5. Quality Verification & Official Inkling 2 Mini Benchmarks
- 1. Interactive & Low-Concurrency Local Agents (
- Deep Technical Details: How the Optimizations Work
- Model Size, Memory Budget & Context Scaling
- Chip Compatibility & Porting Guide
- Included MLX Optimization Skill, Testing & License
- Why Use
Inkling 2 Mini MLX
Fast local Apple Silicon (MLX + Metal 4) inference engine for thinkingmachines/Inkling-2-Mini β exact released weights and quality, running 1.88xβ7.68x faster on Mac.
- GitHub Repository:
github.com/Balllvin/inkling-mlx - Hugging Face Model Card:
huggingface.co/balllvin/Inkling-2-Mini-MLX - Official Base Weights (Apache 2.0):
huggingface.co/thinkingmachines/Inkling-2-Mini - Included MLX Optimization Skill:
skills/mlx-apple-silicon-inference/SKILL.md
Code-only mirror (no duplicated weight binaries): This Hugging Face repository mirrors
github.com/Balllvin/inkling-mlxand contains the full inference engine, native Metal 4 kernels, setup scripts, tests, and Apple Silicon optimization playbook. When launched, it downloads or loadsthinkingmachines/Inkling-2-Minidirectly and runs the exact checkpoint unmodified (3 loop passes / 48 layer visits per token, unquantized 256k BF16 KV cache, mixed NVFP4 / MXFP8 / BF16 weights, and built-inmtp.safetensorsdrafter) over an OpenAI-compatible HTTP/SSE API (/v1/chat/completions,/v1/models,/health). Text generation and OpenAI tool calling are supported (vision encoder inputs are not wired into this MLX server).
Why Use inkling-mlx?
Standard MLX runners lose substantial throughput on Inkling-2-Mini from command-buffer flushes (max_ops_per_cb = 50), MoE sorting bottlenecks, redundant lm_head reads, dense prefill attention masks, and leaving the built-in mtp.safetensors drafter unused.
inkling-mlx fixes all four layers while keeping numerical parity bit-tight against PyTorch Transformers (KL = 2.48e-10):
- Single-user tool/code agents up to
120 tok/s(4.63xvs stock): End-to-end 1-command-buffer GPU speculative decode (B=1..4). - Four concurrent local agents up to
117.7 tok/saggregate (2.99xvs stock): Designed specifically to keep local 1β4 agent concurrency fast without paying cloud API costs. - High-batch scaling up to
277β335 tok/s(B=32..64,0swap in 64 GB RAM): EliminatesSwitchGLUsorting cliffs and49.8xlong-context batch collapses (16k B=4:1.87 -> 93.12 tok/s). - Nearly
2xfaster cold prefill: Cuts16kTTFT from20.58β21.4 sto11.14 s(1,464 tok/sserved,1,739 tok/sin-process at4k).
At-a-Glance Before vs After (Apple M5 Pro 64 GB)
| Workload | Before (Baseline) | After (inkling-mlx) |
Speedup |
|---|---|---|---|
Single User (B=1 Plain, ctx=512) |
25.98 tok/s (stock mlx-vlm) |
48.97 tok/s |
1.88x |
Single Agent w/ Tools (B=1 MTP, T=0.0) |
25.98 tok/s (stock mlx-vlm) |
120.19 tok/s |
4.63x |
4 Concurrent Agents (B=4 MTP, ctx=512) |
39.31 tok/s agg (stock mlx-vlm) |
117.68 tok/s agg (27.59/stream) |
2.99x |
32 Concurrent Streams (B=32, ctx=512) |
36.10 tok/s agg (initial MLX) |
277.11 tok/s agg (8.75/stream) |
7.68x |
Max Batch Clean (B=64, ctx=512) |
(OOM / collapse) | 335.48 tok/s agg (41.3 GB peak, 0 swap) |
β |
Cold 16k Prompt TTFT (B=1) |
20.58β21.4 s |
11.14 s (1,464.3 tok/s) |
1.85xβ1.92x |
Cold 16k 4-Stream Decode (B=4) |
1.87 tok/s agg (initial MLX) |
93.12 tok/s agg (23.28/stream) |
49.8x |
Hardware target: Built and tuned specifically for Apple M5 (per-core Metal 4 Neural Accelerators / NAX). Measured and verified on a MacBook Pro (
Mac17,9) with Apple M5 Pro (18-core CPU: 6 Super + 12 Performance, 20-core GPU, Metal 4), 64 GB unified memory, macOS 26.5.1 (Xcode 26.5 SDK), MLX 0.32.4. On M1βM4 Macs or< macOS 26, pass--skip-buildfor the pure MLX fallback or see Chip Compatibility & Porting Guide.
Getting Started
Prerequisites, Model to Download & RAM Requirements
- Model weights:
thinkingmachines/Inkling-2-Mini(~20.2 GBdownload,>= 25 GBfree SSD space):model-00001-of-00001.safetensors(~19.53 GB, mixed NVFP4 / MXFP8 / BF16)mtp.safetensors(~0.64 GB, built-in 3-layer speculative drafter)config.jsonand tokenizer files
- Software: Apple M5 Mac + macOS 26+ + Xcode Command Line Tools (
xcode-select --install) + Python3.11β3.13(oruv) for native Metal 4; or Apple Silicon macOS 14+ with--skip-buildfor the MLX-only fallback.
| Unified Memory | Status | Recommended Setup / Limits |
|---|---|---|
| 16β24 GB | Not supported | Resident text + MTP runtime exceeds 20 GB before KV cache and prefill scratch. |
| 32 GB | Minimum | Single-stream (B=1) short/medium context (<= 16kβ32k); run with --no-mtp --cache-limit-gb 2.0. |
| 48 GB | Supported | B=1..4 with MTP up to 64kβ128k, or B=1 up to 256k with --no-mtp. |
| 64 GB | Recommended (Tested) | Full 256k BF16 KV context with MTP (~29.6 GiB active, ~38.6 GB peak, 0 swap), B=1..4 concurrent MTP agents, or up to B=64 batched decode at ctx=512 (41.3 GB peak, 0 swap). |
| 96β128 GB+ | Supported | Multiple concurrent 128kβ256k streams and larger prefix caches. |
Agent Quickstart Prompt
Copy and paste this prompt into any coding agent on an Apple Silicon Mac:
Set up and verify `inkling-mlx` on this Mac:
1. Check hardware and memory (`system_profiler SPHardwareDataType`): confirm Apple Silicon with >= 32 GB unified RAM (64 GB recommended). Confirm whether this Mac has an Apple M5-family chip and macOS 26+ with Xcode Command Line Tools installed.
2. Clone `https://github.com/Balllvin/inkling-mlx` (or `https://huggingface.co/balllvin/Inkling-2-Mini-MLX`) and `cd` into it.
3. Run `bash scripts/setup.sh` (or create a Python 3.11β3.13 venv, `pip install -e .`, and run `bash scripts/build_native.sh` on Apple M5 / macOS 26+). On older M1βM4 Macs or < macOS 26, skip building the Metal 4 dylibs and use `--skip-build` (MLX fallback, see Compatibility section).
4. Download `thinkingmachines/Inkling-2-Mini` from Hugging Face into `~/models/Inkling-2-Mini` using `.venv/bin/inkling-mlx download --repo thinkingmachines/Inkling-2-Mini --local-dir ~/models/Inkling-2-Mini` (skip if `config.json`, `model-00001-of-00001.safetensors`, and `mtp.safetensors` are already present).
5. Run the verification suite:
- `.venv/bin/python -m unittest tests/test_engine.py -v`
- On Apple M5 / macOS 26+ after `build_native.sh` succeeds:
- `.venv/bin/python tests/test_flash_attn.py`
- `.venv/bin/python tests/test_prefill_moe.py`
- `.venv/bin/python tests/test_mtp_draft.py`
6. Start the OpenAI-compatible server on `127.0.0.1:8095` via `.venv/bin/inkling-mlx serve --model ~/models/Inkling-2-Mini --host 127.0.0.1 --port 8095` (add `--skip-build` on non-M5 / < macOS 26, and `--no-mtp --cache-limit-gb 2.0` if unified RAM is 32 GB) and wait until `http://127.0.0.1:8095/health` reports `"ready": true`.
7. Send one test request to `http://127.0.0.1:8095/v1/chat/completions` and report the `/health` JSON, completion text, usage, and throughput metrics.
Manual Setup & Serving
git clone https://github.com/Balllvin/inkling-mlx.git
cd inkling-mlx
# One-shot setup (Apple M5 + macOS 26+): creates .venv, installs inkling-mlx, compiles Metal 4 .dylibs, and downloads weights
DOWNLOAD_MODEL=1 bash scripts/setup.sh
# Or step by step
python3 -m venv .venv && source .venv/bin/activate
pip install -e .
inkling-mlx build # Requires Apple M5 + macOS 26+ (omit on M1-M4 / < macOS 26 and pass --skip-build below)
inkling-mlx download --repo thinkingmachines/Inkling-2-Mini --local-dir ~/models/Inkling-2-Mini
# Serve OpenAI-compatible API (auto-downloads from HF if passed a repo ID)
inkling-mlx serve --model ~/models/Inkling-2-Mini --host 127.0.0.1 --port 8095
# On 32 GB Macs: add --no-mtp --cache-limit-gb 2.0
# On M1-M4 / < macOS 26: add --skip-build
Example request:
curl -s http://127.0.0.1:8095/v1/chat/completions \
-H "Content-Type: application/json" \
-d '{
"model": "inkling-2-mini",
"messages": [{"role": "user", "content": "Write an O(n) Fibonacci helper in Python."}],
"max_tokens": 256,
"temperature": 0.0
}'
Verified Benchmarks (Before vs After on Apple M5 Pro 64 GB)
Measured on MacBook Pro (Mac17,9, Apple M5 Pro 20-core GPU, 64 GB RAM, macOS 26.5.1, MLX 0.32.4, AC power) (282.6 GB/s DRAM read ceiling, 29.38 TFLOP/s BF16 compute ceiling). Rows labeled (thermalState=1) ran under real concurrent host load (140β195 GB/s available DRAM BW vs 282.6 GB/s idle).
1. Interactive & Low-Concurrency Local Agents (B = 1..4, ctx=512, Cold Prefill)
| Scenario | Before (Baseline) | inkling-mlx |
Speedup | % Plain BW Ceiling |
|---|---|---|---|---|
B=1 Plain Decode (T=0.0) |
25.98 tok/s, 841 ms TTFT (stock mlx-vlm 0.8.0) |
48.97 tok/s, 576 ms TTFT |
1.88x |
97.0% |
B=1 MTP Tool Calling (T=0.0) |
25.98 tok/s (stock mlx-vlm 0.8.0) |
120.19 tok/s (acc=6.67) |
4.63x |
236.4% |
B=1 MTP Code Refactor (T=0.0) |
25.98 tok/s (stock mlx-vlm 0.8.0) |
86.86 tok/s |
3.34x |
170.3% |
B=1 MTP 6-Prompt Median (T=0.0) |
25.98 tok/s (stock mlx-vlm 0.8.0) |
66.79 tok/s |
2.57x |
130.5% |
B=1 MTP Sampled (T=0.7, thermalState=1) |
β | 50.05 tok/s med (97.91/s tool) |
β | 97.8%β192.6% |
B=2 Plain Batched (T=0.0) |
35.73 tok/s agg (18.75/stream, mlx-vlm) |
64.75 tok/s agg (32.38/stream) |
1.81x |
85.1% |
B=2 Unified MTP (T=0.0, thermalState=1) |
35.73 tok/s agg (stock mlx-vlm 0.8.0) |
94.98 tok/s agg (47.49/stream) |
2.66x |
122.7% |
B=2 Unified MTP Sampled (T=0.7, thermalState=1) |
β | 91.69 tok/s agg (45.84/stream) |
β | 118.4% |
B=4 Plain Batched (T=0.0) |
39.31 tok/s agg (14.48/stream, mlx-vlm) |
107.06 tok/s agg (26.77/stream) |
2.72x |
102.0% |
B=4 Unified MTP (T=0.0, thermalState=1) |
39.31 tok/s agg (stock mlx-vlm 0.8.0) |
117.68 tok/s agg (27.59/stream) |
2.99x |
108.9% |
B=4 Unified MTP Sampled (T=0.7, thermalState=1) |
β | 101.73 tok/s agg (21.91/stream) |
β | 81.1% |
2. High-Concurrency Batched Throughput (B = 8..64, Cold Prefill)
| Batch & Context | Before (Baseline) | inkling-mlx |
Speedup | Notes / Memory |
|---|---|---|---|---|
B=8, ctx=512 |
44.70 tok/s agg (10.13/s), 6.55 s TTFT (stock mlx-vlm) |
160.19 tok/s (20.03/stream), 3.10 s TTFT |
3.58x |
115.9% BW ceil |
B=16, ctx=512 |
35.11 tok/s agg (3.40/s), 10.23 s TTFT (initial MLX engine) |
218.33 tok/s (13.86/stream), 6.24 s TTFT |
6.22x |
117.2% BW ceil |
B=32, ctx=512 |
36.10 tok/s agg (1.83/s), 18.25 s TTFT (initial MLX engine) |
277.11 tok/s (8.75/stream), 12.28 s TTFT |
7.68x |
100.1% BW ceil |
B=48, ctx=512 |
β | 308.17 tok/s (6.48/stream) |
β | thermalState=1, 0 swap |
B=64, ctx=512 |
(OOM / collapse) | 335.48 tok/s (5.28/stream) |
β | 41.3 GB peak, 0 swap |
B=32, ctx=4,096 |
(collapse) | 235.80 tok/s (7.49/stream) |
β | 101.8% ceil, 41.3 GB peak, 0 swap |
3. Long Context (4k, 16k, 250k) & Cold Prefill / TTFT
| Condition | Before (Baseline) | inkling-mlx |
Speedup | % Hardware Ceiling |
|---|---|---|---|---|
Cold 4k B=1 Decode / TTFT |
23.48 tok/s / 5.44 s (756/s, mlx-vlm) |
48.28 tok/s / 2.98 s (1,381/s served; 1,739/s in-proc) |
2.06x dec / 1.83x TTFT |
99.0% dec / 45.1%β54.2% prefill |
Cold 4k B=4 Decode / TTFT |
10.23 tok/s / 26.09 s (stock mlx-vlm) |
105.94 tok/s (26.50/stream) / 12.52 s |
10.36x dec / 2.08x TTFT |
108.4% dec / 43.0% prefill |
Cold 4k B=8 Decode / TTFT |
10.04 tok/s / 48.61 s (stock mlx-vlm) |
139.91 tok/s (17.49/stream) / 22.38 s (1,471.5/s) |
13.94x dec / 2.17x TTFT |
111.1% dec / 48.1% prefill |
Cold 16k B=1 Decode / TTFT |
24.76 tok/s / 20.58β21.4 s (762β792/s) |
42.69 tok/s / 11.14 s (1,464.3/s, thermalState=1) |
1.72x dec / 1.85xβ1.92x TTFT |
93.6% dec / 47.9% prefill |
Cold 16k B=4 Decode |
1.87 tok/s agg (1.57/s, initial MLX engine) |
93.12 tok/s agg (23.28/stream) |
49.8x |
108.4% BW ceil |
250k Context (250,102 tok, B=1) |
(untested / OOM) | 19.79 tok/s (29.74 GB active / 38.64 GB peak) |
β | 97.1% BW ceil (2/2 needle PASS) |
4. End-to-End Multi-Turn Agentic Coding Suite (20 Real Tool-Using Tasks)
| Engine & Concurrency | Tasks Passed | Median Task Wall | Total Suite Wall | Throughput | Speedup |
|---|---|---|---|---|---|
Initial MLX Engine (c=4) |
18/20 (90%) |
171.40 s |
1,053.6 s |
1.14 tasks/min |
1.0x |
inkling-mlx (c=1 w/ MTP, 5.33 avg acc) |
19/20 (95%) |
34.40 s |
979.4 s |
1.23 tasks/min |
4.98x / task |
inkling-mlx (c=4) |
20/20 (100%) |
111.64 s |
672.3 s |
1.78 tasks/min |
1.57x total |
inkling-mlx (c=8) |
19/20 (95%) |
170.26 s |
614.6 s |
1.95 tasks/min |
1.71x total |
5. Quality Verification & Official Inkling 2 Mini Benchmarks
- Numerical & Downstream Parity (
inkling-mlxvs Reference):16/16chat top-1 agreement (KL = 2.48e-10vs PyTorch Transformers MPS reference);100%byte-identical single-stream greedy speculative parity + losslessT=0.7rejection sampling;4/4decode-onlyB=2SIMT exact parity andB=4batched prefill4/4top-1 (KL <= 2.88e-10); GSM8K-5048β49 / 50(96β98%); tool-call parser + HTTP20/20 + 6/6;131,014-tok and249,926-tok needle retrieval2/2 PASS(-96 MBswap delta).
Since inkling-mlx executes the exact released thinkingmachines/Inkling-2-Mini weights (26.4B total / 3.4B active per pass / 5.4B effective active across 3 loop passes) without requantizing weights, dropping loop passes, or quantizing KV caches, model capabilities match the official Thinking Machines Lab, Inc. evaluation suite:
| Category | Benchmark | Inkling 2 Mini |
|---|---|---|
| Overall Indices | AA Index (v5.0) | 20.1 |
| Vals Index (v2.2) | 46.5% |
|
| Coding & Autoresearch | SWEBench Verified (bash only) | 79.2% |
| SWEBench Pro v2 (Hard, mini-swe-agent v2.4.6) | 77.9% |
|
| Vibe Code Bench v1.1 (openhands / vals) | 77.9% |
|
| SWEBench Multilingual (bash only) | 73.7% |
|
| Terminal Bench v2.1 (pi v0.83.0) | 71.6% |
|
| DeepSWE v1.1 (mini-swe-agent v2.4.6) | 48.2% |
|
| FrontierCode v2.0 (stirrup v0.2.1) | 15.1% |
|
| Terminal Bench v4.0 (mini-swe-agent v2.4.6) | 5.6% |
|
| PMPP-Hard (AUC, 0β10h, pi v0.83.0) | 455.82 |
|
| Agentic Search, Tool Use & Knowledge Work | DeepSearchQA (with compaction) | 85.3% |
| MCP Atlas (Public) | 82.7% |
|
| BrowseComp (with compaction) | 79.0% |
|
| GDPVal-AA v2.1 | 1319 |
|
| AA-Briefcase v1.1 | 1263 |
|
| Vals Finance Index | 50.1% |
|
| JobBench | 49.6% |
|
| Diligence Bench (best harness) | 48.6% |
|
| AA-AnalystAgent | 46.3% |
|
| EnterpriseOps-Gym | 42.0% |
|
| AutomationBench-AA v1.0.6 | 41.8% |
|
| Reasoning, Knowledge & Epistemics | ARC-AGI v1 / v2 | 84.5% / 49.3% |
| GraphWalks BFS (256K) | 69.7% |
|
| LongBench v2 | 66.9% |
|
| AA-Omniscience v1.1 (non-hallucination / score) | 63.4% (-8.6) |
|
| MRCR v2 (8-needle 256Kβ512K) | 46.4% |
|
| Apex 2025 | 34.4% |
|
| ComplexConstraints v1.1 (openhands v1.45.0) | 33.4% |
|
| CritPt v2 (Full / Hard) | 31.4% / 17.0% |
|
| HLE-Diamond | 15.2% |
|
| Safety & Alignment | StrongREJECT (none) | 97.8% |
| FORTRESS (benign, Public) | 96.4% |
|
| FORTRESS (adversarial, Public) | 89.5% |
(For vision benchmarks and competitor tables, see the official thinkingmachines/Inkling-2-Mini card.)
Deep Technical Details: How the Optimizations Work
- Single-Command-Buffer Native Metal 4 Decode (
src/inkling_mlx/native/decode_runner.mm): Runs all48layer visits (embedding, RMSNorm, depth residuals, message gating, packed QKV/gate, causalShortConv, chronologicalring_idxsplit-K GQA, FP32 routing, NVFP4/MXFP8 MoE,lm_head, greedyhead_argmax) inside 1MTLCommandBuffervia zero-copy16 KBpage-alignedMTLBufferwrappers, cutting~5β8 ms/stepof MLX flush overhead. - Unified
B=1..4GPU-Accept MTP (decode_runner.mm+mtp_draft_runner.mm): DraftsKtokens with the built-in 3-layer DSpark + folded FP64MarkovHeaddrafter in 1 Metal CB, verifiessum(K_i + 1) <= 32tokens across1..4active streams in 1 Metal CB, performs greedy or exact Leviathan rejection sampling on the GPU, commits/rolls back KV & draft caches in place, and captures target hidden states without CPU waits. Switches to Metal 4 NAX batched kernels atM >= 9, caps adaptiveK <= 5atB >= 3, and hands off seamlessly toBatchKVCachecontinuous batching atB >= 5. - Regime-Matched NVFP4 / MXFP8 MoE Kernels (
src/inkling_mlx/moe_kernels.py&native/prefill_moe_nax.mm):M = 1..2: Direct 1-expert-per-threadgroup kernel (moe_m1_experts) with inlinedot8_nvfp4(97β99%DRAM BW).M = 3..112: Zero-spill compact(tile_expert, tile_t0)tile-table grouped kernel (moe_grouped_tiles) with#pragma unrollscalar accumulators,uint4loads, and a256-entryhalf2E2M1 LUT (72β89%DRAM BW,0.00e+00batch invariance,lm_headread once per step).M >= 128: Metal 4.0 NAX (mpp::tensor_ops::matmul2d) double-buffered grouped MoE with GPU radix bucketing, indirect dispatch, and a fused 64-channel 128B-aligned combine+residual dispatch (21.9β27.1 TFLOP/s).
- Metal 4.0 NAX Zero-Mask FlashAttention (
src/inkling_mlx/native/flash_attn_nax.mm): Computes causal bounds, sliding window (w=1024), and raggedkey_startarithmetically inside tiles, avoiding107 GBof dense mask traffic at16kand fusing NAX Toeplitz relative bias + exact FP32 query-dependent sinks (3.6xSWA,2.5x16kGlobal). MTLMathModeSafeOccupancy & Bit-Exactness: Disabling floating-point reassociation reduces live register pressure on Apple M5 (applegpu_g17s), increasing SIMD occupancy (11β29%speedup) with0.00e+00BF16 bit-exactness.- Prefix Sharing & macOS VM / CPython Safety (
engine.py,native_decode.py,native_mtp.py): Shares long system prefixes (>= 128tokens) across concurrent burst arrivals (~93%hit rate), guardsPrefixCacheserialized size before cloning256kKV (-12.5 GBpeak spike avoided), never persists VA-keyed mutableMTLBuffermappings across MLX frees, and validates objectisidentity to defeat CPython LIFO freelistid()aliasing.
Model Size, Memory Budget & Context Scaling
Exact Checkpoint Weight Footprint (thinkingmachines/Inkling-2-Mini)
| Component | Bytes | GiB | Precision / Notes |
|---|---|---|---|
| Routed experts (layers 0β19) | 11,466,199,200 |
10.679 |
NVFP4 (E2M1 + E4M3 [1,16] scale + FP32 amax) |
| Routed experts (layers 20β23) | 4,204,265,472 |
3.916 |
MXFP8 (F8_E4M3 + UE8M0 [1,32] scale) |
| Attention projections & norms (layers 0β23) | 1,307,510,784 |
1.218 |
BF16 (q/k/v/r/o/gate_proj, sconv, rel_proj, norms) |
Token embeddings ([201024, 2304]) |
926,318,592 |
0.863 |
BF16 |
LM head ([201024, 2304]) |
926,318,592 |
0.863 |
BF16 (accumulated in FP32 without storing FP32 copy) |
| Loop controllers (layers 6β17) | 42,467,328 |
0.040 |
BF16 message gates (down, forget, gain) |
| Routers, depth residuals & norms | 16,278,528 |
0.015 |
BF16 + FP32 |
| Text LLM Resident Total | 18,889,358,496 |
17.592 |
model-00001-of-00001.safetensors (19.53 GB on disk incl. vision) |
MTP Drafter (mtp.safetensors) |
635,795,744 |
0.592 |
BF16 3-layer DSpark + folded MarkovHead (+96 MiB folded) |
| Total Text + MTP Resident | 19,525,154,240 |
18.184 |
~20.4 GB MLX active after warmup (excl. eager vision) |
KV Cache & Bandwidth Scaling Across Context Lengths (48 Visits, 3 Loop Passes)
Per-stream BF16 KV & state (n_kv = 8, head_dim = 128, 4,096 B/tok/visit):
- 40 sliding-window visits (
window = 1,024): capped at160 MiB(0.156 GiB) per stream. - 8 full-attention visits: grows linearly at
32 KiB/tok(32,768 B/tok) (1 GiBper32,768tokens). - ShortConv states:
~3.8 MiBper stream; MTP Draft KV (B <= 4):1global layer (4,096 B/tok) +8 MiBlocal layers.
Total DRAM read per plain B=1 decode step = 5.493 GB active weights + KV bytes read:
Context (ctx) |
KV / Stream | Total Resident (B=1 w/ MTP) |
4-Stream KV (B=4) |
Max Clean Streams (<= 51.8 GiB GPU WS) |
B=1 BW Read / Step |
Theoretical B=1 Plain Ceiling (@ 282.6 GB/s) |
|---|---|---|---|---|---|---|
512 |
0.092 GiB |
~20.5 GiB |
0.37 GiB |
64+ (max-batch / scratch limited) |
5.59 GB |
50.5 tok/s |
4,096 |
0.281 GiB |
~20.7 GiB |
1.13 GiB |
64+ (32 verified) |
5.79 GB |
48.8 tok/s |
16,384 |
0.656 GiB |
~21.1 GiB |
2.63 GiB |
~39 |
6.20 GB |
45.6 tok/s |
32,768 |
1.156 GiB |
~21.7 GiB |
4.63 GiB |
~22 |
6.74 GB |
41.9 tok/s |
65,536 |
2.156 GiB |
~22.8 GiB |
8.63 GiB |
~11 |
7.81 GB |
36.2 tok/s |
131,072 (128k) |
4.156 GiB |
~25.1 GiB |
16.63 GiB |
~6 |
9.96 GB |
28.4 tok/s |
262,144 (256k) |
8.156 GiB |
~29.6 GiB |
32.63 GiB |
3 (plain, w/ 4 GB cache) |
14.25 GB |
19.8 tok/s |
Chip Compatibility & Porting Guide
This engine is built and tuned specifically for Apple M5 (Apple10 GPU family: M5, M5 Pro, M5 Max, M5 Ultra) and has only been tested on Apple M5 Pro (Mac17,9, 20-core GPU, 64 GB unified RAM, macOS 26.5.1).
| Subsystem | Apple M5 (Apple10, macOS 26+) |
Apple M1 / M2 / M3 / M4 (Apple7βApple9) |
Why |
|---|---|---|---|
Metal 4.0 NAX FlashAttention (native/flash_attn_nax.mm) |
Native 4x speedup | Not supported natively | Uses MetalPerformancePrimitives (mpp::tensor_ops::matmul2d) targeting M5 per-core Neural Accelerators and MTLLanguageVersion4_0. |
Metal 4.0 NAX Prefill MoE (native/prefill_moe_nax.mm) |
Native 21β27 TFLOP/s | Not supported natively | Uses MTLLanguageVersion4_0 + mpp::tensor_ops::matmul2d (M >= 128) unavailable on M1βM4 hardware. |
Native 1-CB Decode & MTP (native/decode_runner.mm, mtp_draft_runner.mm) |
Compiles & runs (B=1..4 MTP + batched) |
Fails build / init without edits | mtp_draft_runner.mm hardcodes MTLLanguageVersion4_0 even though its shaders are pure SIMT, and decode_runner.mm aborts init if lib_nax (MTLLanguageVersion4_0, M >= 9) fails to compile. |
MLX + Metal 3.1 SIMT Fallback (fused.py, kernels.py, moe_kernels.py, mtp.py) |
Available | Supported in code (untested on M1βM4) | kernels.py and moe_kernels.py use standard Metal 3.1 (simdgroup_bfloat8x8, moe_m1_experts, moe_grouped_tiles) and all native .dylib loaders return None when .dylibs are absent. |
| NVIDIA CUDA / AMD ROCm / Intel / CPU-only | β | Not supported | Depends on Apple Unified Memory, Metal, and mlx. |
Running on M1 / M2 / M3 / M4 today (untested): Pass
--skip-build(inkling-mlx serve --skip-build --model ...) ifbuild_native.shfails on< macOS 26or non-M5 hardware. Native loaders returnNoneand fall back to pure MLX + Metal 3.1 SIMT kernels.
How to Fork / Adapt for M1βM4 (or Other Chips)
- Guard Metal 4.0 NAX in
src/inkling_mlx/native/decode_runner.mm: WrapMTLLanguageVersion4_0/kMetal4NaxSource(cfg->max_m >= 8) in#if defined(__MAC_26_0), leavectx->lib_nax = nilon failure, and gateuse_nax_qkv/use_nax_head(M >= 9) on(ctx->lib_nax != nil)soM >= 9falls back to SIMT. - Lower
MTLLanguageVersioninsrc/inkling_mlx/native/mtp_draft_runner.mm: Changeopts.languageVersion = MTLLanguageVersion4_0toMTLLanguageVersion3_2(orMTLLanguageVersion3_1on macOS 14); the drafter contains nompp::tensor_opscalls. - Make NAX prefill
.dylibs optional inscripts/build_native.sh&src/inkling_mlx/cli.py: Build onlylibinkling_decode.dylibandlibinkling_mtp_draft.dylibon M1βM4; Python falls back to MLXrelative_attention_naxandmoe_grouped_tiles/mx.gather_qmm. - Re-tune & gate parity: Tune threadgroup sizes and
MTLMathModeSafeonApple7βApple9register files and verify parity viatests/test_engine.pyandtests/test_decode_runner.py. - Non-Apple backends (CUDA / ROCm): Reuse the model spec and scheduler in
model.py,config.py,mtp.py, andparser.pywith CUDA Graphs, Triton, FlashAttention, and CUTLASS FP4/FP8 grouped GEMMs.
Included MLX Optimization Skill, Testing & License
- Skill:
skills/mlx-apple-silicon-inference/SKILL.mdβ reusable Apple Silicon MLX & Metal 4 optimization playbook. - Verification Suites:
PYTHONPATH=src python -m unittest tests/test_engine.py -v,tests/test_flash_attn.py,tests/test_prefill_moe.py, andtests/test_mtp_draft.py. - License: Engine code is MIT (
LICENSE). Underlyingthinkingmachines/Inkling-2-Miniweights remain Apache 2.0 by Thinking Machines Lab, Inc.
Model tree for balllvin/Inkling-2-Mini-MLX
Base model
thinkingmachines/Inkling-2-Mini