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
Download README.md from balllvin/Inkling-2-Mini-MLX: direct link, hf CLI and curl.
- Browser
- Download file 9.52 kB
-
https://huggingface.co/balllvin/Inkling-2-Mini-MLX/resolve/main/README.md
- Command line
-
hf download hf://balllvin/Inkling-2-Mini-MLX/README.md
-
curl -L -o README.md https://huggingface.co/balllvin/Inkling-2-Mini-MLX/resolve/main/README.md
library_name: mlx
license: mit
pipeline_tag: text-generation
base_model: thinkingmachines/Inkling-2-Mini
base_model_relation: finetune
language:
- en
tags:
- mlx
- apple-silicon
- metal-4
- m5
- moe
- nvfp4
- mxfp8
- speculative-decoding
- inkling-2-mini
Inkling-2-Mini-MLX (Apple Silicon Metal 4 Runtime)
This repository provides the Apple Silicon (MLX + Metal 4) inference engine for thinkingmachines/Inkling-2-Mini (26.4B total / 3.4B active per pass / 5.4B effective active MoE with 3 loop passes = 48 layer visits per token and 256K context). It mirrors github.com/Balllvin/inkling-mlx and is the MLX base runtime that pairs with balllvin/BS-0.5-Mini.
What This Build Is & Why Use It
Standard MLX runners lose throughput on Inkling-2-Mini from command-buffer flushes (max_ops_per_cb = 50), MoE sorting bottlenecks, redundant lm_head reads, dense prefill masks, and leaving the built-in mtp.safetensors drafter unused. inkling-mlx replaces the hot path with custom Metal 4 NAX and SIMT kernels while matching PyTorch Transformers bit-tight (KL = 2.48e-10).
- Runtime format (
inkling-mlx, code-only repo): Contains no duplicated weight binaries (36files). At launch,inkling-mlx servedownloads or loadsthinkingmachines/Inkling-2-Mini(~20.2 GB) directly and runs the exact mixed NVFP4/MXFP8/BF16 weights, unquantized 256K BF16 KV cache, and built-inmtp.safetensorsspeculative drafter over an OpenAI-compatible HTTP/SSE API (/v1/chat/completions,/v1/models,/health). - Adapter pairing (
balllvin/BS-0.5-Mini): Pass--adapter balllvin/BS-0.5-Minitoinkling-mlx serveto merge our rank-16 BS Code / DeepSeek Harness LoRA+ adapter (312text attention & cross-pass controller modules) into BF16 weights at load time (~2.8 s) with zero decode speed penalty. - Hardware support: Native Metal 4.0 NAX
.dylibs target Apple M5 + macOS 26+ (applegpu_g17s); M1βM4 Macs or< macOS 26fall back to pure MLX + Metal 3.1 SIMT kernels with--skip-build(untested on M1βM4).
Variant & Companion Guide
| Role / Hardware | Format / Engine | Repository |
|---|---|---|
| Upstream base weights (CUDA / PEFT / source) | Mixed NVFP4 / MXFP8 / BF16 | thinkingmachines/Inkling-2-Mini |
Apple Silicon MLX + Metal 4 runtime (inkling-mlx) |
Code-only engine (no duplicated weights) | balllvin/Inkling-2-Mini-MLX (this repo) |
| GitHub source mirror | inkling-mlx source |
Balllvin/inkling-mlx |
| BS Code / DeepSeek Harness LoRA+ adapter | Rank-16 PEFT adapter (~50 MB) |
balllvin/BS-0.5-Mini |
| Agent harness & CLI | bscode |
Balllvin/BS |
Evaluation & Parity Results
Because inkling-mlx executes the exact untouched thinkingmachines/Inkling-2-Mini weights with no re-quantization or KV compression, downstream quality matches the official checkpoint:
- Numerical & downstream parity:
16 / 16chat top-1 agreement (KL = 2.48e-10vs PyTorch Transformers MPS);100%byte-identical single-stream greedy MTP parity;B=4batched prefill4 / 4top-1 (KL <= 2.88e-10); GSM8K-5048β49 / 50(96%β98%);131,014-tok and249,926-tok needle retrieval2 / 2pass;20 / 20(100%) on a 20-task multi-turn agentic coding suite atc=4. - Official
Inkling-2-Minireference scores: AA Index v5.020.1, Vals Index v2.246.5%, SWEBench Verified79.2%, SWEBench Pro v277.9%, Vibe Code Bench v1.177.9%, Terminal Bench v2.171.6%, DeepSearchQA85.3%, MCP Atlas82.7%, BrowseComp79.0%, ARC-AGI v1 / v284.5% / 49.3%.
Speed & Weight Size (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):
| Workload | Stock mlx-vlm / Initial MLX |
inkling-mlx |
Speedup |
|---|---|---|---|
Single User Plain (B=1, ctx=512, T=0.0) |
25.98 tok/s | 48.97 tok/s | 1.88x |
Single Agent w/ Tools (B=1 MTP, T=0.0) |
25.98 tok/s | 120.19 tok/s | 4.63x |
4 Concurrent Agents (B=4 MTP, ctx=512) |
39.31 tok/s | 117.68 tok/s | 2.99x |
32 Concurrent Streams (B=32, ctx=512) |
36.10 tok/s | 277.11 tok/s | 7.68x |
Max Clean Batch (B=64, ctx=512) |
β | 335.48 tok/s | β |
Cold 16K Prompt TTFT (B=1) |
20.58β21.4 s | 11.14 s | 1.85xβ1.92x |
Cold 16K 4-Stream Decode (B=4) |
1.87 tok/s | 93.12 tok/s | 49.8x |
250K Context Decode (250,102 tok, B=1) |
β | 19.79 tok/s | β |
Memory & Context Budget
- Checkpoint resident footprint:
17.59 GiBtext LLM (model-00001-of-00001.safetensors:10.68 GiBNVFP4 experts L0β19,3.92 GiBMXFP8 experts L20β23,1.22 GiBBF16 attention,1.73 GiBBF16 embed/head) +0.59 GiBmtp.safetensors=18.18 GiB(~20.4 GBactive after warmup, excluding eager vision). - Native context & KV cache:
262,144(256K) across48layer visits (3passes):40sliding-window visits (w=1024, capped at160 MiBper stream) +8global-attention visits (32 KiB/tok,1 GiBper32Ktokens) +~3.8 MiBShortConv state.
| Unified Memory | Status | Recommended Setup / Limits |
|---|---|---|
| 16β24 GB | Unsupported | Resident weights + MTP exceed 20 GB before KV cache |
| 32 GB | Minimum | B=1 up to 16Kβ32K with --no-mtp --cache-limit-gb 2.0 |
| 48 GB | Supported | B=1..4 w/ MTP (64Kβ128K), or B=1 at 256K with --no-mtp |
| 64 GB | Recommended | Full 256K w/ MTP (~29.6 GiB active, ~38.6 GB peak), B=1..4 MTP, or B=64 at ctx=512 |
| 96β128 GB+ | Supported | Multiple concurrent 128Kβ256K streams and larger prefix caches |
Agent Setup & Hosting
Authenticate with Hugging Face (hf auth login or HF_TOKEN) so inkling-mlx can download thinkingmachines/Inkling-2-Mini (and optionally balllvin/BS-0.5-Mini).
1. Install inkling-mlx (Apple Silicon / MLX)
git clone https://huggingface.co/balllvin/Inkling-2-Mini-MLX inkling-mlx
cd inkling-mlx
bash scripts/setup.sh # installs Python venv + builds Metal 4 .dylibs (M5 + macOS 26+)
# Pre-download base weights (or let `inkling-mlx serve` resolve automatically)
.venv/bin/inkling-mlx download --repo thinkingmachines/Inkling-2-Mini --local-dir ~/models/Inkling-2-Mini
2. Serve Base Model or Pair with balllvin/BS-0.5-Mini
# Base Inkling-2-Mini on OpenAI-compatible HTTP/SSE server:
.venv/bin/inkling-mlx serve \
--model thinkingmachines/Inkling-2-Mini \
--host 127.0.0.1 --port 8095
# Or serve with the BS-0.5-Mini coding/agent adapter merged at load time:
.venv/bin/inkling-mlx serve \
--model thinkingmachines/Inkling-2-Mini \
--adapter balllvin/BS-0.5-Mini \
--host 127.0.0.1 --port 8095
(Pass --skip-build on Apple M1βM4 or < macOS 26 to use the pure MLX + Metal 3.1 fallback; add --no-mtp --cache-limit-gb 2.0 on 32 GB Macs. Wire into BS Code with bscode providers add inkling-bs --base-url http://127.0.0.1:8095/v1 --models inkling-2-mini+balllvin/BS-0.5-Mini --no-key.)
3. Verify Running Server
curl -sS http://127.0.0.1:8095/health | python3 -m json.tool
curl -sS http://127.0.0.1:8095/v1/chat/completions \
-H "Content-Type: application/json" \
-d '{
"model": "inkling-2-mini",
"messages": [{"role": "user", "content": "What is 17 * 23? Show brief reasoning then the answer."}],
"max_tokens": 512,
"temperature": 0.0
}' | python3 -m json.tool
How It Was Built
- Single-command-buffer decode (
src/inkling_mlx/native/decode_runner.mm): Executes all 48 layer visits inside 1MTLCommandBuffervia 16 KB page-aligned zero-copyMTLBufferwrappers, eliminating MLX flush overhead. - Unified
B=1..4GPU-accept MTP (mtp_draft_runner.mm): Runs the 3-layer DSpark + folded FP64MarkovHeaddrafter and Leviathan rejection sampling on GPU without CPU round-trips. - Regime-matched MoE & Zero-Mask FlashAttention (
moe_kernels.py,prefill_moe_nax.mm,flash_attn_nax.mm): Dispatches directdot8_nvfp4(M=1..2), zero-spill grouped tiles (M=3..112), and Metal 4.0 NAXmatmul2d(M >= 128) plus arithmetic causal/sliding-window attention. - Included skill & tests: See
skills/mlx-apple-silicon-inference/SKILL.mdand verification tests undertests/.
Limits & License
- Hardware & modality scope: Requires Apple Silicon (
32 GB+unified RAM;64 GBrecommended). Native Metal 4.0 NAX kernels require Apple M5 + macOS 26+; M1βM4 fallback (--skip-build) is untested. Text generation and OpenAI tool calling are supported; vision inputs are not wired into this server. - License: Engine code is MIT (
LICENSE); underlyingthinkingmachines/Inkling-2-Miniweights remain Apache-2.0 by Thinking Machines Lab, Inc. Independent community build.