Repository navigation
Conversation
Checks on CPU, with pools of mixed row widths, that each pool's kernel tail bytes stay clear of the next pool and of the bank end. After an overlapped prefill, the staging must overwrite exactly the first n slots of each pool, _pool_stable_from must equal n, and only untouched slots stay registered, including a slot the staging only partly overwrites.
riony
marked this pull request as draft
November 10, 2026 03:38
riony
marked this pull request as ready for review
November 10, 2026 04:44
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of #671. The prefill staging geometry this covers came in #689, whose review noted that "the new pool tests are all CUDA-only" and that "all current geometry coverage is CUDA-only". This test runs that geometry on CPU, where those tests skip.
What it is
Test-only: adds
test_prefill_staging_unregisters_exactly_the_slots_it_overwritestotests/moe/test_offload.py(72 lines, extending the existing file). No runtime change.What it checks
OffloadMoeCacheon CPU with slot pools of mixed row widths, including a pool whose MMQ kernel tail reads past its last row._pool_stable_fromequals n, and only untouched slots stay registered, including a slot the staging only partly overwrites.Why CPU
All four slot-pool tests from #689 are
@pytest.mark.skipif(not torch.cuda.is_available())and build their caches ontorch.device("cuda"), so a host without CUDA runs none of them, and no CPU-reachable test covers the staging slot count or_pool_stable_from. The review of #689 suggested extracting the arithmetic into a pure function to allow CPU unit tests; this drives the integrated path instead, which also covers the registration bookkeeping and a straddled slot.Tested on
mainatfff1022a, plus this branchCommands, run from the repo root of each tree (base, then this branch), extensions built in-tree first with
python setup.py build_ext --inplace:The mutation runs use the CUDA-hidden command on this branch with one line of
python/freetoken/moe/offload_cache.pychanged.Results
maintests/moe/test_offload.py, CUDA hiddentests/moe/test_offload.py, CUDA visible (RTX 3090 Ti)Mutation check: each edit below was applied to this branch, and only the new test failed, at the assertion named:
tests/moe/test_offload.py:310assert (576 + 20) <= 576: a 20-byte MMQ tail runs into the next pool_pool_stable_fromrounded down:343assert 7 == 8: the floor says 7, but 8 slots were overwritten:345assert [7] == []: a partly overwritten slot stays registeredThe staging buffers sit at the start of every bank, and hit-D2D trusts every slot from
_pool_stable_fromonward. If the slot count or the floor rounds down, the cache keeps a slot whose bytes the staging already overwrote, and the next hit on that slot serves the wrong expert rows with no error anywhere. The test compares each slot's bytes before and after the prefill, so the expected boundary comes from the bytes rather than the cache's own arithmetic, and a slot the staging only partly overwrites still has to come out unregistered.AI assistance
AI assistance was used in drafting the test and this description. I ran and reviewed the change on the hardware above and can explain and defend every line of it without help.
This is my first contribution to FreeToken. I have also posted in the Developer Slack about a multi-GPU expert tier (related to #447) and would welcome a pointer on where that should integrate.