Skip to content

qwen35 cuda: opt-in grouped same-input projections keeping each split-K - #4515

Merged
ashhart merged 5 commits into
mainfrom
lead/q35-group-proj
Nov 24, 2026
Merged

ashhart merged 5 commits into
mainfrom
lead/q35-group-proj

Conversation

@ashhart

@ashhart ashhart commented Nov 22, 2026

Copy link
Copy Markdown
Owner

What this changes

Every served Qwen3.8-27B ModelOpt projection (NVFP4, FP8, BF16) decodes in its own qmmf launch with its own split-K. With TF_Q35_GROUP_PROJ=1, projections that read the same input run as segments of one launch; a segment keeps its own split-K and K-slice order, so its outputs are byte-identical to its separate launch. This cuts launches per decode round, which matters most on GPUs with many SMs (a review estimated +5% to +11% on sm_120).

Checks

  • Host build; the device check tf-cuda-test group-proj compares each grouped projection's bytes with its own launch (rows 1 to 16, served groups, odd widths, adversarial values). fmt, ast-check, lean, 600-line cap.

Still to run

Compile and run group-proj on sm_121 and sm_120, then one-stream served A-B-B-A with tokens compared.

@ashhart

ashhart commented Nov 22, 2026

Copy link
Copy Markdown
Owner Author

One GB10 A/B (Qwen3.8-27B NVFP4 with DFlash2, base = this PR with the switch off, new = TF_Q35_GROUP_PROJ on via a local flip-default commit, order warm base new new base):

  • Prompt tokens: 0 of 12 rows differ; replies equal.
  • Prompt processing at 2K: -1.2% to -1.4% (both new runs below both base runs).
  • Decode after the prompts: level (-0.2% to +0.1%).

So on a GB10 this is exact but not a win. The change was aimed at GPUs with many more SMs (sm_120), where grouping fills the device better; it stays open and out of trains until it is measured on such a GPU.

  • Synthena

@ashhart

ashhart commented Nov 22, 2026

Copy link
Copy Markdown
Owner Author

Correction to my A/B note above: the checkpoint was Qwen3.8-27B MLX 4-bit with its DFlash2 drafter, not NVFP4. The numbers and the reading stand as posted; they say nothing yet about the NVFP4 checkpoint.

  • Synthena

@ashhart
ashhart force-pushed the lead/q35-group-proj branch 2 times, most recently from bbab639 to 7b265b8 Compare November 23, 2026 13:26
@joshuaswarren

Copy link
Copy Markdown
Contributor

sm_120 device check for group-proj, from the still-to list. RTX 5060 Ti 16 GB (sm_120), driver 615.78.08, Linux aarch64, head 7b265b85ec built with Zig 0.17.0 / nvcc -Dsm=120.

tf-cuda-test group-proj:

  • PASS: 1920 projections at rows 1-16, tensor scales and adversarial values: bytes equal - each grouped segment's bytes equal its own launch
  • Per-cell timings (grouped vs separate, rows 1 and 16): grouped is neutral-to-faster everywhere on this part - MLP gate+up ~251.7-256.4 vs 252.0-256.4 us, GDN qkv+z ~205.0-208.2 vs 205.9-208.2, GDN a+b 9.7-12.0 vs 16.4-22.0, attention q+k+v 183.8-185.4 vs 196.4-199.3, fp4 padded ~65 vs ~64, bf16 tiles ~92-95 both, fp8 four odd-width 34.1-34.4 vs 43.8-44.7 (544/512/32/448/248/392/400 blocks per cell as the test prints)

Run under idle-guard on the lab queue (ticket 87697162): rc=0, FOREIGN-GPU-USED=0, GPU-TIMEOUTS delta=0. One scheduling note: an earlier queued attempt exited at ~48 s with rc=1 during zig build (transient; the build completes cleanly on this box and the run above is on the same tree/head). The row's receipt carries guard markers only; the table above was captured by re-running the same binary/test interactively after the guarded run.

The served half of the still-to (one-stream A-B-B-A on a ModelOpt Qwen3.8-27B) needs the 27B checkpoint, which does not fit this 16 GB card - leaving that arm to whoever has the bigger box.

…ction's split-K

TF_Q35_GROUP_PROJ=1 (default off) runs a ModelOpt checkpoint's same-input
decode projections as one qmmf launch: MLP gate and up, GDN in_proj_qkv and
in_proj_z, in_proj_a and in_proj_b, attention q, k and v. Each block is one
tile and K slice of one projection in that projection's own 16-row instance
body, so its slices, order and cluster sum are those of its own launch.
Clusters are as wide as the widest split and never span two projections.
Pre-sm_90 GPUs, fused or prompt tiles and wider windows keep today's launches.
…wn launch

Rows 1-16, the served Qwen3.8-27B groups plus padding, odd widths and four
projections, adversarial weights, inputs and tensor scales; warm times at 1
and 16 rows.
Pin the reviewed grouped CUDA sources and shorten the new loader comment. Preplan compatible projection runs before launching so mixed FP8/BF16 GDN uses two groups and every fallback remains four separate launches.
@ashhart
ashhart force-pushed the lead/q35-group-proj branch from f9a216d to 1779ea2 Compare November 24, 2026 06:46
@ashhart
ashhart merged commit 5dc043d into main Nov 24, 2026
12 checks passed
@ashhart
ashhart deleted the lead/q35-group-proj branch November 24, 2026 06:46
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.

2 participants