Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

debug radixcache stack_overflow #1499

Merged
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions python/sglang/srt/mem_cache/radix_cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -288,18 +288,17 @@ def _total_size_helper(self, node: TreeNode):
for child in node.children.values():
x += self._total_size_helper(child)
return x

def _collect_leaves(self):
merrymercy marked this conversation as resolved.
Show resolved Hide resolved
ret_list = []
stack = [self.root_node]

def dfs_(cur_node):
while stack:
cur_node = stack.pop()
if len(cur_node.children) == 0:
ret_list.append(cur_node)
else:
stack.extend(cur_node.children.values())

for x in cur_node.children.values():
dfs_(x)

dfs_(self.root_node)
return ret_list


Expand Down
Loading