Repository navigation
hip flashnext: a shared round's streams draft in one head pass a step - #2696
Conversation
|
Thanks @gilby. Drafting the streams together is a clear win at 2 and 4 streams. Some asks:
|
|
Thanks @gilby. We've done the review items that don't need a GPU on your branch, keeping your two commits. The branch is rebased onto today's main and our commits sit on top:
Item 2, from reading the code. With
Without We have no AMD card, so two items are still yours on gfx1151:
|
|
Thanks @ashhart, and thanks for working through the items that need no GPU. One thing first: I don't see your rebased commits on the PR. The PR branch was still at
Checks on Environment: Zig 0.17.0, |
|
@gilby, sorry, that's on us: our note described commits we hadn't pushed. Yours on And thank you for the rest. The GPU test (two streams batched against serial, comparing drafts, head caches and
|
|
CI is green on |
|
Thanks @gilby. CI is green on
It's ready, and we'll put it on our landing queue next. Thank you for the careful work on a card we don't have.
|
c74222f to
cfd1be1
Compare
|
@gilby main moved under this (
|
|
GPU check on the rebased head Kernel tests. The steps that exist on this head for it are Served sanity check after the rebase (one fresh server per build, page cache dropped before each,
Per-request token hashes of this head equal main's in all 42 requests (3 repetitions of 1, 2 and 4 streams at T=1.0 and T=0), 0 unequal, 0 failed. In every cell of both arms concurrent equals alone (3, 6 and 12 of 3, 6 and 12 per temperature) and alone equals Binary sha256: main |
|
Thanks @gilby. Your gfx1151 rerun at
|
… forward takes segments
…d a batched draft
…against one at a time
… arena, and the GPU check's variables are named for the family
cfd1be1 to
151ba7b
Compare
|
Thank you @gilby. 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. |
What this changes
On HIP, Flash Next's MTP head drafted a shared round's streams one at a time: for each stream a host sync, its own absorb forward over its kept rows, and for each draft a one-row head forward and a draw with its own device-to-host copy and sync (
draftFnwithdraft_streams = false). A kernel trace at 4 distinct streams on gfx1151 put that serial draft step at about 58 ms of a ~200 ms round. The head now drafts a round's streams together, as Flash Next does on CUDA and Metal: one sync, one absorb forward over every stream's kept rows as segments, then per depth step one head forward and one draw over the streams still chaining (each stream keeps its own confidence stop), anddraft_streamsis on whenever drafting.The first commit is a pure move: the draft step goes from
lanes.zigtodraft_batch.zig, andhead.runtakes a segment list (per-segment positions and pooled-index bookkeeping), with no behaviour change.A call with one stream keeps the serial path exactly as before: its draws take the caller's ops (
windowoff, as on main), so one-stream rounds run main's launches. Only the batched draws setwindow.Drafts are proposals only: the verify and its logits are untouched, so replies cannot change. With
windowon, an MLX affine product keeps the stream tile at any row count, so for an MLX-quantized head with the stream tile on, batched drafts equal serial ones (the GPU test below checks this on the served checkpoint). Row count can still pick the kernel for a bf16 projection, which goes to rocBLAS, and under a policy with the stream tile off (the row tile at one row, the lanes tile above it); there a stream's drafts can differ from the serial path's. The batched path keeps each stream's chained residual row in the arena and does not write the lane's stream rows.Issue: n/a; it comes from the same trace (refs HIP Flash Next: about 850 small kernels per verify round cost a fifth of decode #1603).
Stacked on: main.
atc overlap --jsonagainst main (000b534a2): incomplete (pullFilesLimit,timeLimit); the file shared with most open PRs isCHANGELOG.md. hip flashnext: the MTP head absorbs a prompt chunk on the prompt tiles #1878 also changeshead.run's signature; whichever lands second needs a small update.Checks on this head
ecbdf41c8: the two reviewed commits, a merge of main000b534a2(conflict inCHANGELOG.md; hip flashnext: size the scratch arena by the dry run's peak, with the MTP head and a verify round's logits #2670's dry run now callshead.runwith a one-segment list), the serial draws back on the caller's ops (e07cc2594), the GPU test (4c4ad5644), the changelog line (5df700f74), and the chain rows in the arena (ecbdf41c8). The receipt ran on this head.python3 tools/zig/lean_check.py: 345 problems on the base and 345 on this head, 0 new findings.python3 tools/pr_check.py --base origin/main --pr 2696: 0 errors, 0 warnings.zig build test -Dhip=true --summary all: 889 of 891 steps succeeded, 13,642 of 13,756 tests passed, 113 skipped, 1 failed; the failure isdashboard_test"dashboard page polls the public stats snapshot without private details", which fails the same way on main000b534a2.zig build hip-kernel-test(draft_batch_test.zig, "two streams draft in one head pass a step as they do one stream at a time"): it loads the checkpoint named byTF_FLASHNEXT_DIR, takes two streams through the batched draft and the same two through the serial one, and compares each stream's held drafts, each head cache's bytes andpooled. On gfx1151 with the served checkpoint it ran and passed (1 of 1, not skipped), beside the 159 passed and 6 skipped kernel tests main has. It skips without the setting. Withpooledupdated for the first segment only inhead.zig, it goes red (expected 1, found 2).--tp 2(one GPU here), other HIP chips (no card), other Flash Next checkpoints.Receipt
000b534a2) against branch: one Strix Halo iGPU, four fresh servers with the page cache dropped before each, in the order main, this, this, main; both arms of each side are shown.bench_concurrent --levels 1,2,4 --reps 3 --prompts tools/bench_prompts.json --alone --serial --temperatures 1.0,0), aggregate tok/s, steady state in brackets. Greedy: 1 stream 51.6 / 51.6 on main vs 51.6 / 51.5 here; 2 streams 67.5 / 66.6 (68.8 / 68.7) vs 68.9 / 68.9 (71.2 / 71.3), +2.8%; 4 streams 67.3 / 67.1 (73.2 / 73.3) vs 71.6 / 71.7 (79.8 / 79.2), +6.6%. Sampled: 1 stream 45.2 / 45.3 vs 45.2 / 45.2; 2 streams 59.5 / 59.6 (62.8 / 62.6) vs 61.5 / 62.3 (65.1 / 65.1), +3.9%; 4 streams 64.5 / 64.4 (69.3 / 69.8) vs 69.0 / 69.1 (75.2 / 75.6), +7.1%.000b534a2plus this change, Zig 0.17.0,zig build native-hip -Dhip=true -Dhip-arch=gfx1151 -Doptimize=ReleaseFastwith the system hipcc (HIP 7.1, clang 21), one Strix Halo iGPU (gfx1151), Linux 7.0,unigilby/Qwen3.8-Flash-Next-oQ4e-HIP(revision5a0fb414),--context 131072 --parallel 4 --prompt-cache-gib 0.token_sha256equals main's in each arm (42 of 42 warm, 8 of 8 cold);bench_concurrent --alone --serialequal in every cell of every arm (alone 3/3, 6/6 and 12/12 at 1, 2 and 4 streams;"draft": false4/4), 0 unequal, 0 failed. Tokens a round are main's in every cell (3.16 / 3.48 / 3.11 greedy, 2.59 / 3.08 / 3.00 sampled).bench_openai --tokens 256 --reps 3, one stream): code 46.30 / 46.31 vs 46.28 / 46.26 tok/s, chat 40.12 / 40.14 vs 40.10 / 40.10.bench_cache --require-cold) 12.02 / 12.04 s vs 12.06 / 12.31 s, repeat 9.59 / 9.55 vs 9.57 / 9.55 s,token_sha25c0728f9043in every arm. One arm's first request read 0.27 s higher; the repeats are level.Checklist
"draft": false, a resumed prompt equals a fresh one, and concurrent equals solo. Drafted and concurrent are checked above; resumed prompts not re-run.