-
Notifications
You must be signed in to change notification settings - Fork 169
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
⚡️ Speed up function collect_func_params
by 10%
#1128
⚡️ Speed up function collect_func_params
by 10%
#1128
Conversation
Here's the optimized version of your code. ### Changes and Optimizations. 2. **Early Merging**: We use dictionary operations more efficiently by merging `args` and `kwargs` earlier.
@grzegorz-roboflow I would not touch that, since this code is not on the critical execution path and changes may break usage - but leaving up to your judgement |
I might be wrong but I suspect that this code is being run with every inference UsageCollection through a call at
|
I am going to review this since the change is quite substantial refactor, had other priorities and this is on my TODO list |
Hi @misrasaurabh1 , I added a few tests in #1139, applied your branch locally, below tests are failing:
Lets not change behavior of this util |
…_params-m7e2t2pc' into codeflash/optimize-collect_func_params-m7e2t2pc
collect_func_params
by 392%collect_func_params
by 10%
Thank you for your new test cases. I used those + the test cases attached here + created 25 more. The latest version is 10% faster than the original and is more easily verifiable. |
Thanks @misrasaurabh1 !! I guess the initial idea was to remove call to |
Merged changes from main to this branch |
Saurabh's comment - Does make it less readable, but it looks like a really important function to speed up, since it will speed up every inference call, by reducing the overhead of usage collection. I would also recommend you to double check the optimization here.
📄 392% (3.92x) speedup for
collect_func_params
ininference/usage_tracking/utils.py
⏱️ Runtime :
525 microseconds
→107 microseconds
(best of234
runs)📝 Explanation and details
Here's the optimized version of your code.
Changes and Optimizations.
args
andkwargs
earlier.✅ Correctness verification report:
🌀 Generated Regression Tests Details