You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
On Python 3.10.13, running example_gemm.py with backend="msprof" fails while constructing the cache-flush PrimFunc:
TypeError: Forward references must evaluate to types. Got buffer.
Because msprof.py uses postponed annotations, Cache: TA.Tensor(...) is stored as a string. TileLang later resolves it as a forward reference, but TA.Tensor(...) evaluates to a TileLang Buffer rather than a Python type.
Approach
Define the inner cache-flush function without an inline annotation, then use a decorator to set the concrete Buffer in func.__annotations__ before calling TA.prim_func. This preserves the shape and dtype metadata needed to build the PrimFunc while avoiding the ForwardRef type check. The cache-flush kernel body and benchmark logic are unchanged.
👋 Hi! Thank you for contributing to the TileLang project.
Please remember to run pre-commit run --all-files 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! 🚀
No actionable comments were generated in the recent review.
Walkthrough
The nested cache-flush kernel now receives a concrete TA.Tensor annotation for Cache before TA.prim_func is applied. The kernel body remains unchanged.
Changes: Cache Flush Kernel
Layer / File(s)
Summary
Set the Cache annotation tilelang/profiler/msprof.py
A wrapper sets Cache to TA.Tensor((numel,), "int32") before applying TA.prim_func. This replaces the postponed string annotation.
This change fixes msprof cache-flush kernel construction on Python 3.10 by setting the Cache annotation directly. The kernel behavior is unchanged and no concrete merge risk was found.
Pre-merge checks: 4
Check name
Status
Explanation
Title check
The title names the Ascend msprof cache-flush annotation fix, which matches the single-file change in tilelang/profiler/msprof.py that replaces the postponed Cache annotation with a concrete buffer. I…
Linked Issues check
Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check
Check skipped because no linked issues were found for this pull request.
Description check
The description states the problem (a TypeError on Python 3.10.13 when running example_gemm.py with backend="msprof"), the cause (postponed annotations storing Cache as a string), and the fix (define …
Full details: Title check
Explanation
The title names the Ascend msprof cache-flush annotation fix, which matches the single-file change in tilelang/profiler/msprof.py that replaces the postponed Cache annotation with a concrete buffer. It is specific and describes the main change.
Full details: Description check
Explanation
The description states the problem (a TypeError on Python 3.10.13 when running example_gemm.py with backend="msprof"), the cause (postponed annotations storing Cache as a string), and the fix (define the inner function without an inline annotation and set the Buffer in func.annotations before calling TA.prim_func). This matches the raw summary of changes to msprof.py.
Finishing Touches
Generate unit tests (beta)
Create a new PR
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
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.
Reviewing files that changed from the base of the PR and between 210611d and 04d1d0a.
Files selected for processing: 1
tilelang/profiler/msprof.py
Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ascendbugSomething isn't workingpythonPull requests that update python code
1 participant
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
On Python 3.10.13, running
example_gemm.pywithbackend="msprof"fails while constructing the cache-flush PrimFunc:TypeError: Forward references must evaluate to types. Got buffer.Because
msprof.pyuses postponed annotations,Cache: TA.Tensor(...)is stored as a string. TileLang later resolves it as a forward reference, butTA.Tensor(...)evaluates to a TileLang Buffer rather than a Python type.Approach
Define the inner cache-flush function without an inline annotation, then use a decorator to set the concrete Buffer in
func.__annotations__before callingTA.prim_func. This preserves the shape and dtype metadata needed to build the PrimFunc while avoiding the ForwardRef type check. The cache-flush kernel body and benchmark logic are unchanged.