Skip to content

qwen3_5 CUDA: windows of 2-8 rows run at 4 and 8 rows, not 16 (#2909) - #2934

Merged
ashhart merged 2 commits into
mainfrom
lead/q35-cuda-small-buckets
Nov 13, 2026
Merged

ashhart merged 2 commits into
mainfrom
lead/q35-cuda-small-buckets

Conversation

@ashhart

@ashhart ashhart commented Nov 11, 2026

Copy link
Copy Markdown
Owner

Fixes #2909.

On CUDA, every Qwen 3.5/3.6/3.8 window over one row padded to a multiple of 16. At four streams, a 4-row decode window ran as 16: lane_gemv loaded, multiplied and stored 12 padding rows, and attention launched the matching dead blocks.

Shape.init now buckets 1 row as 1, 2-4 as 4, 5-8 as 8, and larger windows as before (cuda_shapes.zig:19). An audit of every Shape.total read in qwen3_5/cuda_*.zig found nothing that assumes a multiple of 16: they're per-row counts and grids, row-table lengths, real rows, a trace label and the prompt tail. Warm-up already captures each distinct key.

Exact: every kernel takes its live rows from the segment table, and MMA rows are independent. Cheaper 2-8-row windows change the measured window costs, so the lanes may pick different widths, but replies must not change.

Tests: the shape test fails on main ("expected 4, found 16") and passes here (4 for 2-4 rows, 8 for 5-8, 16 for 9).

Not yet checked on a GB10: a 4- and an 8-row window's logits equal to the same window at total 16 and to one-row steps, served 4-stream replies byte-equal to main, and the A/B (expected +0.5-2% at four streams).

@ashhart

ashhart commented Nov 11, 2026

Copy link
Copy Markdown
Owner Author

GB10 checks on this head (Qwen3.8-27B MLX 4-bit, main against this PR, base new new base):

Cell Main This PR Change
1 stream, chat greedy 15.2 / 15.2 15.3 / 15.3 +0.7%
4 streams, chat greedy 51.0 / 51.2 51.8 / 51.8 +1.4%
4 streams, chat T=1 50.3 / 50.4 51.1 / 51.1 +1.5%
4 streams, code greedy 51.6 / 51.8 52.5 / 52.5 +1.5%
4 streams, code T=1 50.2 / 50.4 51.1 / 51.1 +1.6%

One-stream code cells are level (+0.0% to +0.3%). Tokens are equal, and the chat cell (serial and concurrent turns over a 30k-token history, thinking off and on) resumes with every reply equal on both arms. CI is green. Queued to land.

  • Synthena (Ash's Agent)

A decode window of 4 rows was captured at 16 rows, so lane_gemv loaded and
stored 12 padding rows and attention launched their dead blocks. Shape.init
now buckets 1 row as 1, 2-4 as 4, 5-8 as 8, and larger windows as before.
Every kernel takes its live rows from the staged segment table and MMA rows
are independent, so a row keeps the bits of the same one-row step.

Warm-up and the cost table follow the new keys: seven buckets instead of five
warm at start, and the live-width tests pin the new call counts. The shapes
tests now run in the qwen35 module and get their own host step.
@ashhart
ashhart force-pushed the lead/q35-cuda-small-buckets branch from 1572881 to f32e6cc Compare November 13, 2026 17:03
@ashhart
ashhart merged commit d1dae4f into main Nov 13, 2026
1 of 9 checks passed
@ashhart
ashhart deleted the lead/q35-cuda-small-buckets branch November 13, 2026 17:03
ashhart added a commit that referenced this pull request Nov 13, 2026
Figures and scope corrected to the PRs (#2948, #2863, #2934, #2933, #2921, #2906, #2878, #2892, #2851, #2728, #3072,
#2915, #2864, #2854 and others), promises of later work removed (#2903, #2875, #1630, #1720), #3074 and #3047/#3046
said as their PRs scope them, the duplicate #2861, #2585, #2321 and #2719 entries and two copies of released 1.2.5
lines removed, #1953's line named for its PR, and a line for #3255. Released sections unchanged.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

qwen3_5 CUDA: windows of 2-8 rows run padded to 16

1 participant