Skip to content

fix(dsv41): plan the 32-row prefill program so the second streams buffer is sized for it - #3388

Merged
ashhart merged 4 commits into
ashhart:mainfrom
sx4im:fix-3366-dsv41-prefill-buffer-plan
Nov 17, 2026
Merged

ashhart merged 4 commits into
ashhart:mainfrom
sx4im:fix-3366-dsv41-prefill-buffer-plan

Conversation

@sx4im

@sx4im sx4im commented Nov 14, 2026

Copy link
Copy Markdown
Contributor

A prefill segment of 18 to 32 rows replies with repeated begin-of-sentence tokens.

The out-of-place mHC boundary program writes the second streams buffer (w.x1), but the plan only sized that role for 17 rows, so rows 17 and up wrote past the buffer and NaN got into the SWA ring. The same band hits long prompts whose last segment is 18 to 32 rows, resumed turns with an 18 to 32 row new part, and TF_DSV41_PREFILL=replay.

Changed planPrograms to also plan a program at block_prefill.split_rows, skipping counts above the largest segment and the repeat when rows is split_rows. Added 18 and 32 to the full-mode row sizes in the index scratch test; it fails on main (w.x1 needs 737,280 bytes at 18 rows, plan gives 696,320) and passes with the fix.

The host test is zig build test-dsv41-forward. No Zig toolchain or dsv41 hardware here, so the end-to-end check is CI and the pair numbers the reporter kindly offered to run against this head.

Fixes #3366

@ashhart

ashhart commented Nov 16, 2026

Copy link
Copy Markdown
Owner

@sx4im, thank you, and thanks @BadAd84 for the GB10 receipts. The fix is right: it plans one more prefill program and sizes the buffers for it, with no kernel change. Replies outside the 18 to 32 row band stay identical to main's, and inside the band the repeated begin-of-sentence replies from #3366 become ordinary ones, which is the correction the issue asks for.

One thing before it lands: the new comment in forward_prefill.zig runs over five lines, and our lean check (python3 tools/zig/lean_check.py) takes one-line comments only. CI was waiting for maintainer approval on this fork; we have approved it. After that we will run the check from #3366 on two GB10s: one greedy request at every prompt length from 10 to 96 tokens on main and on this head.

  • Synthena (Ash's Agent)

@ashhart

ashhart commented Nov 16, 2026

Copy link
Copy Markdown
Owner

Thanks for folding the note down to one line; that clears the last thing we asked for. The plan itself is right: it sizes the second streams buffer across the whole split range without changing any serving program, so replies outside the affected lengths stay exactly as they were, and the repeated begin-of-sentence band from #3366 becomes ordinary text.

The one step left is ours: a token comparison on two GB10s. We will send one greedy request at every prompt length across the sweep on main and on this head and compare the ids directly. Outside the affected lengths the two must be identical at every point; inside the band, this head must match a build that plans the larger buffer outright, in both prefill modes, including a long prompt whose last segment falls in the band and a resumed turn whose new part does. If it holds, this lands and closes #3366 with it.

  • Synthena

@ashhart

ashhart commented Nov 17, 2026

Copy link
Copy Markdown
Owner

Thanks @sx4im. This is the fix we will land for #3366.

We added one commit on top of your head: a host test that sweeps prefill segments of 17 to 33 rows, at starts 0, 2,048 and 65,536, in full mode and in replay's encoder. It is @laudney's sweep from #3529, widened to both edges and to replay, with co-author credit. On main it fails at 18, 24 and 32 rows (w.x1 needs 737,280, 983,040 and 1,310,720 bytes against 696,320 planned), and with your plan it passes. test-dsv41-forward, test-dsv41-cuda-host and test-dsv41-draft pass, and the lean check is clean.

We also checked that the fix changes nothing else. On current main the only planned size that moves is w.x1, from 17 rows to 32. Nothing changes at a 32-row segment limit, which already planned the 32-row program.

Nothing is needed from you. @BadAd84's GB10 pair receipts on #3366 cover the device side, and our commit adds only the test, so this lands once CI is green on it.

  • Synthena

sx4im and others added 4 commits November 17, 2026 07:08
…fer is sized for it

Prefill segments of 18 to 32 rows run the out-of-place mHC boundary
program, which writes the second streams buffer (w.x1), but the plan
only sized that role for 17 rows, so rows 17 and up wrote past the
buffer and the decode came back with repeated begin-of-sentence tokens.

Plan a program at block_prefill.split_rows too, skipping counts above
the largest segment and the repeat when rows is split_rows. Add 18 and
32 to the full-mode row sizes in the index scratch test, which fails on
main and passes with the fix.

Fixes ashhart#3366
The lean check flags consecutive // lines as multi-line comments; the
four-line note added three new problems. One line keeps the why without
tripping the gate.
… replay (ashhart#3366)

Every segment from 17 to 33 rows, at starts 0, 2,048 and 65,536, in full mode and in replay's encoder, must find
the second streams buffer (w.x1) planned for its rows. On main 25de9d7 it fails at 18, 24 and 32 rows
(w.x1 needs 737,280, 983,040 and 1,310,720 bytes against 696,320 planned) and passes with the 32-row program
planned; 17 and 33 pass either way. The sweep is @laudney's test from ashhart#3529, widened to both edges and to replay.

Co-authored-by: laudney <[email protected]>
@ashhart
ashhart force-pushed the fix-3366-dsv41-prefill-buffer-plan branch from 9bc2274 to 58ac71e Compare November 17, 2026 07:09
@ashhart
ashhart merged commit 09c5fd5 into ashhart:main Nov 17, 2026
@ashhart

ashhart commented Nov 17, 2026

Copy link
Copy Markdown
Owner

Thank you @sx4im. This is merged into main with your commits under your own name, so you're listed as a TensorFold contributor. It ships in the next release, credited to you in the changelog and the release notes.

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.

dsv41: a prompt whose prefill segment is 18 to 32 rows long replies with repeated begin-of-sentence tokens (second streams buffer planned for 17 rows)

2 participants