Skip to content

Conversation

@LeiWang1999
Copy link
Member

as title.

…ndition handling

- Introduced a new function to replace IfThenElse nodes with their then_case while preserving attributes.
- Streamlined the PipelineBodyRewriter to improve buffer access rewriting and async state management.
- Enhanced the handling of pipeline loop conditions and added support for predicate conditions in the pipeline body.
- Removed obsolete code and improved overall code clarity and maintainability.
@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!

🚀

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.

Summary of Changes

Hello @LeiWang1999, 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 significantly refactors the pipeline pass by phasing out the use of fragment and double buffer information. The changes involve removing specialized rewriters and associated data structures, simplifying constructors, and integrating necessary buffer access logic directly into core components. This leads to a cleaner and more streamlined pipeline transformation process, reducing complexity and dependencies on outdated concepts.

Highlights

  • Removal of specialized rewriter: The PipelineOpaqueAccessRewriter class, which handled specific buffer access rewrites for tensor core fragments, has been completely removed. This simplifies the pipeline pass by eliminating a specialized rewriter.
  • Simplification of PipelineBodyRewriter: The fragment_info parameter and the opaque_access_rewriter_ member were removed from PipelineBodyRewriter, streamlining its constructor and dependencies.
  • Relocation of buffer access logic: The general RewriteBufferAccess method was moved from the removed PipelineOpaqueAccessRewriter directly into PipelineBodyRewriter, indicating that general buffer access rewriting is still necessary but is now integrated more directly into the main body rewriting logic.
  • Streamlined PipelineRewriter interface: Parameters related to double_buffers and fragment_info were removed from the PipelineRewriter constructor and its static Rewrite method, simplifying its interface and internal state.
  • Phase-out of double-buffering logic: The logic for handling double_buffers was removed, including a specific check for num_versions == 1 && double_buffers_.count(buffer), indicating that this particular double-buffering mechanism is no longer managed within this pass.
  • Refined asynchronous state management: The internal structs and logic for managing asynchronous states (AsyncStateLocal) were simplified, removing fields like seen, predicate, and commit_groups, and updating how wait counts are populated and loop statements are completed.
  • Simplified loop emission: The EmitImpl method, responsible for emitting loop statements, was simplified by removing the extra_loop_lower_bound parameter and adding a need_bound_check boolean, making the loop emission logic more direct.
  • Cleanup in PipelineInjector: The fragment_info_ and double_buffers members were removed from PipelineInjector, aligning with the overall phase-out of these concepts across the pipeline pass.
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 in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

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 issue 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 refactors the software pipeline injection pass to remove dependencies on fragment_info and double_buffer_info, simplifying the overall logic. It also introduces significant improvements to the handling of asynchronous pipeline stages, making the logic more robust and clear.

My review found one issue: the error messages for missing pipeline annotations in src/transform/inject_pipeline.cc have been swapped, which could be misleading. I've provided a suggestion to correct this. Otherwise, the changes look good and are a positive step towards a cleaner pipeline implementation.

Comment on lines 963 to 970
if (has_stage) {
LOG(FATAL)
<< "ValueError: Order of the software pipeline is not defined.";
<< "ValueError: Stage of the software pipeline is not defined.";
}
if (has_order) {
LOG(FATAL)
<< "ValueError: Stage of the software pipeline is not defined.";
<< "ValueError: Order of the software pipeline is not defined.";
}
Copy link
Contributor

Choose a reason for hiding this comment

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

high

The error messages for missing pipeline annotations seem to have been swapped in this change, which could be misleading for developers.

  • If has_stage is true but has_order is false, the error should indicate that the order annotation is missing.
  • If has_order is true but has_stage is false, the error should indicate that the stage annotation is missing.

The previous implementation had the correct error messages.

Suggested change
if (has_stage) {
LOG(FATAL)
<< "ValueError: Order of the software pipeline is not defined.";
<< "ValueError: Stage of the software pipeline is not defined.";
}
if (has_order) {
LOG(FATAL)
<< "ValueError: Stage of the software pipeline is not defined.";
<< "ValueError: Order of the software pipeline is not defined.";
}
if (has_stage) {
LOG(FATAL)
<< "ValueError: Order of the software pipeline is not defined.";
}
if (has_order) {
LOG(FATAL)
<< "ValueError: Stage of the software pipeline is not defined.";
}

…y std::move calls

- Updated return statements in multiple methods to return objects directly instead of using std::move, improving code clarity and potentially avoiding unnecessary moves.
- Ensured consistent handling of BufferStore and BufferLoad nodes during pipeline transformations.
@LeiWang1999 LeiWang1999 merged commit 49d5d80 into tile-ai:main Aug 13, 2025
2 checks passed
RubiaCx pushed a commit to RubiaCx/tilelang that referenced this pull request Nov 24, 2025
tile-ai#711)

* Update submodule 'tvm' to commit e11521e6936a827efa334588d29571fbb4620107

* Refactor inject_pipeline.cc to enhance pipeline body rewriting and condition handling

- Introduced a new function to replace IfThenElse nodes with their then_case while preserving attributes.
- Streamlined the PipelineBodyRewriter to improve buffer access rewriting and async state management.
- Enhanced the handling of pipeline loop conditions and added support for predicate conditions in the pipeline body.
- Removed obsolete code and improved overall code clarity and maintainability.

* lint fix

* Refactor return statements in inject_pipeline.cc to remove unnecessary std::move calls

- Updated return statements in multiple methods to return objects directly instead of using std::move, improving code clarity and potentially avoiding unnecessary moves.
- Ensured consistent handling of BufferStore and BufferLoad nodes during pipeline transformations.

* test fix
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