-
Notifications
You must be signed in to change notification settings - Fork 813
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: refactor recursive helper methods #3029
base: main
Are you sure you want to change the base?
Debug radixcache: refactor recursive helper methods #3029
Conversation
cb2dfd7
to
2cc5089
Compare
cc @xiezhq-hermann @hnyls2002 Can you help review this? |
Thank you for the contribution, can you make the change minimal and to the point? For example, put the style-wise change in a separated PR if needed. |
0eaec72
to
2cc5089
Compare
Convert `_match_prefix_helper`, `_insert_helper`, `_print_helper`, and `_total_size_helper` from recursive to iterative implementations using stacks or loop. This prevents potential stack overflow errors with deep trees while maintaining the same functionality. Also update the test cases to use tensor values instead of strings for better testing of the radix cache's core functionality.
2cc5089
to
d02f0d0
Compare
@xiezhq-hermann Sorry for the inconvenience caused to you due to the extensive code refactoring. To minimize the impact, I made minimal changes and pushed a new commit. I believe this will serve as a better starting point for the review. Additionally, we can enhance the elegance of the code in the following two aspects, which can be done in another PR:
|
Motivation
Currently radixcache is implemented by several recursive functions, which may cause PYTHON Stack overflow problem when tree hits a certain depth. You may reproduce this issue by following code.
Related Issue: #813
#1499 fixed one of recursive function but NOT ALL: .
Modifications
Replace recursion functions with loop or stack in radix_cache.py
Checklist