[BUGFIX] fix radix cache memory consumption to avoid OOM#17191
Merged
[BUGFIX] fix radix cache memory consumption to avoid OOM#17191
Conversation
Contributor
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
Collaborator
Author
|
/tag-run-ci-label |
5 tasks
ispobock
reviewed
Jan 16, 2026
| @@ -654,10 +654,10 @@ def _split_node(self, key: RadixKey, child: TreeNode, split_len: int): | |||
| new_node.parent = child.parent | |||
| new_node.lock_ref = child.lock_ref | |||
| new_node.key = child.key[:split_len] | |||
| new_node.value = child.value[:split_len] | |||
| new_node.value = child.value[:split_len].clone() | |||
Collaborator
There was a problem hiding this comment.
We need to fix this for all radix cache variants.
Contributor
|
Can I test it? |
Collaborator
Author
you can run unit test and print allocated memory. Bad case can be reproduced easily |
hanming-lu
approved these changes
Jan 16, 2026
Collaborator
|
/tag-run-ci-label |
Contributor
Contributor
5 tasks
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.
Motivation
When radix tree does splitting, new_node and child both hold the view for inserted value, so when child is evicted,
child.valuewill not return to torch memory pool until all nodes along path hold the view of value are evicted. It may cause dynamic CUDA OOM when tree shares long prefixThis bug may also happen in other radix cache types.
Modifications
use clone to release original value when do slice, it may cause overhead but I think it is small and can be hidden by overlap schedule
Accuracy Tests
see ut, before this pr,
torch_allocated_memory / tree total_sizeis more than 400, which is abnormal. After this pr, it is less than 10 (it should be value dtype theoratically)Benchmarking and Profiling
Checklist
Review Process
/tag-run-ci-label,/rerun-failed-ci,/tag-and-rerun-ci