Skip to content

Inkling 2 and Inkling 2 Mini, with DSpark speculative decoding - #65

Merged
rromenskyi merged 5 commits into
mainfrom
inkling2
Nov 23, 2026
Merged

rromenskyi merged 5 commits into
mainfrom
inkling2

Conversation

@rromenskyi

Copy link
Copy Markdown

Summary

  • mlx_lm.models.inkling2: Inkling 2 (inkling2) and Inkling 2 Mini (inkling2_loop), from the upstream draft PRs Add Inkling 2 model ml-explore/mlx-lm#2061 and Add Inkling 2 Mini model ml-explore/mlx-lm#2086, with the parts of the new upstream layout they import (mlx_lm/layers, kernels/bitlinear.py), not the whole layout refactor.
  • Loading: bf16 experts load as they are (only uint8 tensors are packed NVFP4 / MXFP8); save_config keeps vision_config for inkling2; load_processor(config) as upstream (nothing called the old signature).
  • DSpark speculative decoding for Inkling 2 Mini's mtp.safetensors (inkling2/dspark.py, generate.dspark_generate_step, picked by stream_generate), as vLLM's reference. Rejected drafts roll back exactly: key/value caches as for Gemma 4's drafter, convolution states from windows the verify forward records.
  • setup.py: find_packages. The hand-written list missed mlx_lm.kernels, mlx_lm.processors and the new packages, so a pip install from git had no inkling2.

Published models that need this: roman220220/Inkling-2-Mini-gptq-mlx-jang and -small.

Test plan

  • tests/models/test_inkling2.py (8) and test_inkling2_dspark.py (5) pass with MLX_ENABLE_TF32=0; the cache / batch / loop tests fail only under TF32 (M5 default, 1e-4 tolerance).
  • tests/test_models.py, tests/test_utils.py: 191 pass.
  • Logits vs transformers 5.24 on a tiny checkpoint in the published layout: 4e-6 (fp32).
  • Real Inkling 2 Mini on CUDA (mlx[cuda]): convert, perplexity, vision, image answer, DSpark 1.8 / 3.6 tokens per step.

🤖 Generated with Claude Code

Roman Romenskyi and others added 5 commits November 22, 2026 16:06
Backports the inkling2 package from the upstream draft PRs (ml-explore#2061, ml-explore#2086)
together with the pieces of the new upstream layout it needs
(mlx_lm/layers, kernels/bitlinear), without the full models-layout refactor.
Prefill/forward tests pass; cached decoding and batching still mismatch
against our cache.py.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- sanitize: unquantized (bf16) w13/w2 experts load as they are; only
  uint8 tensors are packed NVFP4 / MXFP8.
- save_config keeps vision_config for inkling2 / inkling2_loop.
- load_processor(config) as upstream, by model package; inkling2 added.
  Nothing called the old load_processor(model, config).

The cache, batch and loop tests failed only under TF32 (M5 default);
with MLX_ENABLE_TF32=0 all eight pass.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The draft as vLLM's reference: an anchor + mask block through three dense
layers over per-layer mixed target features as context K/V, then the
recurrent Markov head chaining the drafts. The model returns the features
of the target layer visits; dspark_generate_step verifies a block, keeps
the longest matching prefix and rolls the caches back exactly (key/value
caches as for Gemma 4, convolution states from the windows the verify
forward recorded). stream_generate uses it when the model has the draft.

Tests: greedy output equal to plain decoding (fp32), partial acceptance
with oracle drafts, the cache after an early stop, sanitize.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The hand-written list missed mlx_lm.kernels, mlx_lm.processors,
mlx_lm.layers and mlx_lm.models.inkling2: a pip install from git had no
inkling2 model ("Model type inkling2 not supported") and no kernels. Now
find_packages, plus mlx_lm.quant (no __init__.py).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@rromenskyi
rromenskyi merged commit 197a226 into main Nov 23, 2026
2 checks passed
@rromenskyi
rromenskyi deleted the inkling2 branch November 23, 2026 02:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant