Skip to content

[REFACTOR][METAL] Update CHECK_LE to TVM_FFI_ICHECK_LE in Metal runtime#18819

Merged
tqchen merged 2 commits intoapache:mainfrom
mshr-h:fix-missing-macro-migration
Feb 25, 2026
Merged

[REFACTOR][METAL] Update CHECK_LE to TVM_FFI_ICHECK_LE in Metal runtime#18819
tqchen merged 2 commits intoapache:mainfrom
mshr-h:fix-missing-macro-migration

Conversation

@mshr-h
Copy link
Contributor

@mshr-h mshr-h commented Feb 25, 2026

As per title.

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @mshr-h, 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 refactors the Metal runtime module by updating a specific macro used for boundary checks. The change ensures consistency with the TVM FFI (Foreign Function Interface) error checking conventions, improving maintainability and standardizing error reporting within the Metal backend.

Highlights

  • Metal Runtime Macro Update: Replaced the CHECK_LE macro with TVM_FFI_CHECK_LE in the Metal runtime module to align with TVM's Foreign Function Interface (FFI) checking mechanisms.

🧠 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
  • src/runtime/metal/metal_module.mm
    • Updated the CHECK_LE macro to TVM_FFI_CHECK_LE for consistency in FFI error handling.
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.

@mshr-h
Copy link
Contributor Author

mshr-h commented Feb 25, 2026

We can test the change after #18818 got merged.

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 updates the Metal runtime to use TVM_FFI_CHECK_LE instead of CHECK_LE for validating thread block size. This aligns the error checking with TVM's FFI-safe error handling mechanism, which is the correct approach for code at this boundary. The change is a straightforward replacement and no issues were identified during the review.

@mshr-h mshr-h changed the title [REFACTOR][METAL] Update CHECK to TVM_FFI_CHECK in Metal runtime [REFACTOR][METAL] Update CHECK_LE to TVM_FFI_CHECK_LE in Metal runtime Feb 25, 2026
int blockSize = wl.block_dim(0) * wl.block_dim(1) * wl.block_dim(2);
auto maxTotalThreadsPerThreadgroup = scache_[device_id].maxTotalThreadsPerThreadgroup;
CHECK_LE(blockSize, maxTotalThreadsPerThreadgroup);
TVM_FFI_CHECK_LE(blockSize, maxTotalThreadsPerThreadgroup);
Copy link
Member

Choose a reason for hiding this comment

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

TVM_FFI_CHECK_LE needs to have explicitly error type as third argument

Copy link
Contributor Author

Choose a reason for hiding this comment

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

thanks!

@mshr-h mshr-h changed the title [REFACTOR][METAL] Update CHECK_LE to TVM_FFI_CHECK_LE in Metal runtime [REFACTOR][METAL] Update CHECK_LE to TVM_FFI_ICHECK_LE in Metal runtime Feb 25, 2026
@tqchen tqchen marked this pull request as ready for review February 25, 2026 23:45
@tqchen tqchen merged commit 327315c into apache:main Feb 25, 2026
10 of 12 checks passed
@mshr-h mshr-h deleted the fix-missing-macro-migration branch February 26, 2026 02:22
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.

2 participants