Skip to content

fix(dynamicemb): clear score block in insert() Reclaim branch - #467

Merged
shijieliu merged 1 commit into
NVIDIA:mainfrom
ShaobinChen-AH:fix/dynamicemb-reclaim-stale-frequency
Sep 1, 2026
Merged

shijieliu merged 1 commit into
NVIDIA:mainfrom
ShaobinChen-AH:fix/dynamicemb-reclaim-stale-frequency

Conversation

@ShaobinChen-AH

Copy link
Copy Markdown
Contributor

Description

Checklist

  • I am familiar with the Contributing Guidelines.
  • New or existing tests cover these changes.
  • The documentation is up to date with these changes.

Summary

Fixes a phantom-frequency bug in DynamicEmb's LruLfu score policy: a new key inserted into a slot reclaimed by erase() inherited the erased key's residual frequency, corrupting LFU eviction order.

Root Cause

table_erase_kernel resets only score word 0 (the timestamp), leaving word 1 (frequency) stale. The insert() Evict branch already clears the full AoS score block when displacing a live key, but the Reclaim branch (slot vacated by erase(), keyed as ReclaimKey) was overlooked. ScorePolicy<LruLfu>::update() accumulates score += table_score[1], so the incoming key received a phantom frequency boost (stale frequency + its own delta), corrupting LFU eviction ranking.

Fix

In insert() (src/table_operation/kernels.cuh), the Reclaim branch now clears the full multi-word score block before the caller runs Policy::update(), mirroring the Evict branch:

if (evict_key == Bucket::reclaimed_key()) {
  atomicAdd(&bucket_sizes[bucket_id], 1);
  ScoreType *sblk = bucket.scores(iter);
  for (int64_t s = 0; s < bucket.num_scores(); ++s)
    sblk[s] = ScoreType();
  result = InsertResult::Reclaim;
}

@greptile-apps

greptile-apps Bot commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

The PR fixes stale LRU/LFU frequency state when inserting into a slot previously vacated by erase().

  • Clears every word in the reclaimed slot’s score block before applying the incoming key’s score update.
  • Adds a CUDA-backed regression test verifying that a reclaimed key starts with its own frequency rather than inheriting the erased key’s frequency.

Confidence Score: 5/5

The PR appears safe to merge, with the reclaimed-slot score reset matching existing score-layout and insertion semantics.

The new clearing loop operates on the bucket’s contiguous score block before policy update and key publication, and the regression test covers the reported stale-frequency behavior.

Important Files Changed

Filename Overview
corelib/dynamicemb/src/table_operation/kernels.cuh Clears the complete score block on the Reclaim path, matching the existing Evict-path initialization.
corelib/dynamicemb/test/unit_tests/table_operation/test_lru_lfu.py Adds focused coverage for stale LRU/LFU frequency metadata after erase and reclamation.

Reviews (1): Last reviewed commit: "fix(dynamicemb): clear score block in in..." | Re-trigger Greptile

@jiashuy

jiashuy commented Aug 31, 2026

Copy link
Copy Markdown
Collaborator

/build

@JacoCheung

JacoCheung commented Aug 31, 2026 •

Copy link
Copy Markdown
Collaborator

❌ Pipeline #65407542 -- failed

Job Status Log
pre_check ❌ failed view
train_build_x86 ✅ success view
train_build_arm64 ✅ success view
prepare-jet-b200-smoke ✅ success view
prepare-jet-b200-inference ✅ success view
prepare-jet-cw-dfw-e2e-benchmark ✅ success view
build_whl ✅ success view
dynamicemb_test_fwd_bwd_8gpus ✅ success view
dynamicemb_test_load_dump_8gpus ✅ success view
unit_test_1gpu_a100 ✅ success view
unit_test_1gpu_h100 ❌ failed view
unit_test_4gpu ✅ success view
unit_test_tp_4gpu ❌ failed view
L20_unit_test_1gpu ✅ success view
inference_unit_test_1gpu ✅ success view
inference_test_1gpu ✅ success view

Result: 13/16 jobs passed

View full pipeline

@shijieliu
shijieliu merged commit 2f94964 into NVIDIA:main Sep 1, 2026
1 check passed
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.

4 participants