mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[GH-ISSUE #2134] Foresight swap: a slot copied before an adaptive exchange can hold another expert's bytes (FS_VERIFY: 19 BAD on clean v0.1.43) #855
Labels
No labels
needs-format
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Niko1221/Strata#855
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @radoslawsz on GitHub (Oct 12, 2026).
Original GitHub issue: https://github.com/Niko1221/Strata/issues/2134
Summary
When the Foresight swap space is on (
STRATA_FS_SLOTS > 0) and the adaptive cache swaps experts between VRAM and the page-locked RAM copy, a slot copy can read the wrong expert.note_miss/predictissue the copy from an expert's address in the RAM copy beforecommit_exchanges()/commit_copies()/commit_flip()run. The copy can land after the exchange has rewritten that RAM place with the outgoing expert's bytes. The slot is then ready for expert X but holds expert Y, andtake()serves it when X misses the cache. Nothing in the exchange path touches the Foresight slots.The default configuration is not affected, because Foresight is opt-in.
Reproduction (clean v0.1.43,
7695859a, no other patches)STRATA_FS_SLOTS=4 STRATA_FS_VERIFY=1; other FS switches at their defaults, so the router look-ahead is on.The patch costs no speed: the median per request is 71.8 tok/s in both runs, and the 0.8% difference over the whole run is run-to-run noise. We first saw it on our fork: 1 BAD in 611,201, then 0 BAD in 617,808 with the same fix.
Where (v0.1.43)
src/core/expert_source.cpp:3320FileExpertSource::commit_exchanges()src/core/expert_source.cpp:3349FileExpertSource::commit_copies()src/core/expert_source.cpp:3360FileExpertSource::commit_flip()src/core/expert_source.cpp:4876/4881ForesightSwap::note_miss()/predict()Fix
In all three commit functions, every exchange invalidates the Foresight slots of both experts it moves (
x.in,x.out). Undersmu_, the slot is freed and the next miss or prediction copies again. A copy still in flight finishes first, because it is on the same stream. The patch is 37 lines and applies cleanly to v0.1.43:patch
@Niko1221 commented on GitHub (Oct 13, 2026):
Thanks @radoslawsz, the analysis was right. The fix is in 0.1.44 (out now), built from your patch with one change: every exchange (commit_exchanges, commit_copies to commit_flip, and the rotation path) holds the experts it moves in the swap space. Their slot is dropped and no new copy of them is issued until the commit is done.
The difference from your patch: a dropped slot is not given out again at once. Your patch set the slot's expert to -1, and
request_lockedtakes an empty slot before it checksdepth. So a slot that a window planned before the exchange was still reading could get overwritten. A dropped slot now waits the samedepthfinished windows as any other slot.The report line gains "N dropped by exchanges". There is a GPU test as well (
file_expert_source_test --rotation-gpu): both commit paths, the depth rule, and the bytes after the exchange (verified 2 ok / 0 BAD on an RTX 3060). You are credited as co-author. If you can, please rerun your HumanEval FS_VERIFY run on 0.1.44. This stays open until then.@radoslawsz commented on GitHub (Oct 14, 2026):
Hi !
Rerun done on clean v0.1.44 (
ed4773eb, no local patches): RTX PRO 6000 with the expert cache limited to an RTX 4080S-sized one (4698 slots), IQ3_XXS,STRATA_FS_SLOTS=4,STRATA_FS_VERIFY=1, HumanEval 50 × 3 rounds:0 BAD in 3.03M checks. Same setup on clean v0.1.43 hit 19 BAD in round 1 (426k checks). The "dropped by exchanges" counter shows the race is real and now handled.
Looks fixed — thanks!
For reference, v0.1.44 was tested on three machines (Qwen3.8 Flash-Next IQ3_XXS). Decode speed on a long reasoning task (elevator puzzle, reasoning effort medium, ~30k generated tokens per run):
The desktop also has a second RTX PRO 6000 and an RTX 5090; the Foresight runs used one RTX PRO 6000 with the expert cache capped to 4698 slots (RTX 4080 Super size).
@Niko1221 commented on GitHub (Oct 19, 2026):
Thanks for the report. This is fixed in 0.2.0-beta (or an earlier release), and we're closing it as part of the tracker reset for 0.2.0-beta.
If it still happens on 0.2.0-beta, add the area prefix to the title ([Engine], [GUI], [TUI], [Benchmark], [Docs] or [Other]), put the Strata version and your hardware in the issue form fields, and comment
/reopen. A check runs and reopens it.