fix: update block size and tile size heuristic for 16+ num of token#2492
fix: update block size and tile size heuristic for 16+ num of token#2492nv-yunzheq wants to merge 1 commit intoflashinfer-ai:mainfrom
Conversation
Summary of ChangesHello @nv-yunzheq, 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 resolves a performance regression observed in FP4 operations with higher token counts by refining the block size heuristic. The change ensures that the optimal block size is selected based on whether the operation is in 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. Changelog
Activity
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 PR adds conditional gating to FP4 optimization in AllReduce fusion, making it active only for FP4 patterns with oneshot mode or small token counts (≤16), replacing the previous unconditional approach and updating downstream block_size and cluster_size logic accordingly. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
Tip Issue Planner is now in beta. Read the docs and try it out! Share your feedback on Discord. 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 correctly fixes a performance regression for FP4 patterns with 32 or more tokens by adjusting the heuristic for applying a specific FP4 optimization. The change is well-contained and the logic is sound. I've included a suggestion to simplify the code for updating the block_size, which improves maintainability without altering the core logic.
| if (apply_fp4_optimization) { | ||
| block_size = threads_per_block; | ||
| } |
| if (!apply_fp4_optimization) { | ||
| block_size = threads_per_block; | ||
| } |
There was a problem hiding this comment.
|
@timlee0212 I saw you left a comment in the original PR that caused the regression. Do you want to take a look at this one? |
update block size and tile size heuristic for 16+ num of token issue #2407
The regression is caused by PR #2268
The fix is to adjust the heursitic choice based experiment, where when number of tokens is larger than 16, the original heuristic works better.
Result on B200:
🔍 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