Skip to content

hip: 4096-row prompt chunks by default on the RDNA 3.5 iGPUs - #1651

Merged
ashhart merged 3 commits into
ashhart:mainfrom
gilby:strix/hip-gfx115x-prefill-step
Nov 2, 2026
Merged

ashhart merged 3 commits into
ashhart:mainfrom
gilby:strix/hip-gfx115x-prefill-step

Conversation

@gilby

@gilby gilby commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

What this changes

The RDNA 3.5 iGPUs (gfx1150 to gfx1153) default to a 4096-row prompt step instead of 1024 (Policy.forCaps, applied in the HIP server's policy resolution); other chips keep 1024, and --policy prefill_step=N and TF_POLICY still override. Fixes #1649.

The larger chunk's scratch takes about 4.6 GiB more device memory. When the step is the GPU's default (no prefill_step in --policy or TF_POLICY) and one rank serves, Flash Next counts the scratch of both chunks on its dry run once the weights are resident (Engine.fittedScratch) and takes 1024 if 4096 would admit fewer of the streams the server asks for (narrows). A step the user asks for is kept as before. The policy line notes that the default can fall back, and the startup line names the chunk taken and, after a fallback, why:

policy ...,prefill_step=4096,fill_rows=512; mtp drafts 3 under 0.3, 8 snapshots prefill_step 4096 is this GPU's default, 1024 when it admits fewer streams;
HIP gfx1151 device 0, rank 0 of 1: Flash Next, 76.58 GiB on the device, 8 streams of 131136 positions, 4.31 GiB each; prompts in 1024-row chunks (4096-row chunks would admit fewer of the streams asked for)

Receipt

  • Environment: TensorFold main d377fcc6 plus this change, zig build native-hip -Dhip-arch=gfx1151, Ubuntu archive HIP 7.1 (clang 21), AMD Ryzen AI MAX+ 395 with Radeon 8060S gfx1151 (128 GB unified memory). Checkpoint TensorFold/Qwen3.8-Flash-Next-MLX-4bit-MTP revision 2b170fa6, MTP 3 drafts, --prompt-cache-gib 0, base and candidate on the same machine.
  • Tokens equal at 1024 and 4096: main (1024), this change at its default (4096) and this change with --policy prefill_step=1024, --parallel 1 --context 131072, give the same token_sha256 set across tools/bench_openai.py, tools/bench_concurrent.py and both tools/bench_cache.py --require-cold prompts; bench_concurrent --alone --serial every cell alone 3/3 and 12/12 equal, serial equal, 0 failed, in all three.
  • Decode level, tools/bench_openai.py --tokens 256 --reps 3 --temperatures 0, median tok/s code / chat: main 50.08 / 44.05, this change at 4096 49.77 / 43.77, this change at 1024 49.93 / 43.93 (within 0.6%).
  • Prompt speed, tools/bench_cache.py --require-cold --tokens 16, first cold request on public 7,377- and 29,364-token arrays: main 44.9 / 96.5 s, this change at 4096 43.6 / 92.3 s (-3.1% / -4.4%; the earlier receipt's -7.6% / -7.0% measured the cold requests after the first).
  • Streams admitted (each line is the server's own report at startup; the 4.31 and 8.07 GiB are a stream at the window):
window, --parallel main (1024) this change, default this change, --policy prefill_step=4096
131,072, 8 8 streams, 1024-row chunks 8 streams, 1024-row chunks (fell back) refused: "33.89 GiB is left: serve --parallel 7"
131,072, 7 7 streams, 4096-row chunks
262,144, 4 4 streams, 1024-row chunks 4 streams, 4096-row chunks
131,072, 1 1 stream, 1024-row chunks 1 stream, 4096-row chunks

The most streams at each window, from the refusal of --parallel 64: 131,072 tokens main 8, default 8, forced 4096 7; 262,144 tokens 4 in all three.

  • Tests run: zig build test -Dhip=true --summary all 476/476 steps, 0 failed. Host tests: gfx1151 resolves to 4096, gfx1100 keeps 1024, --policy prefill_step=1024 and TF_POLICY still override; narrows takes the smaller chunk only when the larger one costs a stream asked for (a planted wrong expectation fails the step). Both need the new functions, so they fail to build before the change. python3 tools/zig/lean_check.py 424 on main and change. zig fmt --check and git diff --check clean.
  • Not run: the fallback under --tp (it is offered for one rank only; ranks keep the resolved step); other gfx115x parts with less memory; Metal and CUDA (HIP policy only). An oQ4e checkpoint with an 8-bit shared expert loads only with hip: load a shared expert wider than the routed experts beside the stack #1612, so it is not in this receipt.

Checklist

  • Every token still goes through the lane rounds. No serial path, and nothing that needs drafts off.
  • Drafted output equals "draft": false, a resumed prompt equals a fresh one, and concurrent equals solo.
  • No precision traded for speed. If the bits change, the description says which sums change and why.
  • A new or changed GPU kernel is registered with the kernel contract (docs/kernel-contract.md); each backend's SUMMARY line is in the receipt. (No kernel change.)
  • Prompt processing is no slower than the last release.
  • The description says which platforms I ran, Metal M1 to M5 and CUDA, and which I could not.
  • New tests fail before the change, pass after it, and skip cleanly without their dependency.
  • Comments and docstrings are one line. No measurements or history in the source.
  • No personal data, machine names, internal hosts or local paths. No AI attribution lines.

@ashhart

ashhart commented Nov 1, 2026

Copy link
Copy Markdown
Owner

Thanks @gilby, the receipts answer what we asked: the same tokens at 1024 and 4096, decode level, the fallback keeping 8 streams at 131K, and the startup line saying which chunk it took and why. Decoding streams don't wait longer either, since Flash Next takes fill_rows while another lane decodes. One gap: the fallback is offered only when --tp is 1. Under --tp 2 the step still defaults to 4096, with about 4.6 GiB more scratch on each rank and no fallback, so a launch can admit fewer streams than on main. Could the GPU default apply only at one rank (keep 1024 under --tp unless asked), or could the fallback be agreed across ranks the way prepare agrees on the fit? Either is fine. Then we'll land it.

@gilby

gilby commented Nov 2, 2026

Copy link
Copy Markdown
Contributor Author

Thanks @ashhart. Done the first way: the GPU's larger default applies only at one rank, and a group keeps the plain 1024-row step unless --policy or TF_POLICY asks for another (9938cd85b). Policy.forCaps now takes the rank count, and the host test checks gfx1151 at one rank (4096), gfx1151 in a group of two (1024) and gfx1100 (1024), beside the existing override cases. The branch is rebased on 9e8c368b.

On the rebased head, gfx1151: zig build test -Dhip=true --summary all 485/485 steps, 0 failed; python3 tools/zig/lean_check.py 424 as on main; zig fmt --check and git diff --check clean. One rank's behaviour is unchanged by this commit, so the receipts in the description stand for --tp 1; I have one GPU here, so --tp 2 is covered by the host test only.

@ashhart
ashhart force-pushed the strix/hip-gfx115x-prefill-step branch from 9938cd8 to b776578 Compare November 2, 2026 16:18
ashhart added a commit to gilby/TensorFold that referenced this pull request Nov 2, 2026
@ashhart
ashhart marked this pull request as ready for review November 2, 2026 16:26
@ashhart

ashhart commented Nov 2, 2026

Copy link
Copy Markdown
Owner

Thanks @gilby, your 12:21 change answers what we asked: the larger default applies only at one rank, and a group keeps the 1,024-row step unless --policy asks for another. It's gated and lands now. We marked the PR ready for review, since GitHub won't merge a draft.

gilby and others added 3 commits November 2, 2026 18:42
On the gfx115x iGPUs a 4096-row prompt step reads the weights a quarter
as often per prompt and measured faster cold prefill with unchanged
tokens and decode. Policy.forCaps gives those chips prefill_step 4096;
other chips keep 1024, and --policy and TF_POLICY still override.

The larger chunk's scratch takes about 4.6 GiB more device memory. When
the step is the GPU's default (not asked for) and one rank serves,
Flash Next measures the scratch of both chunks once the weights are
resident and takes the plain 1024-row chunk if the larger one would
admit fewer of the streams the server asks for. The startup line names
the chunk it took and, after a fallback, why.

Fixes ashhart#1649
The larger default chunk's scratch has a fallback only on one rank, so a
group now keeps the plain 1024-row step; --policy and TF_POLICY still
choose any step.
@ashhart
ashhart force-pushed the strix/hip-gfx115x-prefill-step branch from b776578 to a1d8168 Compare November 2, 2026 18:42
@ashhart
ashhart merged commit bd7b066 into ashhart:main Nov 2, 2026
10 of 11 checks passed
@ashhart

ashhart commented Nov 2, 2026

Copy link
Copy Markdown
Owner

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.

@ashhart

ashhart commented Nov 3, 2026

Copy link
Copy Markdown
Owner

ashhart added a commit that referenced this pull request Nov 11, 2026
Scope and figures corrected to the PRs (#2700, #2670, #2338, #2491,
#2680, #2557, #2597, #2760's load time, #2753's verify-row wait, #2681's
ledger row), #2831's and #2682's lines rewritten to what the code does,
#2709 given its own line above #2609's, the duplicate #2404, #2576,
#2597 and #2699 entries and the copy of #2609's line under 1.2.6
removed, entries spaced one blank line apart, and the released sections
restored to the v1.2.6 tag's text (#1651's 1.2.2 line and six blank
lines in 1.2.5 and older).
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.

HIP Flash Next on gfx1151: defaults for prompt step and MTP drafts

2 participants