fix(dynamicemb): retain CUB scratch tensors through selection - #489
Merged
Merged
Conversation
Signed-off-by: lidongdong.2024 <lidongdong.2024@bytedance.com>
Contributor
|
shijieliu
approved these changes
Sep 21, 2026
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.
The CUB selection helpers take a raw pointer from a temporary
at::empty(...)tensor. The temporary is destroyed at the end of the assignment statement, before the followingDeviceSelect::Flaggedcall uses the pointer.Keep the owning tensor in scope through the CUB call in
select_async,select_index_async, andflagged_compact_impl. Allocation and launch use the existing current-stream path; no synchronization or API change is introduced.Validation on upstream commit
1ed1ab716cdbae8d103b1007d8beb40c86c4a18a, with the identicalindex_calculation.hpresent in the current base (97062d9):test_unique_op.py -k flagged_compacttests under Compute Sanitizer reported an invalid global write in CUBScanTileState::InitializeStatus(18 reported errors).test_unique_op.pypass.PYTORCH_NO_CUDA_MEMORY_CACHING=1 CUDA_LAUNCH_BLOCKING=1 PYTEST_DISABLE_PLUGIN_AUTOLOAD=1.Reproduce the sanitizer check:
This fixes the independently reproduced scratch-storage lifetime defect; it is not a claim that every illegal-memory-access failure in an embedding workload has this cause. The entire current-main library and distributed training suite were not rebuilt or rerun.