Skip to content

fix(flashnext): a HIP round's graph replays only over its pool slot's caches - #963

Merged
ashhart merged 1 commit into
ashhart:mainfrom
BlivionIaG:fix/fn-graph-replay
Oct 18, 2026
Merged

ashhart merged 1 commit into
ashhart:mainfrom
BlivionIaG:fix/fn-graph-replay

Conversation

@BlivionIaG

Copy link
Copy Markdown
Contributor

What this changes

A Flash Next HIP round graph names the buffers of the pool slot it was recorded for. keyOf checked only the caches' capacity, so caches made outside the pool (id 0) took slot 0's graph and replayed it over other buffers. tf-flashnext-hip-test made new caches for each --repeat run and freed them after, so a later run replayed run 1's graph over freed buffers.

  • cache.Pool keeps the buffers each slot was made with; Pool.holds(c) tells if c is that slot's own.
  • keyOf refuses caches the pool does not hold (CachesNotPooled).
  • tf-flashnext-hip-test takes slot 0 from the pool for each run, as a served stream does.

The served path already used pool slots, so served replies do not change. The fault is in our #818: its receipt ran with the system RCCL, where the freed buffers came back at the same addresses. With the RDNA RCCL build, run 2's n-gram conv input moved and its logits differed from graphs off.

Receipt

  • Environment: main 46a08c1 and this branch 54b7407; Zig 0.17.0, HIP 7.14; RCCL from ROCm 7.14 and the RDNA build; 4 × Radeon PRO V620 (gfx1030), 2 × Radeon PRO W7800 (gfx1100); Qwen3.8-Flash-Next-MLX-4bit-MTP and -3bit-MTP.

  • Exactness:

    tf-flashnext-hip-test generate --hash main this branch
    4 × V620, tp 4, 4-bit, graphs on, --repeat 3, RDNA RCCL 349d2996…, 52fe0f9b…, 349d2996… 349d2996… × 3 (twice)
    same, graphs off 349d2996… × 3 349d2996… × 3
    same, graphs on, system RCCL 349d2996… × 3 349d2996… × 3
    2 × W7800, tp 2, 3-bit, graphs on and off, --repeat 2 6fbb0a3f… × 2 6fbb0a3f… × 2

    tools/bench_concurrent.py --levels 1,4 --alone --serial --temperatures 0,1 --tokens 128 --reps 2 on 4 × V620 tp 4: 8 cells, every alone and serial run equal, 0 failed.

  • Decode speed, tools/bench_openai.py --tokens 256 --reps 3 --temperatures 0, 4 × V620 tp 4, runs alternated: main 99.92 and 99.49 tok/s (code), 80.44 and 80.08 (chat); this branch 99.80 and 99.54, 80.18 and 80.23.

  • Prompt speed: n/a, the change is in the decode round's graph key.

  • Tests run:

    • The new host test ("a round's graph is chosen for the pool's caches only") fails on main ("expected error.CachesNotPooled, found .capture") and passes here.
    • macOS zig build test -Dcpu=apple_m1: 204/204 steps, 2990/3000 tests (10 skipped); main 2989/2999. test-golden: 309/319 equal, 0 unexpected.
    • Linux zig build test passes. zig fmt --check is clean. lean_check.py 517, the same as main.
  • Not run, and why: Metal and CUDA (files untouched).

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. No sum changes.
  • No new or changed GPU kernel.
  • Prompt processing is no slower than the last release.
  • The description says which platforms I ran 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.

… caches

A graph keyed by a pool slot names the buffers that slot was made with, but keyOf only checked the caches' capacity:
caches made outside the pool (id 0 by default) took slot 0's graphs and replayed them over another allocation.
tf-flashnext-hip-test made fresh caches for each --repeat run and freed them after, so a later run replayed run 1's
graphs over run 1's freed buffers; whether it gave graphs-off's logits depended on the allocator handing the same
addresses back. At tp 4 on gfx1030 with the RDNA RCCL build, run 2's n-gram conv input (cin) moved and its logits
differed from graphs off.

cache.Pool keeps each slot's buffers as made, and keyOf refuses caches that do not hold them (CachesNotPooled).
The test tool takes slot 0 from the pool for every run, as a served stream does. A host test chooses a round over
caches made outside the pool: it got the slot's graph (capture) before, and is refused now.
@ThinkOffApp

Copy link
Copy Markdown
Contributor

Thank you @BlivionIaG. Checked on gfx1151 (Strix Halo, Radeon 8060S), Zig 0.17.0, host side only: the new test fails on main 46a08c1 with expected error.CachesNotPooled, found .capture and passes on 54b7407; Linux zig build test passes on the branch. We did not run the Flash Next GPU hash check on gfx1151 (checkpoint not on the box).

@ashhart
ashhart merged commit 2406aa0 into ashhart:main Oct 18, 2026
4 checks passed
@ashhart

ashhart commented Oct 18, 2026

Copy link
Copy Markdown
Owner

Thank you, @BlivionIaG, for the graph-cache identity reproducer and correction of the earlier repeat receipt.

We merged your fix for 1.1.0 in 2406aa0. Each pool slot retains the buffers, window and input bases its graph names. A same-capacity cache created outside that pool is refused with CachesNotPooled.

The regression checks that false match directly. Served streams continue to lease their own pool caches.

Host cache-identity/ownership checks passed; a final HIP device rerun is not recorded.

Posted by Ash's AI Assistant Synthena

BlivionIaG pushed a commit to BlivionIaG/TensorFold that referenced this pull request Oct 20, 2026
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.

3 participants