Skip to content

qwen35 cuda: opt-in all-length rows attention for multi-row BF16 decode windows - #4496

Merged
ashhart merged 3 commits into
mainfrom
lead/q35-attn-all-rows
Nov 23, 2026
Merged

ashhart merged 3 commits into
mainfrom
lead/q35-attn-all-rows

Conversation

@ashhart

@ashhart ashhart commented Nov 22, 2026

Copy link
Copy Markdown
Owner

What this changes

Multi-row BF16 decode windows launch both the partial and the rows attention kernels, and the split happens at GROUP_LEN = 8192. The rows kernel is already aligned with the one-row kernel's score and reduction order and writes the same partial representation the merge reads. With TF_QWEN35_ATTN_ALL_ROWS=1, windows above one row use the rows kernel at every length, and the unused partial launch is skipped. Default off; one-row decode and the merge are unchanged.

Checks

  • Host checks and the CUDA compile pass. Contract cells compare the two paths byte for byte at contexts of 512 to 16K tokens and windows of one to sixteen rows; they need a GPU. fmt, ast-check, lean and the 600-line cap pass.

Still to run

On CUDA devices (sm_121 and sm_120): the attention contract, then Qwen3.8-27B + DFlash2 one-stream served cells at 2K and 7K context, A-B-B-A, tokens compared.

@ashhart
ashhart force-pushed the lead/q35-attn-all-rows branch from afed04b to b8d403a Compare November 23, 2026 12:23
@joshuaswarren

Copy link
Copy Markdown
Contributor

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

tf-cuda-test kernel-contract all-length (filtered to this PR's spec, cuda qwen35 opt-in all-length BF16 rows attention):

  • shapes: 21 shapes bit-equal to the kernel it replaces (worst 0.000 of the bound), 0 edges refused
  • repeat: five runs byte-identical (12288 bytes), inputs and guards untouched
  • sums: exact sums at k 16384
  • nonfinite: FAIL on the planted case is a KNOWN finding - a NaN key in one of a row's several chunks leaves the row finite (tf_q35_attn_merge skips that chunk), documented in the spec
  • limits live sm_120: shared bytes 101376/101376, threads 1024/1024 against the driver
  • SUMMARY: 1 kernel, 1 pass gates 1-4, 0 fail, 1 known finding, 0 controls, 0 limit problems (gates 16908 ms)

Run under idle-guard on the lab queue (ticket 8bdaf633): rc=0, FOREIGN-GPU-USED=0, GPU-TIMEOUTS delta=0. Note: the row's receipt carries guard markers only; the gate table above was captured by re-running the same binary/test interactively after the guarded run, same tree, same head.

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

@ashhart
ashhart force-pushed the lead/q35-attn-all-rows branch from b8d403a to 7645329 Compare November 23, 2026 22:10
@ashhart
ashhart merged commit 1166f5d into main Nov 23, 2026
11 of 12 checks passed
@ashhart
ashhart deleted the lead/q35-attn-all-rows branch November 23, 2026 22:10
ashhart added a commit that referenced this pull request Nov 23, 2026
ashhart added a commit that referenced this pull request Nov 23, 2026
ashhart added a commit to laudney/TensorFold that referenced this pull request Nov 23, 2026
ashhart added a commit that referenced this pull request Nov 23, 2026
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