Repository navigation
feat(inkling2_loop): add inkling-2-mini support - #942
Open
ischencheng wants to merge 31 commits into
Open
ischencheng wants to merge 31 commits into
ischencheng wants to merge 31 commits into
Conversation
…rence conversion ops
# Conflicts: # tests/moe/test_mixed_expert_formats.py
4 tasks done
KarrAcaRn
pushed a commit
to KarrAcaRn/FreeToken-ByAI
that referenced
this pull request
Nov 21, 2026
…-mini support Conflicts: the model's own-kernel KV format check joins next's kv_format_unsupported_reason (so ft info's tips skip it too); the offload prefill hook start_prefill_call is skipped on a layer-major chunk (FlashML-org#686), whose prefill the engine already began and which runs layer 0 once per chunk; docs keep next's Flint link next to the new Inkling row. Assisted-by: Claude Opus 5.5
KarrAcaRn
pushed a commit
to KarrAcaRn/FreeToken-ByAI
that referenced
this pull request
Nov 21, 2026
…after FlashML-org#942 Assisted-by: Claude Opus 5.5
KarrAcaRn
pushed a commit
to KarrAcaRn/FreeToken-ByAI
that referenced
this pull request
Nov 21, 2026
Batch 2026-11-21: FlashML-org#942 FlashML-org#940 FlashML-org#918 FlashML-org#917 adopted, FlashML-org#915 deferred; FlashML-org#354 superseded by upstream FlashML-org#894, FlashML-org#408 ported onto its KVFormat framework. Assisted-by: Claude Opus 5.5
KarrAcaRn
pushed a commit
to KarrAcaRn/FreeToken-ByAI
that referenced
this pull request
Nov 21, 2026
…efstand Debug: code-review 1.0, Delta-E 0.9 (1 correction), result-init 1.0; echt (3 runs, generation_config temperature 1.0): code-review 0.67/1/1, Delta-E 0.24/0.9/0.79, result-init 1/1/0.67. ~40 tok/s, 82k context with --memory-ratio 0.85 --kv-reserve-tokens 82000. New think_format inkling2 (TMLv0 thinking message -> text message) for the think-stop continuation. run.py finds the FreeToken checkouts next to its own instead of the old ~/claude/ paths. Assisted-by: Claude Opus 5.5
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #941
Adds thinkingmachines/Inkling-2-Mini (
Inkling2LoopForConditionalGeneration, revision6e7c8248f7): text and image input, the official NVFP4/MXFP8 checkpoint, its DSpark draft, andfused,offload,hybridandcpuexperts.It's an Inkling 2 MoE (24 layers, hidden 2304, 128 experts top-8, 20 sliding-window layers and 4 global ones) whose layers 6-17 run three times per token with shared weights. Passes 2 and 3 restart from the residual state after layer 5 and mix in four messages per layer (q, k, v, MLP inputs) that learned queries read from the previous pass, through low-rank tanh gates. Layers 18-23 then run once on the last pass's state. The reference is huggingface/transformers#51050 (
6173a2f679),models/inkling2_loop/.What it needed here:
cache_offset: 48 cache layers (40 sliding, 8 global) on 24 weight layers.ModelConfig.num_kv_layerssizes the KV pool apart fromnum_layers, and the convolution windows (k, v, after attention, after the MLP, 3 tokens each) areslot_statesofLinearStatePool, which now builds with no GDN group.kernel/triton/inkling2_attention.py). Logits are fp32. The kernel reads unquantized KV only, so--kv-cache-dtypeother than the default is refused at config time (ModelConfig.kv_formats).swiglu_softcap:4*tanh(g/4)*sigmoid(g)*25*tanh(u/25)) in the GPU kernels and the CPU executor. Layers 0-19 are NVFP4 and run W4A16; the experts declare no static activation scale. Layers 20-23 are MXFP8, which has no expert kernel here yet, so they are dequantized to bf16 at load (lossless, about 4 GB more).w13stores gate and up rows interleaved. The checkpoint'sconfig.jsoncalls the whole model NVFP4, so a newModelSpec.quant_confighook builds a ModelOptMIXED_PRECISIONconfig fromhf_quant_config.json's parameter groups instead.--moe-strategy cputakes them too: with several slot pools it sizes each pool so every bank stages two whole layers in its widest format.--moe-cpu-layerswith several formats still refuses.moe_layer_order, since layer 6 follows layer 17 twice) and clears its staging after the last call in that order. That is why even a 26-token prompt takes about 1.35 s to first token under offload on the A10.--image-max-tokens(16384 when unset, a 5120x5120 image) is refused. The features replace the token embeddings afterembed_norm, as in the reference.inkling2reasoning and tool-call parsers, following the checkpoint'schat_template.jinjaandresponse_template:<|message_model|>[name]<|content_KIND|>...<|end_message|>messages, thinking to reasoning,invoke_tool_jsoncalls with{"name": ..., "args": {...}}.autopicks both frommodel_type/architectures.mtp.safetensors, 3 layers, block 8, Markov head) under--speculative-algorithm mtp. Its taps are the inputs of runs 5, 23 and 41 in execution order and the final hidden. Convolution windows roll back on rejection like the GDN verify.Shared code this touches, and what it does for other models:
--moe-strategy cpuused to refuse several slot pools; now it sizes them by bytes, so other mixed-format checkpoints can take it too. Single-format models keep 2E slots.swiglu_softcapis a new CPU MoE activation id, so a CPU MoE module built before this is refused by the ABI probe instead of computing silu.LinearStatePoolbuilds with only slot states;ModelConfig.num_kv_layersandno_prefix_reuseandModelSpec.quant_configdefault to what every other family does today.If you'd rather take the resident mixed-format experts or the DSpark draft as their own PRs, I can split them out.
Tested on an RTX PRO 6000 (sm_120) and an A10 (sm_86), driver 610.57.04 on the runs that logged it (620.70.06 on the A10G of the post-merge test run), torch 2.14.1+cu130, triton 3.8.0, checkpoint
thinkingmachines/Inkling-2-Mini@6e7c8248f7. The containers report no CPU model name (4 cores with the RTX PRO 6000, 16 with AVX-512 VNNI on the A10). The runs drivefreetoken.LLMfrom a script, except GSM8K, which starts the server:LLM(model, moe_strategy="fused", max_running_req=2, max_seq_len_override=16384), once eager (cuda_graph_bs=[]) and once withcuda_graph_max_bs=2LLM(model, moe_strategy=<offload|hybrid|cpu>, memory_ratio=0.85, max_running_req=2, cuda_graph_max_bs=2), withmoe_cache_auto=Truefor offload and hybrid andmax_seq_len_override8192 on the A10, 16384 on the RTX PRO 6000LLM(model, max_running_req=4, max_seq_len_override=16384)with and withoutspeculative_algorithm="mtp"python -m freetoken.cli serve --model thinkingmachines/Inkling-2-Mini --max-running-requests 32 --cuda-graph-max-bs 32 --moe-strategy fused --max-seq-len-override 8192 --max-extend-length 2048, then/v1/chat/completionswithtemperature0Parity against the reference (bf16, experts dequantized to bf16, eager attention) on four prompts: a 26-token chat, a 157-token tool call, a 3993-token code summary and a 462-token image prompt (432 image tokens). The comparison is per run of a layer (48 per forward), relative L2:
input_idsare equal toInkling2ImageProcessor/Inkling2Processoron 7 images (RGB, L, RGBA, LA, P with transparency, odd sizes).reasoning_effortlow,max_tokens4096, 32 at a time on the RTX PRO 6000 withfusedexperts: 390/400 (97.5%), none cut by length or without an answer.16 GB: another process holds the rest of the card, so the engine sees 16.0 GiB,
--memory-ratio 0.85, CUDA graphs. On the A10 the 26-token chat's 198-token answer equals the reference's text under all three strategies.--moe-strategyAt the default
--memory-ratio 0.9the 3993-token prefill runs out of memory infused_experts_nvfp4with 1.5 GiB left after init; docs/models.md says to start at 0.85. The test containers' PCIe (13-25 GB/s between A10 hosts) and server CPUs don't say how a desktop does.DSpark on the RTX PRO 6000 (
moe_strategyauto, full card, CUDA graphs 1/2/4): 3.21 tokens per verify (138 verifies over 3 prompts, up to 256 tokens each), one stream 34.0 -> 54.2 tok/s. Greedy output with and without drafts is the same on the tool call (82/82); the chat splits at token 5, where it also splits from the reference, and the code summary at token 76.Tests on the RTX PRO 6000 at
80b6ef2, before merging main:pytest -m "not slow" tests/2688 passed, 315 skipped, 4 failed, and the same four fail on main2fb371e:test_capture_rows_per_req.py::test_graph_replay_matches_eager_attention[fa-1]and[fa-4](no FA3/FA4 kernels for sm_120),test_pinned_tensor.py::test_host_device_ptr_is_identity_under_uvaandtest_swiglu_clamp.py::test_triton_matches_reference. After merging mainc84946b(#916, the CPU executor's per-expert grouping),tests/moe/test_cpu_moe.py,tests/moe/test_mixed_expert_formats.py,tests/kernels/test_swiglu_clamp.pyandtests/models/inkling2_loop/on an A10G at this head: 86 passed, 27 skipped. The new tests check against independent references: a port of the reference's ops for attention, convolution, routing and the activation (checked equal to the transformers classes on CPU, maxabs 0 for all but the activation at 7.6e-6), the reference's conversion ops for the checkpoint transforms, the HF image processor, a template render -> parse -> render round trip for the parsers, and a dense recompute for every DSpark acceptance count.Not covered
ModelConfig.no_prefix_reusemakes the engine serve--cache-type radixasnaivewith a warning.--max-extend-length 8192, so many concurrent requests need a smaller--max-extend-length(docs/models.md says so).--image-max-tokens.is_varloop).--moe-strategy cpuwith other mixed-format checkpoints (mixed-type GGUFs) loads now, but I only ran it on this one.