Repository navigation
feat(xla): add Kimi-Linear KDA mixer with MLA and sigmoid MoE - #3612
Merged
Merged
Conversation
4 tasks done
inureyes
force-pushed
the
feature/issue-3354-kimi-linear
branch
2 times, most recently
from
December 1, 2026 10:50
53e02a8 to
4553e7e
Compare
Adds model_type kimi_linear to the OpenXLA emitter: a KDA mixer (per-channel gated delta rule, three short convs, A_log/dt_bias log-decay, sigmoid beta, gated RMSNorm output gate) on the layers listed in linear_attn_config.kda_layers, MLA on the rest (a direct query projection plus split per-head embed_q/unembed_out expansion, at the layer's compact KV row), and a sigmoid-routed MoE FFN. The KDA layers thread delta_s and delta_conv through the existing recurrent state ABI, so prefill, single decode and ragged continuous batching all carry them. The Kimi checkpoint uses the MLX-converted layout (flattened A_log/dt_bias, q_conv/k_conv/v_conv, embed_q/unembed_out, stacked switch_mlp experts, mlp.e_score_correction_bias); Config::validate_recurrent_checkpoint cross-checks every shape. A new WeightScheme::KimiLinear names the KDA and MLA tensor lists in the emitter's arg order for the loader. The per-channel log gate is expanded to [rows, Hv, Dk] explicitly; without that broadcast iree-compile rejects the multiply. Evidence: a seeded synthetic 4-layer checkpoint (3 KDA + 1 MLA, 8 experts top-2) and its MLX eager greedy continuation are committed under spike/openxla/kimi_linear_reference with the local-task and hip gate logs and probe JSON. New StableHLO goldens are registered; every existing golden re-emits byte-identically. Only the 48B-A3B real checkpoint exists and does not fit the 31 GiB host, so the synthetic model plus the MLX oracle is the whole evidence. At the 48B KDA geometry the per-channel prefill plans 12,739.5 MiB of transient at context 4096 (798.1 MiB at 256) while staying within 5.4e-7 of the fp32 reference, so production width needs a smaller chunk or Dk blocking before it runs; FINDINGS_ssm.md records the measurement and the follow-up. Refs #3354
inureyes
force-pushed
the
feature/issue-3354-kimi-linear
branch
from
December 1, 2026 10:58
4553e7e to
bbf132a
Compare
inureyes
marked this pull request as ready for review
December 1, 2026 10:59
inureyes
added a commit
to Jaeyeong-CHOI/mlxcel
that referenced
this pull request
Dec 1, 2026
lablup#3612 committed spike/openxla/kimi_linear_reference/model.safetensors after this branch was cut, and main fails the binary-assets check on it too. Unlike the RWKV7 fixture, it cannot be regenerated by a standalone script: examples/xla_kimi_linear_oracle.rs needs a full MLX build, and the committed oracle continuation and gate logs were measured against these exact bytes. Declare it with a 448 KiB ceiling and raise the total budget by its 390,720 bytes. Refs lablup#3611 Refs lablup#3612
inureyes
pushed a commit
that referenced
this pull request
Dec 1, 2026
Two seeded synthetic checkpoints made main fail the binary-assets gate. The RWKV7 one from #3609 is removed from Git and ignored: spike/openxla/rwkv7_oracle.py regenerates it from seed 3355, and the two #3609 reports now show how to build the fixture outside the checkout before the parity gate. Regeneration on GB10 (aarch64) reproduced SHA-256 6b3b9811...d828c byte for byte, with identical greedy tokens. The Kimi-Linear checkpoint from #3612 is declared instead, with a 448 KiB ceiling and the total budget raised by its 390,720 bytes, because regenerating it needs a full MLX build and its committed oracle and gate logs were measured against these exact bytes. Refs #3609, #3612
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.
Summary
Adds
model_type = "kimi_linear"to the OpenXLA/IREE emitter. KDA (the per-channel gated delta rule from #3352) runs on the layers inlinear_attn_config.kda_layers, MLA on the rest, and both feed a dense or sigmoid-routed grouped MoE FFN (from #3345). The KDA mixer runs three short causal convs, theA_log/dt_biasper-channel log decay,beta = sigmoid(b_proj), the delta primitive, the gated output RMSNorm ando_proj; the MLA layer reuses the DeepSeek-V3 path with a direct query projection and the split per-headembed_q/unembed_outexpansion, at the layer's compact KV row.delta_sanddelta_convthread through the existing recurrent-state ABI in prefill, single decode and ragged decode.The checkpoint is the MLX-converted layout;
Config::validate_recurrent_checkpointchecks every KDA, MLA and MoE tensor shape. A seeded synthetic 4-layer checkpoint (3 KDA + 1 MLA, 8 experts top-2) and its MLX eager greedy continuation are committed, because only the 48B-A3B checkpoint exists and does not fit this host. The oracle is mlxcel's own MLX eager model, not an independent HF implementation.Validation
xla_batch_bench --batch 4 --requests 8reference-exact; the per-channel KDA probe reads max-abs 3.58e-7 (prefill) and 1.19e-7 (decode) at the synthetic KDA dims, and 2.68e-7 / 1.19e-7 at the 48B'sHv=32, Dk=128geometry, all within the 5e-5 bar.-D warnings, fmt clean;make verify-env-var-docs,verify-versions,verify-kernel-dtype-keysandverify-used-bypass. The four new goldens are registered and every pre-existing golden re-emits byte-identically.spike/openxla/kimi_linear_reference/.Production-width limitation (measured)
delta_lowering_measure.py --dims kimi_prodplans 798.1 MiB of transient at capacity 256 and 12,739.5 MiB (12.4 GiB) at 4096 for one per-channel prefill (still within 5.4e-7 of the fp32 reference). 12.4 GiB cannot coexist with the 48B weights on 31 GiB, so production width needs a smaller chunk orDkblocking first; the wiring keeps MLX's chunk 64 andspike/openxla/FINDINGS_ssm.mdrecords the follow-up. Raw rows are inkimi_linear_reference/delta-production-geometry.json.Closes #3354