Skip to content

Commit b33b53f

Browse files
adithyakvhclaude
andcommitted
fix(xtoken): return cached tuple in get_topk_projection; align HSDP test
get_topk_projection's cache-miss path returned a freshly-built (indices, likelihoods) tuple instead of the one stored in _TOPK_PROJECTION_CACHE, so the first (miss) call and subsequent (hit) calls handed back different tuple objects. This broke test_repeat_call_hits_cache's identity assertion (a is b). Store and return the same tuple. Also update test_dtensor_hsdp_dispatches_distinct_batches: Policy.train now threads check_dim_skip_keys through common_kwargs (added in this PR for cross-tokenizer skip-keys plumbing), so the expected run_all_workers_sharded_data call must include 'check_dim_skip_keys': None. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Signed-off-by: Adithya Hanasoge <adithyakvh@gmail.com>
1 parent 96378e4 commit b33b53f

2 files changed

Lines changed: 4 additions & 2 deletions

File tree

nemo_rl/algorithms/x_token/loss_utils.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -425,8 +425,9 @@ def get_topk_projection(
425425
)
426426
indices = data["indices"].long().to(device)
427427
likelihoods = data["likelihoods"].float().to(device)
428-
_TOPK_PROJECTION_CACHE[key] = (indices, likelihoods)
429-
return indices, likelihoods
428+
result = (indices, likelihoods)
429+
_TOPK_PROJECTION_CACHE[key] = result
430+
return result
430431

431432

432433
# Process-local cache. Keyed by every input that affects the partition:

tests/unit/models/policy/test_policy_validation.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,7 @@ def test_dtensor_hsdp_dispatches_distinct_batches(
327327
"eval_mode": False,
328328
"gbs": 32,
329329
"mbs": 4,
330+
"check_dim_skip_keys": None,
330331
},
331332
)
332333

0 commit comments

Comments
 (0)