Repository navigation
qwen3_5 cuda: streams resumed from one prompt read each shared prefix key tile once a forward - #3653
Merged
Merged
Conversation
ashhart
added a commit
that referenced
this pull request
Nov 17, 2026
Owner
Author
|
A second GB10 with the same binaries (the join build against main's, Qwen3.8-27B with paged KV and the shared store): all 344 replies are identical to main's again. Per-stream decode against main:
This second GB10 ran noisier than the first: its one-stream cells, where both arms run byte-identical kernels, moved between -6.6% and +12%. The first GB10's numbers in the description stay the reference.
|
…oss streams (join kernels) With paged KV and the shared prompt store (TF_QWEN_KV_PAGES, TF_QWEN_KV_SHARE), streams resumed from one prompt hold the same physical prefix pages. tf_q35_attn_rows / rows8 took one stream's rows a pass, so eight such streams read every prefix key tile eight times. attn_rows gains a compile-time JOIN switch. JOIN false is main's kernel: all 43 existing kernels in qwen35 and qwen35_kv8 compile to byte-identical SASS on sm_80/86/89/120/121 (nvcc 13.0.88), so the default contiguous path and every forward without shared pages run main's code, and their records are unchanged. tf_q35_attn_rows_join and tf_q35_attn_rows8_join (JOIN true) let another stream's rows join a class when both hold the chunk's span below their length in the same page ids; each line's arithmetic is its own, so every stream keeps its solo bits. The host takes them only for a paged forward where two parts' caches start on one page (cuda_cache.anyShares), as the graph shape's join bit; the shape key is 64 bits. mt2 takes one segment, so it never joins. Tests: qwen-shared-prefix (new, in the CUDA contract run) checks every stream's PM, PL, PO and merge from the join kernels against main's kernel alone, bit for bit, at 2/4/8 streams x 1/4 rows, beside a 384-key-chunk stream and a contiguous one, with two planted controls (a changed copy of a shared page, a tree row past its length). Its time mode compares the two kernels on shared and distinct pages. Host: the join rule and the shape key's uniqueness with the join bit. Measured on a GB10, Qwen3.8-27B 4-bit with paged KV and the shared store, eight streams resumed from one prompt, replies identical in every arm (344 against main, drafts off and one stream): - rows kernel at a 35K shared prefix, main's -> join: 8 x 1 rows 4.00 -> 0.82 ms, 8 x 4 2.50 -> 1.21, 4 x 1 2.08 -> 0.69; on distinct pages the two are level (-0.19% to 0.00%). - served decode, tokens a second a stream while all decode (main -> join, two arms each): 32K x 8 6.41 -> 10.08 (+57%), drafted +60%; 32K x 4 +28%; 8K x 8 +4.9%, drafted +11%; one stream, 512-token prompts and 32K distinct prompts level (-0.3% to +0.8%, main's kernels). The join kernels' records for nvcc 13.3 and later compilers are pending receipts, like their neighbours'.
ashhart
force-pushed
the
lead/oe1-shared-prefix
branch
from
November 17, 2026 07:10
ee77d98 to
3b29714
Compare
ashhart
added a commit
that referenced
this pull request
Nov 17, 2026
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.
Qwen3.8-27B on CUDA: when several streams resume from one prompt through paged KV and the shared prompt store, each shared prefix key tile is now read once a forward instead of once a stream.
The change. Two join variants of the attention rows kernels,
tf_q35_attn_rows_joinandtf_q35_attn_rows8_join, run only for a paged forward in which two streams start on one KV page. That is a new bit in the graph shape. Every other forward takes main's kernels: all 43 existing kernels inqwen35andqwen35_kv8compile to machine code byte-identical to main's on sm_80, 86, 89, 120 and 121. The serving-source pin forqwen35.cuindense_serving_test.zigis updated, with a receipt line.Exact. The shared-prefix tests pass 16 of 16 and the paged-KV tests 26 of 26, with their planted controls failing as they should. The kernel contract matches main. The host suite matches main. pr_check reports 0 errors and lean is 221 before and after.
Served, on a GB10, Qwen3.8-27B with paged KV and the shared store. Every one of 344 replies is identical to main's.
A second-box replicate with the same binaries is queued on another GB10. The Metal version comes separately.