Repository navigation
fix: opt Qwen3-Next out of no-ID chunked prefill - #2295
Merged
Merged
Conversation
Qwen3-Next resets its model-owned GatedDelta and KV state when a multi-token forward carries no sequence ID. Advertise the conservative single-pass policy so cache-less callers cannot silently discard earlier prompt pieces while preserving independent-prompt resets and stable sequence-ID continuation. Add a one-layer GatedDelta model loaded from deterministic nonzero weights. The regression forces both paths and verifies offset 3 after two independent no-ID prompts and offset 5 after two forwards with one sequence ID. The CUDA library test graph builds, the focused GPU test passes, and formatting and diff checks pass. Refs #2285
`PrefillCaps` consumes the model-wide chunking capability for every token-ID prefill plan. Clarify that DirectEngine's stable sequence ID makes its state handling safe while the false capability still forces DirectEngine and cache-less callers to build one whole-prompt graph. This changes only the source comment, PR documentation, and bilingual reports. The prior focused GPU test and contract results remain applicable. Refs #2285
inureyes
added a commit
that referenced
this pull request
Oct 20, 2026
…2493) * fix(models): continue Qwen3-Next cache across multi-token forwards Qwen3NextModel::forward_for_sequence reset the model-owned GatedDelta and KV state on every multi-token forward that carried no sequence id, so one multi-token forward behind a populated cache ran from an empty state while the same tokens forwarded one at a time behind it continued the cache. This is the shape speculative-decode verification uses, and teacher-forced traces on Qwen3-Next-80B-A3B-4bit showed width 5 behind 512 tokens of context reading perplexity 980 while widths 1 and 256 read 27 and 24. Drop the reset so a no-ID multi-token forward continues the fallback cache, matching the Qwen3.5 model, and remove the no-ID chunked-prefill opt-out #2295 added while the reset existed. Callers that start a new prompt reset through reset_runtime_state (the logit-trace and perplexity harnesses already do); server requests isolate per sequence through SequenceId. Validated with a synthetic eight-layer Qwen3-Next test that compares one T=5 forward against five T=1 forwards from the same post-prefill state (fails on main, passes here), and with fixed-versus-reverted traces on the real checkpoint: width 5 gives ppl 18.68 (was 980.26) and widths 1 and 256 are unchanged at 27.140 and 24.059. Refs #2463 * docs(models): fix orphaned qwen3_next comment and in_proj_qkvz formula Convert the issue-2463 chunked-prefill decision note orphaned onto `eos_token_ids` when the `supports_chunked_prefill` override was deleted from a rustdoc comment into a plain `//` comment, and correct the `hybrid_weights` fixture comment's `in_proj_qkvz` width formula to `[2*nk*dk + 2*nv*dv, hidden]` (q, k, v, z per k-head group, 48 rows for the fixture), matching the `[48, 16]` tensor. The docs sweep found no stale chunked-prefill claim to update. Validation: cargo fmt --all -- --check, cargo clippy -p mlxcel --profile test-fast --features cuda -- -D warnings, and the 16 qwen3_next lib tests pass under gpu-lock with MLX_ENABLE_TF32=0 and --test-threads=1. Refs #2463 * docs: add PR 2493 technical report
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
Qwen3NextModel::from_weightsthat proves independent no-ID prompts reset to offset 3 while a stable sequence ID continues to offset 5.Validation
mlxcelandmlxcel-surgerylibrary test graph builds successfully, andqwen3_next_loaded_model_chunking_contract_is_safepasses 1/1 under the GPU lock.Current DirectEngine prefill keeps one stable sequence ID across its pieces, so its state handling is safe.
PrefillCapsconsumes this model-wide false capability for every token-ID prefill plan, however, so DirectEngine and cache-less callers both build one whole-prompt graph instead of bounded chunks and can use more transient memory for long prompts.Closes #2285