Skip to content

Conversation

@chengyupku
Copy link
Contributor

@chengyupku chengyupku commented Sep 25, 2025

Summary by CodeRabbit

  • New Features
    • Added a built-in control-flow operation to break out of the innermost loop, enabling early termination when a condition is met. This simplifies conditional exit patterns in kernels and can reduce unnecessary iterations for better performance and readability. Available across supported backends without impacting existing behavior.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Sep 25, 2025

Walkthrough

Introduces a new public function loop_break() in tilelang/language/builtin.py that calls the intrinsic "tl.loop_break" via tir.call_intrin with tir.op.Op.get. Positioned after sync_grid, it returns the intrinsic handle. No other files or behaviors are changed.

Changes

Cohort / File(s) Summary of Changes
Builtins
tilelang/language/builtin.py
Added function loop_break() that returns tir.call_intrin("handle", tir.op.Op.get("tl.loop_break")), enabling invocation of the tl.loop_break intrinsic.

Sequence Diagram(s)

sequenceDiagram
    autonumber
    actor Dev as Developer Code
    participant Builtin as builtin.loop_break()
    participant TIR as tir.call_intrin(...)
    participant Op as tir.op.Op.get("tl.loop_break")
    participant IR as TL Intrinsic: tl.loop_break

    Dev->>Builtin: loop_break()
    Builtin->>Op: get("tl.loop_break")
    Op-->>Builtin: Op handle
    Builtin->>TIR: call_intrin("handle", Op)
    TIR->>IR: Invoke intrinsic
    Note right of IR: Signals break from innermost loop
    IR-->>Builtin: handle
    Builtin-->>Dev: return handle
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Poem

I hop through loops with nimble cheer,
A tiny break arrives right here—
A twitch, a turn, the cycle ends,
New paths to burrow, curve, and bend.
With tl whispers, I’m swift, awake—
One call, one hop: I cleanly break.

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title succinctly captures the primary change of adding support for the loop_break primitive, is concise and clear, and directly reflects the main focus of the updates in the pull request.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
✨ Finishing touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c538d8a and b45b2ed.

📒 Files selected for processing (1)
  • tilelang/language/builtin.py (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
tilelang/language/builtin.py (2)
tilelang/language/tir/op.py (1)
  • call_intrin (119-144)
src/transform/warp_specialized_rewriter.cc (16)
  • op (38-43)
  • op (38-38)
  • op (73-83)
  • op (73-73)
  • op (85-93)
  • op (85-85)
  • op (95-100)
  • op (95-95)
  • op (102-110)
  • op (102-102)
  • op (134-146)
  • op (134-134)
  • op (148-177)
  • op (148-148)
  • op (179-189)
  • op (179-179)
⏰ 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). (3)
  • GitHub Check: format-check
  • GitHub Check: bot-task
  • GitHub Check: format-check
🔇 Additional comments (1)
tilelang/language/builtin.py (1)

355-358: LGTM – loop_break intrinsic binding fits the existing pattern.

The wrapper mirrors the other intrinsic helpers and exposes the tl.loop_break op cleanly. No issues found.

Tip

👮 Agentic pre-merge checks are now available in preview!

Pro plan users can now enable pre-merge checks in their settings to enforce checklists before merging PRs.

  • Built-in checks – Quickly apply ready-made checks to enforce title conventions, require pull request descriptions that follow templates, validate linked issues for compliance, and more.
  • Custom agentic checks – Define your own rules using CodeRabbit’s advanced agentic capabilities to enforce organization-specific policies and workflows. For example, you can instruct CodeRabbit’s agent to verify that API documentation is updated whenever API schema files are modified in a PR. Note: Upto 5 custom checks are currently allowed during the preview period. Pricing for this feature will be announced in a few weeks.

Please see the documentation for more information.

Example:

reviews:
  pre_merge_checks:
    custom_checks:
      - name: "Undocumented Breaking Changes"
        mode: "warning"
        instructions: |
          Pass/fail criteria: All breaking changes to public APIs, CLI flags, environment variables, configuration keys, database schemas, or HTTP/GraphQL endpoints must be documented in the "Breaking Change" section of the PR description and in CHANGELOG.md. Exclude purely internal or private changes (e.g., code not exported from package entry points or explicitly marked as internal).

Please share your feedback with us on this Discord post.


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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions
Copy link

👋 Hi! Thank you for contributing to the TileLang project.

Please remember to run bash format.sh in the root directory of the project to ensure your changes are properly linted and formatted. This will help ensure your contribution passes the format check.

We appreciate you taking this step! Our team will review your contribution, and we look forward to your awesome work!

🚀

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @chengyupku, 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 introduces a new loop_break primitive to the tilelang language. This addition provides a direct mechanism for exiting the innermost loop, enhancing control flow capabilities within the language's iterative constructs.

Highlights

  • New Built-in Function: Introduced the loop_break() function in tilelang/language/builtin.py, which allows breaking out of the innermost loop by calling the tl.loop_break intrinsic.
Using Gemini Code Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

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

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a loop_break primitive. The implementation in tilelang/language/builtin.py is correct and consistent with the surrounding code. However, there are no tests included for this new functionality. Adding tests is crucial to ensure correctness and prevent future regressions. I also noticed a minor documentation issue in a related C++ header file (src/op/builtin.h) where the comment for loop_break incorrectly states it's for loop continue; it would be good to fix that as part of this change.

Comment on lines +355 to +358
def loop_break():
"""Break out of the innermost loop.
"""
return tir.call_intrin("handle", tir.op.Op.get("tl.loop_break"))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

This new loop_break primitive is a good addition. However, there are no tests in this pull request to verify its functionality. Please add unit tests to ensure loop_break behaves as expected and to safeguard against future regressions.

@chengyupku chengyupku merged commit 15a303d into tile-ai:main Sep 25, 2025
5 of 7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant