Repository navigation
Conversation
The prompt's n-gram gather copied each id's rows one at a time on the host. Rows now locate the shard by division when the shard sizes allow it and split the ids across up to eight threads into disjoint staging rows, same bytes. After every weight is on the device the checkpoint's pages are dropped from the mapping and the page cache, except the n-gram table spans a gather still reads. Fixes ashhart#1606
|
Thanks — the gather rewrite reads well, and the byte-for-byte tests against the old search are exactly what we want. Two things before this can leave draft: could you add a short description with before/after resident memory and gather (or prefill) time on a real checkpoint? And #1615 contains this whole diff plus the MADV_RANDOM advice — is 1615 meant to replace this one, or to stack on it? Either is fine, we just want to land one path. |
|
Thanks. #1615 is meant to stack on this one, not replace it: it contains this commit plus one more (the The receipt in the description has the real-checkpoint numbers (
I also pushed a |
What this changes
Two parts of the HIP Flash Next host path for the n-gram tables: the gather splits a chunk's ids across up to eight threads (shard located by division when the shard sizes are a remainder run, search otherwise), and after upload the checkpoint's weight pages are dropped from the mapping and page cache except the n-gram spans a gather still reads (
Checkpoint.releaseExcept). Same bytes. Fixes #1606. Happy to split the two parts into separate pull requests if preferred.Receipt
7c068895plus 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). CheckpointTensorFold/Qwen3.8-Flash-Next-MLX-4bit-MTPrevision2b170fa6.--parallel 1 --context 131072 --prompt-cache-gib 0, base and candidate on the same machine.tools/bench_concurrent.py --tokens 256 --reps 3 --temperatures 0 --levels 1,4 --alone --serialevery cellalone3/3 and 12/12 equal,serialequal, 0 failed;token_sha256ofbench_openai,bench_concurrentand bothbench_cacheprompts identical to the base build.tools/bench_openai.py --tokens 256 --reps 3 --temperatures 0, median tok/s code / chat: base 50.03 / 43.93, this change 49.90 / 43.86.tools/bench_cache.py --require-cold --tokens 16on public 7,377- and 29,364-token arrays, first cold requestttft_s: 7,377 tokens 48.44 -> 28.55 s, 29,364 tokens 108.97 -> 105.80 s. Later cold requests in the same process are unchanged (22.45 / 22.33 -> 22.52 / 22.34 s at 7,377): the first-request gain is the load no longer leaving about 29 GiB of weight pages in the page cache for the first prompt to reclaim (page cache after load 31.5 GiB -> 2.8 GiB, device usage unchanged). Host gather alone on synthetic 29.8 GiB shards: 4,096 ids 1.75x, 16,384 ids 2.2-2.5x, 65,536 ids 2.27x faster.zig build test -Dhip=true --summary all165/167 passed, 2 skipped, 0 failed (identical on the base);zig build hip-kernel-test15/15 steps; new tests: shard location over every id of uneven shards, gather equality against the previous row-at-a-time gather (single and multi-threaded, repeated and boundary ids, refusals), span coverage, andreleaseExceptkeeping its spans readable; mutating the shard location makes them fail.python3 tools/zig/lean_check.py425 problems on base and change (inherited);git diff --checkclean.releasegains a scratch allocator argument, updated at its one other caller in radio); other AMD chips; overlapping the next chunk's gather with the current chunk (needs a second staging region and graph/arena ordering changes; left out).Checklist
"draft": false, a resumed prompt equals a fresh one, and concurrent equals solo.SUMMARYline is in the receipt. (No kernel change.)