- 
                Notifications
    You must be signed in to change notification settings 
- Fork 291
[Bugfix] Fix missing reg alloc in custom warp specialization #1084
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
Conversation
| 👋 Hi! Thank you for contributing to the TileLang project. Please remember to run  We appreciate you taking this step! Our team will review your contribution, and we look forward to your awesome work! 🚀 | 
| WalkthroughModification to warp group register allocation annotation logic that restricts set_max_nreg handling to only the no_set_max_nreg path, tightens the injection condition to require exactly zero register adjustments and no SIMT copy detection, and replaces computed register hint constants with fixed values. Changes
 Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes The change modifies register allocation logic with stricter conditions and fixed constants, requiring review context on SIMT copy detection semantics, register adjustment implications, and verification that the hardcoded values (240, 24) are appropriate replacements for dynamic computation. Possibly related PRs
 Poem
 Pre-merge checks and finishing touches❌ Failed checks (1 warning)
 ✅ Passed checks (2 passed)
 ✨ Finishing touches
 🧪 Generate unit tests (beta)
 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
- src/transform/annotate_warp_group_reg_alloc.cc(2 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
src/transform/annotate_warp_group_reg_alloc.cc (1)
tilelang/language/builtin.py (1)
no_set_max_nreg(174-177)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: Quick Lint
🔇 Additional comments (1)
src/transform/annotate_warp_group_reg_alloc.cc (1)
135-145: Fix the misleading comment; the behavioral change appears intentional.The comment at line 135 is indeed misleading. It states "Only inject if we have valid register hints" but the condition on line 138 actually injects only when both
dec_regandinc_regare exactly zero—meaning no explicitset_max_nreg()calls were found in the code.Based on the code structure:
nreg_is initialized to{0, 0}(lines 56-57)- The
SetMaxNRegCollectorpopulatesnreg_from explicitset_max_nreg()calls in user code- When both values remain zero, it means the user provided no hints, so hardcoded defaults (240, 24) are injected
- This behavior appears intentional: only inject defaults when no user-provided hints exist
Apply this fix to clarify the comment:
- // Only inject if we have valid register hints and no SIMT copy + // Only inject default register hints when no explicit hints were provided and no SIMT copy is detected bool has_simt_copy = SimtCopyDetector::Detect(producer_body);
| if (call->op.same_as(no_set_max_nreg())) { | ||
| // Remove the original set_max_nreg calls as they will be re-inserted | ||
| // at appropriate locations | ||
| return Evaluate(0); | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Update the misleading comment.
The comment on lines 99-100 claims to "Remove the original set_max_nreg calls" but the code now only removes no_set_max_nreg() calls. Original set_max_nreg() calls are preserved in this version.
Apply this diff to correct the comment:
       if (call->op.same_as(no_set_max_nreg())) {
-        // Remove the original set_max_nreg calls as they will be re-inserted
-        // at appropriate locations
+        // Remove no_set_max_nreg() calls to allow injection of default hints
+        // if no explicit register hints were provided
         return Evaluate(0);
       }📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| if (call->op.same_as(no_set_max_nreg())) { | |
| // Remove the original set_max_nreg calls as they will be re-inserted | |
| // at appropriate locations | |
| return Evaluate(0); | |
| if (call->op.same_as(no_set_max_nreg())) { | |
| // Remove no_set_max_nreg() calls to allow injection of default hints | |
| // if no explicit register hints were provided | |
| return Evaluate(0); | 
🤖 Prompt for AI Agents
In src/transform/annotate_warp_group_reg_alloc.cc around lines 98 to 101, the
comment incorrectly states that "Remove the original set_max_nreg calls" while
the code only removes no_set_max_nreg() calls; update the comment to accurately
state that only no_set_max_nreg() calls are removed (or similar wording) so it
reflects the current behavior, e.g., change the comment to indicate removal of
no_set_max_nreg() calls which will be re-inserted later.
This pull request makes targeted changes to the
SetMaxNRegInjectorlogic inannotate_warp_group_reg_alloc.cc, refining how register allocation annotations are handled. The main focus is to adjust when and howset_max_nregcalls are injected and removed, specifically tightening the conditions under which register hints are applied.Refinements to register allocation annotation:
The check for removing
set_max_nregcalls inVisitStmt_is now limited to onlyno_set_max_nreg, meaning originalset_max_nregcalls are no longer removed at this stage.The logic for injecting register hints has changed: register hints are now only injected if both
dec_regandinc_regare exactly zero and there is no SIMT copy detected, simplifying and restricting the conditions for annotation. The register numbers are now hardcoded to 240 and 24 forinc_reganddec_regrespectively.Summary by CodeRabbit