Repository navigation
qwen35: use GDN state rows for safe single-sequence plain decode - #407
Merged
Merged
Conversation
Empty recurrent-state views can reach async uploads after #393. Metal cannot allocate a zero-length staging buffer. Assisted-by: Codex
Use rows reads and K=1 scatter for fused single-token decode. Require one active sequence and no extra recurrent rows to avoid relocation ordering hazards. Assisted-by: Codex
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.
Depends on #406 (the Metal empty-upload fix); this branch contains that commit too.
Plain Qwen3.5 decode currently gathers and copies the full recurrent state for every GDN layer and token, because rows mode is gated on
n_rs_seq > 0(speculative decoding only). This enables the existing CPU/Metal rows reads and fused writeback for single-token plain decode when exactly one sequence is active and there are no extra recurrent rows, sobuild_rs_cache_viewcannot relocate state. Multi-sequence decode and prefill keep the gathered path. CUDA dispatch is unchanged.Correctness: greedy token IDs identical to the gathered path on three Qwen3.5-architecture model sizes (1,280/1,280 per model), including parallel, interleaved and shared-prefix multi-sequence cases, CPU weights, rollback snapshots and a two-slot llama-server run; Metal and CPU GATED_DELTA_NET/SET_ROWS test-backend-ops all pass.
Performance (M5 Pro, tg, indicative; candidate bracketed by gathered controls on a shared host, a quiet-window repeat is still pending): decode +3.3%, +11.7% and +8.0% on the small, medium and large model; prefill unchanged.