-
Notifications
You must be signed in to change notification settings - Fork 25
Introduce @skip_rewrite_func
, @skip_rewrite_type
to extend should_rewrite_call
#1377
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
Merged
Conversation
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
wsmoses
reviewed
Jun 6, 2025
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.
can you add a test to confirm?
@skip_rewrite
to extend should_rewrite_call
@skip_rewrite_func
, @skip_rewrite_type
to extend should_rewrite_call
done, i'm not sure how to test |
wsmoses
approved these changes
Jun 11, 2025
Failed tests seem unrelated to the PR. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Performance comparison
I'm using
Muscle.binary_einsum
to compare compile time. It is semantically equal tostablehlo.dot_general
. What I found is that the compilation time disappears on the second time a function is traced. Notably I get a x5-30 comptime speedup on second tracing. Most probably this recompilation that disappears might be becauseMuscle.binary_einsum
is a type-unstable function and AFAIK that is a dynamic call that Reactant always rewrites. In that case, this PR successfully avoids the rewrites on those cases.Unfortunately, first trace comp time doesn't get lower and the bottleneck is probably in other part.
Before
After
Open questions
f
in@compile f(x)
) is marked, it won't be detected and it will rewrite it. Before starting the rewrite, we should check if the top-function must be rewritten. Here the proof that it's not working:should_rewrite_invoke
.Core.MethodTable
that it's only used to check methods that skip rewritting.