Skip to content

Commit

Permalink
debug_radixcache_stack_overflow
Browse files Browse the repository at this point in the history
  • Loading branch information
unknown committed Sep 24, 2024
1 parent fec2d12 commit e7bdeb5
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 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,18 @@ 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):
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

0 comments on commit e7bdeb5

Please sign in to comment.