Repository navigation
feat(xla): add gated delta-rule primitive and probe - #3607
Merged
Merged
Conversation
3 tasks done
Adds the matrix-valued delta-rule recurrence Qwen3-Next / Qwen3.5 (GatedDeltaNet) and Kimi-Linear (KDA) need: a one-step form and a chunk-64 prefill with a fixed 64-step forward substitution, both f32 and matching HF torch_recurrent_gated_delta_rule / torch_chunk_gated_delta_rule. The scalar and per-channel gates share the primitive through DeltaConfig. A one-layer IREE probe (emit_delta_probe, examples/xla_ssm_probe.rs --kernel delta, delta_oracle.py, delta_gate.sh) passes every acceptance case on local-task and hip at 5e-5. FINDINGS_ssm.md records compile time, op and dispatch counts at capacity 256 and 4096. Model wiring stays with #3353/#3354. Refs #3352
MLXCEL_DELTA_GATE, MLXCEL_DELTA_MODE and MLXCEL_DELTA_T are read only from the opt-in #[ignore] dump test in emitter/mod.rs, so they join the existing MLXCEL_SSM_MODE and MLXCEL_SSM_T entries in the same allowlist block. verify-env-var-docs fails without them.
inureyes
force-pushed
the
feature/issue-3352-gated-delta-primitive
branch
from
December 1, 2026 08:15
a6472f0 to
63d2d35
Compare
inureyes
marked this pull request as ready for review
December 1, 2026 08:23
This was referenced Dec 1, 2026
26 tasks
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 the matrix-valued delta-rule primitive that Qwen3-Next / Qwen3.5 (GatedDeltaNet) and Kimi-Linear (KDA) need in place of the selective scan: one decode step and a chunk-64 prefill with a fixed 64-step forward substitution, f32, matching HF
torch_recurrent_gated_delta_ruleandtorch_chunk_gated_delta_rule. This is the contract #3353/#3354 consume; model wiring is deferred there.What changed
src/lib/mlxcel-xla/src/emitter/delta.rsanddelta_chunk.rs:DeltaGate(Scalar / PerChannel),DeltaConfig,delta_step,delta_prefill. Prefill batches chunks, solves(I + T)[Wv | R]by forward substitution, and scans theT/64inter-chunk states the way HF and MLX do. Padded rows getg = 0,beta = 0in-graph.emit_delta_probeinemitter/model.rs, its dump test inemitter/mod.rs, anddelta_probe.rs(probe spec, IREE auxiliary runner,XlaCache::DeltaProbe).examples/xla_ssm_probe.rs --kernel delta, plusspike/openxla/delta_oracle.py,delta_gate.shanddelta_lowering_measure.py.spike/openxla/FINDINGS_ssm.mdaddendum: per-case max-abs table for both gate modes on local-task and hip, and compile time / op / dispatch counts at capacity 256 and 4096.Validation
Every delta gate case passed on both devices (11/11 each, tolerance 5e-5), worst max-abs 9.54e-7 (hip, per-channel full prefill). The per-case table and the exact commands are in the
FINDINGS_ssm.mdaddendum; the two reproductions are:Lowering at tiny probe dims (ops / dispatches / llvm-cpu compile s / rocm compile s): scalar 256
597 / 115 / 4.41 / 1.20, scalar 40961917 / 475 / 24.62 / 6.61, per-channel 256601 / 116 / 4.80 / 1.20, per-channel 40961921 / 476 / 22.01 / 6.40. The 64-step substitution is the fixed part (~509 ops); capacity only adds the 22-op inter-chunk scan per chunk.Also clean locally:
cargo test --profile test-fast -p mlxcel-xla --lib(602 passed, dense goldens included),cargo test ... --lib delta,cargo clippy -p mlxcel-xla --lib --tests -- -D warnings,cargo fmt --all -- --check.Closes #3352