-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Persist valid rematerialisations from slice creation #8292
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
Conversation
3ea7fc5 to
7bb6583
Compare
`getConvertBackwardSlice` currently includes any existing rematerialisation it finds in the returned slice. However, this shouldn't be necessary because that value does not need to be rematerialised or included in the cost calculation. Instead, once we find a valid rematerialisation, we can stop the traversal right away.
7bb6583 to
087c9b7
Compare
| if (Value remat = getRematValue(v, layoutIt->second)) { | ||
| // If we found a valid rematerialization for this value while constructing | ||
| // the slice, use that. | ||
| if (Value remat = existingRemats.lookup({v, layoutIt->second})) { |
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.
Could you check properlyDominates here instead and not need to pass the additional data structure around everywhere?
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.
The issue is knowing which users it needs to dominate. We need to consider exactly the same rematerialisations as getConvertBackwardSlice here because any value that getConvertBackwardSlice finds an existing rematerialisation for will not be propagated through when constructing the backward slice.
If we require that the rematerialisation dominate all the users (or the original value itself), then it is possible we will disqualify rematerialisations that getConvertBackwardSlice did allow.
087c9b7 to
364706a
Compare
When we construct a slice, we correctly only consider rematerialisations that dominate the use in question. However, when rewriting the slice, we allow any rematerialisation, including one that might not dominate the users we want to rewrite. To address this, record the set of rematerialisations that we permitted while constructing the slice, and reuse them when rewriting the slice. This ensures that both operations consider the same set of valid rematerialisations. Note that it is important that they are the same, because slice creation stops once it encounters a valid rematerialisation, so the inputs to the value we are looking up will not be in the slice.
364706a to
a80b07e
Compare
|
This is causing some crash in our internal kernels. (causes inconsistent types to be generated: |
This reverts commit e3cf2ad.
Reverts #8292 as it causes functional regressions
|
@ThomasRaoux Sorry about the failures, if you have a repro or more information you can share, I'll dig into them when I next get the chance. |
I cannot share the repro at the moment but I'll try to reduce it and share |
When we construct a slice, we correctly only consider rematerialisations that dominate the use in question. However, when rewriting the slice, we allow any rematerialisation, including one that might not dominate the users we want to rewrite. To address this, record the set of rematerialisations that we permitted while constructing the slice, and reuse them when rewriting the slice. This ensures that both operations consider the same set of valid rematerialisations. Note that it is important that they are the same, because slice creation stops once it encounters a valid rematerialisation, so the inputs to the value we are looking up will not be in the slice. This addresses the crash in triton-lang#8257.
…-lang#8395) Reverts triton-lang#8292 as it causes functional regressions
When we construct a slice, we correctly only consider rematerialisations that dominate the use in question. However, when rewriting the slice, we allow any rematerialisation, including one that might not dominate the users we want to rewrite. To address this, record the set of rematerialisations that we permitted while constructing the slice, and reuse them when rewriting the slice. This ensures that both operations consider the same set of valid rematerialisations. Note that it is important that they are the same, because slice creation stops once it encounters a valid rematerialisation, so the inputs to the value we are looking up will not be in the slice. This addresses the crash in #8257.
Reverts #8292 as it causes functional regressions
When we construct a slice, we correctly only consider rematerialisations that dominate the use in question. However, when rewriting the slice, we allow any rematerialisation, including one that might not dominate the users we want to rewrite. To address this, record the set of rematerialisations that we permitted while constructing the slice, and reuse them when rewriting the slice. This ensures that both operations consider the same set of valid rematerialisations. Note that it is important that they are the same, because slice creation stops once it encounters a valid rematerialisation, so the inputs to the value we are looking up will not be in the slice. This addresses the crash in triton-lang#8257.
…-lang#8395) Reverts triton-lang#8292 as it causes functional regressions
When we construct a slice, we correctly only consider rematerialisations
that dominate the use in question. However, when rewriting the slice, we
allow any rematerialisation, including one that might not dominate the
users we want to rewrite.
To address this, record the set of rematerialisations that we permitted
while constructing the slice, and reuse them when rewriting the slice.
This ensures that both operations consider the same set of valid
rematerialisations.
Note that it is important that they are the same, because slice creation
stops once it encounters a valid rematerialisation, so the inputs to the
value we are looking up will not be in the slice.
This addresses the crash in #8257.
New contributor declaration
I am not making a trivial change, such as fixing a typo in a comment.
I have written a PR description following these
rules.
I have run
pre-commit run --from-ref origin/main --to-ref HEAD.Select one of the following.
/testforlittests/unittestfor C++ tests/python/testfor end-to-end testsFILL THIS IN.Select one of the following.
littests.littests I have added follow these best practices,including the "tests should be minimal" section. (Usually running Python code
and using the instructions it generates is not minimal.)