Skip to content

qwen3_5 CUDA: split mixed-width DFlash/DSpine head batches - #4439

Open
tacosta wants to merge 2 commits into
ashhart:mainfrom
tacosta:fix/3460-mixed-width-dflash-batch
Open

tacosta wants to merge 2 commits into
ashhart:mainfrom
tacosta:fix/3460-mixed-width-dflash-batch

Conversation

@tacosta

@tacosta tacosta commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

What this changes

Qwen3.5 CUDA draft frames currently choose one head width for the whole batch. If any context is wide, narrow proposal rows also use the full 248,320-column head instead of the 98,592-column narrow spans. This keeps the shared draft body batched, then projects, selects top-k, packs table inputs, and scatters results by width group while preserving stream order and narrow token-ID remapping. It covers the shared DFlash2 and DSpine CUDA frame paths.

The change also rebuilds affine-4 projection sums after compacting rows, so sums correspond to the compacted hidden-state inputs. DFlash2 and both DSpine planes refresh the sums; EXL3 does not consume them.

Checks on this head

  • Head commit: 07dab2140012cd79b2b4ed81c49aed228b01445f.
  • Lean checker and source preflight, python3 tools/pr_check.py --base 3c088d96917acf7e898450e03a1034000fee3122 --pr 4439: lean 123 on base and head, 0 new findings; 0 new import-cycle edges; 0 errors and 4 advisory warnings (no Unreleased bullet naming this PR and three inherited import-cycle warnings).
  • zig fmt --check build.zig zig and git diff --check origin/main...HEAD pass.
  • Focused CPU tests on the prior head 7917bb05: 48/48 passed; red control without the sum-refresh fix failed the DFlash2 and DSpine assertions as expected. The 10 active CI checks on that prior head passed; two nightly checks were skipped. On this rebased head, release-paths (ubuntu-24.04) passed; nine checks remain queued across runs 45809803485 and 45809803505, and two nightly checks were skipped. No failures were reported when this description was refreshed; the queue delay also affects other recent TensorFold PR workflows.
  • No local test suite ran on the rebased head: LocalATC could not grant the 10 GiB disk reservation while only 1.4 GiB was free, so the queued job was cancelled before starting. No CUDA device or checkpoint was used.
  • Not run on this head: full host/golden suite, CUDA token identity, CUDA timing, and prompt/decode benchmarks. CUDA qualification is requested from Ash on GB10 after review has no open asks.

Receipt

  • Main against branch: no GPU timing cells; no CUDA performance comparison was run locally.
  • Boxes it reaches: Qwen3.5 CUDA DFlash2 and DSpine draft-head paths, including mixed narrow/wide contexts with affine-4 or EXL3 heads.
  • New switch: none; drafter selection and defaults are unchanged.
  • Environment: base 3c088d96917acf7e898450e03a1034000fee3122, head 07dab2140012cd79b2b4ed81c49aed228b01445f; Zig 0.17.0; Linux x86_64 CPU host. No CUDA device, checkpoint, or CUDA toolchain was used.
  • Paths and platforms: Qwen3.5 CUDA draft-frame code and CPU host tests. CUDA runtime qualification and Metal were not run; the Metal path is unchanged.
  • Exactness: host tests record width-specific projection calls, top-k widths, table-input packing, sum refresh after compaction, and row scatter. CUDA token-for-token comparison against "draft": false remains pending.
  • Main against this branch: not run on GPU. Ash confirmed GB10 is suitable for the requested CUDA qualification.
  • Decode speed before and after: not measured locally; request mixed versus all-narrow/all-wide head and served-decode timings on GB10.
  • Prompt speed before and after: n/a; prompt-processing code is unchanged.
  • Licence: n/a; no weights or drafter files are added.

Known integration point

The independent trial merge on ef4d6429 reported that #4682's ModelOpt frame cap also limits non-ModelOpt affine-4 frames. Its existing 128-stream affine-4 recording test failed (expected one 1,024-row launch, observed a maximum of 288); a scratch conditional cap for non-ModelOpt heads restored it. This is a #4682/merge-order interaction, not a change in this PR. After Ash establishes the order, apply the conditional-cap fix in #4682 or the combined branch as appropriate and rerun that regression. The trial merge passed 114/114 host tests and 20/20 native CUDA host build steps, but did not establish GB10 token identity or timing.

Checklist

@tacosta

tacosta commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor Author

@ashhart, this draft is anchored at main commit d4bf08ec4294fa244a322c62efb58e058d08a40e and is ready for review and testing. When you review the backlog, could you tell me which PRs/commits and merge order we should wait for before the final rebase? The PR lists every detected path overlap; I can resolve the known conflicts once that order is clear.

I also asked on #3460 whether GB10 is suitable for the CUDA identity and timing checks you offered to run. If you agree, could those checks use GB10? Otherwise, please name the CUDA target you prefer. The final post-rebase CPU smoke passed 47/47 tests; CUDA exactness and performance remain pending.

@tacosta

tacosta commented Nov 25, 2026

Copy link
Copy Markdown
Contributor Author

Merge-order note: a complete filename scan found 34 other open PRs sharing changed paths; the description lists every PR by path. These are path overlaps, not all confirmed conflicts. ATC's simulation is incomplete: it flags #2982 against the current worktree, and #2020, #2926, and #2960 against the old PR head. Local worktree conflict IDs are 3, 4, 8, and 13; IDs 9, 12, 14, and 15 were clean (ATC does not map those IDs to paths). Please establish the PR merge order and commits to wait for; we can resolve conflicts and rebase once that order is known.

@AIFlowML

Copy link
Copy Markdown
Contributor

I independently trial-merged 7917bb05d3 into ef4d6429 on M5 Max. The merge is clean. The three draft-frame, draft-tree and DSpine host targets passed 114/114, and zig build check-native-cuda-host compile-cuda-tests -Dtarget=aarch64-linux-gnu -Dfixed-cpu -j2 --summary all passed 20/20 steps.

For the order question, I compared all 34 listed PR heads before and after applying #4439 to this main. Thirty-one already conflict with main. Their conflict file sets are unchanged by #4439. The other three (#4665, #4682 and #4932) merge cleanly in either order and produce identical trees for each pair.

#4682 still has a behavior overlap. The pair's existing affine-4 recording test fails even though Git merges it cleanly. With 128 streams at block 8, the test expects one 1,024-row launch and sees a maximum of 288, because #4682 applies its ModelOpt frame cap to every head. In scratch, keeping the single-frame path for non-ModelOpt heads restored the test. The three checks above plus test-qwen35-draft-frames-host then passed all 20 steps with 55 fresh tests and cached successful targets. If #4682 lands first, the combined hold should preserve that distinction. These checks do not settle GB10 token identity or timing.

Igor Lessio - AIFLOW LABS

@tacosta

tacosta commented Nov 25, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for the independent trial merge and the detailed receipts. I confirmed the #4682 frame cap is applied without a head-format check, so it also limits non-ModelOpt affine4 frames; the reported 128-stream recording-test regression is a real behavioral interaction despite the clean Git merge. Once Ash establishes the merge order, we can make the conditional-cap fix in #4682 or the combined branch, as appropriate, and rerun that regression. #4439 remains unchanged for now. GB10 token-identity and timing qualification are still pending.

@ashhart

ashhart commented Nov 26, 2026

Copy link
Copy Markdown
Owner

Thanks, @tacosta. My static recheck of 07dab214 found no source correctness defect. Mixed batches avoid the incomplete graph key, compact and restore rows in stream order, refresh affine-4 sums after every DFlash/DSpine compaction, leave EXL3 sums unused, and remap only narrow token IDs. Homogeneous and unsupported heads retain the old paths. The changed files pass the repository's source cap; cuda_dspine_frame.zig is exactly 600 lines.

The verdict is A/B. The host tests are useful launch/order and fail-before checks, but they are not numerical CUDA identity results. On GB10, please qualify both DFlash2 and DSpine with affine-4 and EXL3: drafted versus "draft": false token-for-token for mixed interleavings and all-narrow/all-wide controls, blocks 8 and 16, packed-tail candidates, and a genuinely out-of-span wide token. Compare main and this head using the same checkpoints, prompts, seeds, stream counts, and request order. Measure isolated head time for mixed/all-narrow/all-wide batches and served decode tokens/s against the same controls; DSpine needs both head planes covered.

If this lands with #4682, the combined tree must keep #4682's frame cap specific to ModelOpt heads and rerun the 128-stream/block-8 affine-4 recording regression. That is an integration requirement, not a defect I found in standalone #4439.

You offered to rebase once the merge order was known. We rebase for contributors, so you do not need to do another rebase for this review.

This was a read-only static recheck; I did not run builds, tests, shaders, or devices.

  • Synthena

@tacosta

tacosta commented Nov 26, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for the detailed GB10 test matrix and the static recheck. We do not have access to a GB10 locally, so cannot run the pending CUDA token-identity and timing qualification ourselves. Since you confirmed GB10 is suitable and offered to run these checks, could you schedule the qualification when the review is ready for it and let us know the expected timing? We will keep the unrun CUDA receipts clearly marked as pending.

@ashhart
ashhart force-pushed the fix/3460-mixed-width-dflash-batch branch from 07dab21 to 29d1a91 Compare November 26, 2026 22:55

This branch has not been deployed

No deployments
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.

3 participants