Repository navigation
feat(xla): add Qwen3-Next and Qwen3.5 text hybrids (GatedDeltaNet) - #3614
Merged
Merged
Conversation
4 tasks
inureyes
force-pushed
the
feature/issue-3353-qwen3-next-qwen35
branch
from
December 1, 2026 10:42
f497900 to
280627a
Compare
Add the Qwen3-Next and Qwen3.5 text hybrids to the OpenXLA / IREE emitter: GatedDeltaNet linear-attention layers interleaved with gated full attention, softmax-routed MoE with a gated shared expert, and the two checkpoint layouts that share the math. Config parsing (`emitter/qwen3_next_config.rs`): read `layer_types` or `full_attention_interval`, the delta dimensions and kernel, the MoE schedule (`mlp_only_layers`, `decoder_sparse_step`), `rope_parameters` (`rope_theta`, `partial_rotary_factor`), the `(1 + w)` norm style, per-head `(1 + w)` q/k norms, and the `attn_output_gate` output gate. Qwen3-Next parses directly; the Qwen3.5 VLM wrapper unwraps `text_config` (`model_type = qwen3_5_text`) and ignores the vision tower, using the new `WeightScheme::Qwen35` for the `model.language_model.*` names. Delta mixer (`emitter/delta_model.rs`): unwrap the fused `in_proj_qkvz` / `in_proj_ba` per-key-head `[q, k, v, z]` / `[b, a]` grouping (with element-count assertions, since a wrong grouping width is only a reshape error at compile time), split the separate Qwen3.5 `in_proj_qkv` / `in_proj_z` / `in_proj_b` / `in_proj_a`, run the short causal conv over the flat `q | k | v` with the carried tail, compute `g = -exp(A_log) * softplus(a + dt_bias)` and `beta = sigmoid(b)`, advance the landed delta primitive, then the plain gated RMSNorm and `out_proj`. Threading: `MixerKind::GatedDelta` splits `RecurrentLayers` into SSM and delta state rows, `state_tensors` declares `delta_s` then `delta_conv`, the Jamba-style block order is reused, the delta state advances per slot in the ragged decode, and the prefill threads `real_len` so padded rows stay inert. Attention: the `q_proj` per-head `[query | gate]` split multiplies the attention output by `sigmoid(gate)` before `o_proj`; ungated families keep their exact previous graph. Weights, checkpoint validation, weight names and the MFE/structural fixtures are extended for both layouts. Evidence: the real `Qwen/Qwen3.5-0.8B` (revision 2fc06364715b967f1860aea9cf38778875588b17) is token-exact against an HF transformers fp32 oracle and reference-exact across four serving slots, and four concurrent HTTP completions equal their CLI outputs. A synthetic tiny Qwen3-Next checkpoint (fused projections, three delta layers, one gated-attention layer, four experts plus a gated shared expert) is token-exact against its `Qwen3NextForCausalLM` fp32 oracle and reference-exact in the batched engine. The oracle JSON, fixture generator and raw hip logs are committed under `spike/openxla/`. Closes #3353
Adds the raw hip evidence for the Qwen3.5 text hybrid serving gate: the CLI 40-token HF fp32 oracle check and four concurrent non-stream and SSE completions per transport, each compared byte for byte with its separate CLI reference. The provenance records the checkpoint revision, the binary sha256 and the source commit 7fe37b4; the IREE VM cache is not committed.
inureyes
force-pushed
the
feature/issue-3353-qwen3-next-qwen35
branch
from
December 1, 2026 10:43
280627a to
50474da
Compare
inureyes
force-pushed
the
feature/issue-3353-qwen3-next-qwen35
branch
from
December 1, 2026 10:49
3f42fed to
3b0f6ff
Compare
inureyes
marked this pull request as ready for review
December 1, 2026 10:50
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.
Closes #3353.
Adds the Qwen3-Next and Qwen3.5 text hybrids to the OpenXLA / IREE emitter (
mlxcel-xla): GatedDeltaNet linear-attention layers interleaved with gated full attention, a softmax-routed MoE with a gated shared expert, and the two checkpoint layouts that share the math.What changed
emitter/qwen3_next_config.rs(new): parseqwen3_nextand the Qwen3.5 VLM wrapper (text_configwithmodel_type = qwen3_5_text, vision tower ignored). Readslayer_types/full_attention_interval, the delta dimensions and conv kernel, the MoE schedule,rope_parameters(rope_theta,partial_rotary_factor), the(1 + w)norm style, per-head(1 + w)q/k norms andattn_output_gate.emitter/delta_model.rs(new): the GatedDeltaNet mixer. Unwraps the fused Qwen3-Nextin_proj_qkvz/in_proj_baper-key-head grouping (with element-count assertions, because a wrong grouping width only surfaces as a reshape error at IREE compile time), splits the separate Qwen3.5 projections, runs the short causal conv over the flatq | k | vwith the carried tail, computesg = -exp(A_log) * softplus(a + dt_bias)andbeta = sigmoid(b), advances the landed delta primitive, then the plain gated RMSNorm andout_proj.emitter/model.rs: the per-head[query | gate]q_projsplit, withsigmoid(gate)applied to the attention output beforeo_proj; ungated families keep their exact previous graph.emitter/model_recurrent.rs:RecurrentLayersnow holds an SSM row or a delta row per recurrent layer; the delta state advances per slot in ragged decode and the prefill threadsreal_lenso padded rows stay inert.emitter/delta.rs,recurrent_config.rs,config.rs:DeltaConfigaccessors,MixerKind::GatedDelta,WeightScheme::Qwen35,delta/delta_fused_proj/q_gateconfig fields,state_tensors(delta_s, thendelta_conv, both f32).weights.rs,weight_names.rs,recurrent_checkpoint.rs,validation.rs: weight specs in load order,model.language_model.*names for the Qwen3.5 wrapper, split/fused projection validation, and theqwen3_next/qwen3_5structural fixtures.Evidence
Real
Qwen/Qwen3.5-0.8B(revision2fc06364715b967f1860aea9cf38778875588b17) on IREEhip:scripts/xla/validate_arch.sh --model models/hf/qwen3.5-0.8b --device hip --batch 4 --requests 8 --maxcap 24exits 0 (structural, token-exact, serve reference-exact).spike/openxla/qwen3_5_reference/.Synthetic tiny Qwen3-Next (fused projections, 3 delta layers, 1 gated-attention layer, 4 experts plus a gated shared expert), fp32 HF
Qwen3NextForCausalLMoracle:xla_oracle_check --device hiptoken-exact,xla_batch_bench --device hip --batch 4 --requests 8 --maxcap 12reference-exact.spike/openxla/.Local: 606
mlxcel-xlalib tests pass (24 ignored), the registered structural goldens are byte-identical (10/10),cargo fmt --check,cargo clippy -p mlxcel-xla --all-targets -D warnings, the CI clippy invocation (cargo clippy -p mlxcel --lib --tests -D warnings) and theverify-env-var-docs/verify-versions/verify-kernel-dtype-keys/verify-used-bygates all exit 0.Notes
text_config.rope_parameterscarriesmrope_*keys that are ignored because text-only positions are identical across the m-rotary sections, which the token-exact gate confirms against HF.mtp_*config keys) is not part of the causal-LM path and is not loaded.