Repository navigation
[FIX](DynamicEmb): evict LruLfu tables through the ranked evictor on every insert path - #508
Merged
Merged
Conversation
Contributor
[Medium impact] The PR appears safe to merge; no blocking issues were found. SummaryFixes full-bucket insertion into two-word
No actionable issues were found. Tests were not run during this review. Reviews (3) · Last reviewed commit: "Merge branch 'main' into bug-lru-lfu-loa..." · Reviewed by Greptile |
…ery insert path
Loading a checkpoint into a {TIMESTAMP, LFU} (LruLfu) table device-asserted
`num_scores_ == 1` in LinearBucket::reduce as soon as a bucket overflowed.
The AoT insert / insert_and_evict kernels pick the evictor by the call's
score policy, not by the table layout, so a 2-word table reaches the
single-score reduce() whenever the caller passes CONST or ASSIGN: load
placement (_load_key_values), backward refresh (preserve_existing),
rehash and ScoredHashTable.load.
- DefaultEvictor ranks a 2-word bucket with the default LruLfu comparator
(frequency asc, then timestamp asc) via reduce_ranked() instead of
reduce().
- _load_key_values places multi-word keys with the table's own LruLfu
policy and a zero frequency delta, so a full bucket evicts through the
LruLfu cubin (honoring a custom score_function); the score blocks are
then scattered as before.
- Tests: load overflow across batches (lowest frequency evicted, rows
intact, both column orders), single-batch overflow, custom
score_function on load, CONST/ASSIGN insert and insert_and_evict into a
full bucket, preserve_existing insert, storage insert overflow, batched
training overflow (hbm/host/caching), and single-score LRU/LFU load
overflow regression.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
shijieliu
force-pushed
the
bug-lru-lfu-load-eviction
branch
from
October 27, 2026 13:18
061f706 to
efd319c
Compare
3 tasks done
jiashuy
approved these changes
Oct 29, 2026
3 tasks done
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.
Fix the issue:
An LruLfu table (
score_strategy=(TIMESTAMP, LFU), two score words per key) device-asserts inLinearBucket::reduce(types.cuh:414,Assertion num_scores_ == 1 failed) whenever aCONSTorASSIGNinsert lands in a full bucket.The AoT
insert/insert_and_evictkernels choose the evictor from the score policy of the call, not from the table layout: only anLruLfucall reaches the LruLfu cubin and its ranked evictor. Every other policy runstable_insert_kernelwithDefaultEvictor, which calls the single-scorereduce(), and that asserts on a 2-word bucket. Callers that do this on an LruLfu table:_load_key_valuesplaces multi-word keys withScorePolicy.CONSTbefore scattering the score blocks, so a load asserts as soon as one bucket overflows;storage.insert(..., preserve_existing=True)(CONST), when a refreshed key is no longer in its full bucket;ASSIGN);ScoredHashTable.load(ASSIGN).Symptom: resuming training from a checkpoint of a full LruLfu table crashes with this assert, either during the load or in the first training steps.
Details
kernels.cuh:DefaultEvictorpicks the victim of a 2-word bucket withreduce_rankedand the default LruLfu comparator: frequency ascending, ties by timestamp ascending, the same order the cubin uses. Single-score tables keep the existingreduce()call. This covers every AoTCONST/ASSIGNpath listed above.key_value_table.py:_load_key_valuesplaces multi-word keys with the table's own LruLfu policy and a zero frequency delta instead ofCONST. A full bucket therefore evicts through the LruLfu cubin and honors a customscore_function;scatter_score_blocksthen overwrites both words as before.score_for_compareis the max value for every policy). Keys inside one batch are locked during the kernel and cannot evict each other.Tests
New cases in
test/unit_tests/table_operation/test_lru_lfu.py, on a single 128-slot bucket with exact oracles. For load cases the oracle checks the evicted set equals the lowest-frequency keys, and every surviving key's value row and[ts, freq]block equals its dump.score_function(evicts by the function's ranking)CONST/ASSIGNxinsert/insert_and_evictinto a full bucketpreserve_existingstorage insert into a full bucketWithout the fix, 10 of the 15 new cases hit the device assert. With the fix, on main
1ba40f2+ this commit (1 GPU, RTX PRO 6000):test/unit_tests/table_operation/test_lru_lfu.pytest/unit_tests/table_operation/test_table_operation.pytorchrun --nproc_per_node=1 -m pytest test/unit_tests/table_operation/test_table_dump_load.pytest/test_batched_dynamic_embedding_tables_v2.py