Repository navigation
hip flashnext: random-access advice on the n-gram table mappings - #1615
Conversation
|
Thanks — the random-access advice makes sense for scattered n-gram rows. This PR contains all of #1611 plus the madvise change; could you say whether it replaces 1611 or should be rebased on top of it once 1611 lands? Either works, but we'll only land one copy. Please also add a short description with before/after numbers (page faults, or gather / first-prefill time) so we can see what the advice buys. |
|
It stacks on #1611 rather than replacing it: after #1611 lands I'll rebase this so it holds only the advice commit. What the advice buys, on the same machine and checkpoint (
I also pushed a |
2eb785b to
b3af83a
Compare
|
#1611 has landed, so this is now one commit on current main (cfcbecb) instead of a stack: the old copy of #1611's commit is gone, and the remaining commit is the random-access advice on the n-gram table's mappings. The only conflict was in On the rebased head (b3af83a), one Strix Halo iGPU (gfx1151), ROCm 7.1 hipcc, zig 0.17.0:
The advice only changes how the kernel reads pages of the table, so no token can move, but the speed receipts in the description were taken on the earlier head and I have not re-run them on this one. Not run: any other GPU or family. |
|
Thanks @gilby. This is a clean, exact change with the receipts we asked for: |
b3af83a to
25afa68
Compare
A prompt's n-gram gather reads one 100-byte row per id at random rows, but the table shards were mapped without advice, so each faulted page pulled a readahead window: about 1.4 GB read from disk for a first short request. The table tensors' spans now get MADV_RANDOM after mapping. Fixes ashhart#1602
25afa68 to
0eda4ea
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. |
|
Thanks @gilby! This is in TensorFold 1.2.3, out now: https://github.com/ashhart/TensorFold/releases/tag/v1.2.3 |
What this changes
The HIP Flash Next engine advises
MADV_RANDOMover the n-gram table tensors' spans after mapping (File.adviseRandom,Checkpoint.adviseRandom), so a gather's random single-row reads fault only their pages instead of whole readahead windows. Fixes #1602. #1611 has landed, so this is one commit on main.The issue guessed at first-use graph capture; measuring showed otherwise: with graphs off the first request was equally slow, the engine replays 4,563 of 4,571 rounds, and the first request read 1,419,132 KiB from disk with 11,262 major faults while the identical repeat read 0. The slowdown follows new prompt content (new n-gram rows), not server start. The CUDA path already advises its tables this way.
Receipt
7c068895plus hip flashnext: parallel n-gram gather, release weight pages after upload #1611 and this change,tensorfold-native 1.1.8built withzig build native-hip -Dhip-arch=gfx1151, Ubuntu archive HIP 7.1 (clang 21), AMD Ryzen AI MAX+ 395 with Radeon 8060Sgfx1151(128 GB unified memory), page cache dropped before each server start. CheckpointTensorFold/Qwen3.8-Flash-Next-MLX-4bit-MTPrevision2b170fa6, MTP 3 drafts,--parallel 1 --context 131072 --prompt-cache-gib 0, fresh process per run, base and candidate on the same machine.token_sha256oftools/bench_openai.py,tools/bench_concurrent.pyand bothtools/bench_cache.pyprompts identical to the base build;bench_concurrent --alone --serialevery cellalone3/3 and 12/12 equal,serialequal, 0 failed.tools/bench_openai.py --tokens 256 --reps 3 --temperatures 0: first request after start (14-token prompt) 24.4 tok/s on the base, 35.8 / 35.9 / 34.9 tok/s with this change alone over three fresh processes, 35.5 tok/s stacked on hip flashnext: parallel n-gram gather, release weight pages after upload #1611; later requests unchanged (base 50.03 / 43.93, stacked 50.13 / 44.09 median code / chat).tools/bench_cache.py --require-coldon public 7,377- and 29,364-token arrays, first cold requestttft_s: base 48.44 / 108.97 s; this change alone 28.9 s at 7,377; stacked on hip flashnext: parallel n-gram gather, release weight pages after upload #1611 25.30 / 102.22 s.zig build test -Dhip=true --summary all466/466 steps, 0 failed, on the stacked tree; a new host test checks thatadviseRandommarks the tensor's pages random in/proc/self/smaps(fails with the advice disabled: 25 passed, 1 failed).python3 tools/zig/lean_check.py425 on base and change.git diff --checkclean.hip-kernel-testand the kernel contract (no kernel change). The residual cold cost is random-read latency (about 4 s for 5,888 rows on this disk); parallel reads could cut it further and are left out. Metal and CUDA (Linux HIP path only; the advice is a no-op elsewhere and on heap-copied files).Checklist
"draft": false, a resumed prompt equals a fresh one, and concurrent equals solo.SUMMARYline is in the receipt. (No kernel change.)