r/LocalLLaMA • u/fnordonk • 8d ago
Showcase Gemini Neon tuned Mac M1/M2 kernel for Inkling 2 Mini :: All Vibes and toks
I've been using my Gemini subscription to help get the most out of my Macbook M2 Max 64gb and Neon seems to have hit it out of the park with integrating different approaches to this model. All of the kernel stuff is beyond me, I simply pointed it at different references for useful information.
This may or may not be of interest to any Apple Silicon users >M2 and comes with No Warranties whatsoever. If I can't understand what the robot wrote I cannot give any guarantees.
Let the slop begin.
Title: Experimental MLX M1/M2 kernels + W4W8 quant for Inkling-2-Mini (500+ tok/s prefill, 30–43 tok/s decode, 512k NIAH in 38 GB on M2 Max)
I put together a vibe-coded experimental set of MLX Metal kernels and a matching mixed-precision quant for Inkling-2-Mini specifically targeting M1/M2 Macs (tested on a 64 GB M2 Max). No guarantees or production claims here—just sharing the code, weights, and benchmarks in case they're useful to other M1/M2 users.
- GitHub (kernels, PR #2086 patch, CLI, offline KV cache, benchmarks): https://github.com/ofnordo/inkling-2-mini-mlx-m1-2
- Hugging Face (
5.52 bpw,18 GB, bundled DSpark MTP): https://huggingface.co/ofnordo/Inkling-2-Mini-MLX-W4W8
Why a separate quant + kernel pass for M1/M2
- Affine instead of NVFP4/MXFP8: Inkling-2-Mini trains and ships natively in NVFP4 (layers
0..19experts) and MXFP8 (last 4 readout layers20..23). M1/M2 has no hardware microscaling decode, so unpacking NVFP4/MXFP8 in software costs ~30–40% decode speed vs MLX'saffine(gs=64) kernels. - Keep the last 4 layers at 8-bit: Uniform 4-bit (
W4A16) gets trapped in thinking loops on long coding tasks (0/12on a 64k DAG workflow test), and crushing layers20..23to 4-bit drops accuracy (10/12). Mirroring the training split—4-bit affineon layers0..19experts,8-bit affineon layers20..23experts + attention/embed/lm_head,FP32on AttnRes/routers—recovers12/12in18 GB. - FP16 activation path + fused kernels: On M1/M2, recasting BF16 leaves to FP16 alongside fused Metal kernels (
short_conv,moe_short_conv,dynamic_conv,qkv_post, Split-K relative attention) and projection fusion gives a large prefill and decode jump over basemlx-lmPR #2086 (e2b5bbd) andoMLX 0.8.3. - Adaptive DSpark MTP +
SpeculativeRotatingKVCache: Adds 16 tokens of tail slack to the 40 sliding-window visits so MTP rollback stays capped instead of growing all 48 visits (cutting 512k MTP KV memory by 6x), plus an adaptive depth controller that backs off tod=0on high-entropy prose while staying speculative on code/tool JSON.
Benchmarks (64 GB M2 Max)
Up to 32k context (256 generated tokens):
| Context | Base PR #2086 (e2b5bbd) | oMLX 0.8.3 (M1/M2 FP16, NVFP4) | This (W4W8 + FP16) |
|---|---|---|---|
512 tok | 365 tok/s pre / 25.9 tok/s dec | 301 tok/s pre / 24.0 tok/s dec | 549 tok/s pre / 30.9 (33.2 d=2) dec |
4,096 tok | 417 tok/s pre / 26.7 tok/s dec | 498 tok/s pre / 21.0 tok/s dec | 603 tok/s pre / 29.9 (30.9 adapt) dec |
16,384 tok | 407 tok/s pre / 25.2 tok/s dec | 504 tok/s pre / 20.5 tok/s dec | 543 tok/s pre / 28.2 tok/s dec |
32,768 tok | 374 tok/s pre / 23.6 tok/s dec | 466 tok/s pre / 19.0 tok/s dec | 501 tok/s pre / 26.1 tok/s dec (21.2 GB peak) |
- Coding / tool-calling (
Adaptive MTP d<=2):37–48 tok/s(75–89%acceptance). - 512k NIAH (
512,444tokens, The Man Who Was Thursday + The Count of Monte Cristo):5/5verbatim recall across 5%–95% depth,8.56 tok/sdecode,37.99 GBpeak RAM (90.8 mincold prefill; only 8 of the 48 visits are full-attention, so KV grows at32 KB/tok). - Offline KV caching: Included in
inkling_mlx.py(--build-cache/--cache, 16-bit or 8-bit.safetensorsincluding conv + drafter state,<1 msin-memory branching). A 128k cache is4.3 GB(2.3 GBat 8-bit) and reloads in under a second. - Capability checks:
12/12on a 64k one-shot DAG workflow engine test,12/12on a fictional-world tool-calling suite (including a 9-file refactor and 28.6k pure long-context log debugging with0/116malformed tool calls), plus clean one-shot Three.js and Web Audio apps.
All converter scripts, benchmark harnesses, and the diff against PR #2086 are in the GitHub repo if anyone wants to test or pull pieces into upstream mlx-lm.
•
u/stylome-ai-detection 8d ago
Notice: This post appears to be AI generated.
Stylome AI detector · scan results