chore: Refactor benchmark imports to be lazy-loaded#2388
chore: Refactor benchmark imports to be lazy-loaded#2388yzh119 merged 1 commit intoflashinfer-ai:mainfrom
Conversation
Summary of ChangesHello @bkryu, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request addresses a critical issue in the Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
📝 WalkthroughWalkthroughThe change refactors import statements in the benchmark module, converting top-level imports of routine modules into lazy, in-function imports. This defers loading of heavy dependencies (gemm, moe, moe_comm, norm, quantization) until their specific routines are executed, maintaining the same routing logic and outcomes. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Code Review
This pull request effectively refactors the benchmark imports to be lazy-loaded, addressing the issue of unnecessary dependencies (like mpi4py) causing failures in non-MPI environments. By moving the routine-specific imports into the if/elif blocks within run_test and parse_args functions, the code now only loads modules when they are actually required. This significantly improves the robustness and flexibility of the benchmark harness, allowing users to run non-MPI benchmarks without encountering import errors. The changes are well-implemented and align perfectly with the stated objective.
|
#2386 was merged, please rebase the pr on top of latest main. |
|
The changes in this file are not tested on CI so I don't think rebase will bring any benefits. Let's bypass and merge directly. |
📌 Description
No changes to library code. Will not launch internal CI
#2354 added moe_comm microbenchmarks to the benchmark harness. However, the PR causes failures in non-MPI enabled environments because
flashinfer_benchmark.pyblindly imports routines for all modules.Current PR refactors
flashinfer_benchmark.pyto use lazy imports for routine modules instead of importing all modules at startup. This avoids loading unnecessary dependencies when running specific benchmarks. Users without MPI installed can now run all non-MPI benchmarks without import errors.🔍 Related Issues
🚀 Pull Request Checklist
Thank you for contributing to FlashInfer! Before we review your pull request, please make sure the following items are complete.
✅ Pre-commit Checks
pre-commitby runningpip install pre-commit(or used your preferred method).pre-commit install.pre-commit run --all-filesand fixed any reported issues.🧪 Tests
unittest, etc.).Reviewer Notes
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.