Repository navigation
fix(dynamicemb): release slot pins after no-grad training forwards - #541
lidongdongbuaa wants to merge 5 commits into
Conversation
Signed-off-by: lidongdong.2024 <[email protected]>
[Medium impact] The change reaches DynamicEmb training forwards that run without gradients. Refresh stale slots in the no-grad release path before merging. Findings
SummaryReleases embedding slot pins after training forwards that build no gradient graph.
GPU tests were not run during this review. Diagram%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[Prefetch batch A and pin its slots] --> B[Prefetch batch B grows the key map]
B --> C[Keys and pin counts move to new slots]
C --> D[Batch A runs without gradients]
D --> E[Release uses old slot numbers]
E --> F[Wrong pin counts change]
Reviews (3) · Last reviewed commit: "Merge branch 'main' into bug-dynamicemb-..." · Reviewed by Greptile |
…d forward The backward and the no-grad forward both undo the ref-counter pins that prefetch took. Put the choice of counter owner (cache or storage, by the batch's storage_mode) in one function so the two paths cannot disagree. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
…tches for slot pins Run the slot-pin lifetime tests on every storage layout (HBM, cache, hybrid, host-only), with and without a frequency admission that rejects a key on its first sight (slot -1). Add a case with two batches in flight, one under no_grad and one with grad, in both orders: releasing the no-grad batch must leave the other batch's pins until its backward. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Review/pr 541
| release_slot_pins( | ||
| self._cache, | ||
| self._storage, | ||
| prefetch_state.storage_mode, | ||
| prefetch_state.slot_indices, | ||
| prefetch_state.unique_table_ids, |
There was a problem hiding this comment.
Growth releases the wrong pins
A queued HBM prefetch can grow the key map before an earlier batch runs under torch.no_grad(). Growth moves each key's pin count to its new slot, but this release still uses prefetch_state.slot_indices from the old map. For a NO_EVICTION table, value rows stay valid, so forward succeeds while the release decrements the wrong counters. This leaves pins stuck and can remove another batch's protection against erase.
Refresh the slots when key_map_generation changes, as backward already does.
|
closed as merged by #547 |
Description
Repeated training-mode forwards under
torch.no_grad()gather their output but retain embedding slot pins: there is no autograd graph to release the pins in backward. Release those pins on the current stream after the gather when the result does not require gradients. Grad-enabled forwards keep their pins until backward.Split from #538 following the review request. This PR is based directly on
main@4c75b48and has no dependency on the Docker or build changes in #538.unit_test.sh fwd_bwdsuite.torch.no_grad().Validation
bash -n corelib/dynamicemb/test/unit_test.sh, andgit diff --checkpassed.03865e2snapshot, and the runtimeforward()implementation matches that snapshot. On that earlier combined build/runtime snapshot, all eight lifecycle cases passed on GB300, alongside table/JIT tests (108 cases total, no failures/errors/skips).Run in a CUDA environment with DynamicEmb built and installed:
Checklist