Skip to content

Conversation

neildhar
Copy link
Contributor

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.

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.

    • I have added tests.
      • /test for lit tests
      • /unittest for C++ tests
      • /python/test for end-to-end tests
    • This PR does not need a test because it is a simplification and existing tests pass.
  • Select one of the following.

    • I have not added any lit tests.
    • The lit tests 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.)

@neildhar neildhar marked this pull request as ready for review September 25, 2025 23:17
@neildhar neildhar requested a review from ptillet as a code owner September 25, 2025 23:17
`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.
@neildhar neildhar force-pushed the simplify-backward-remat branch from d9ed637 to 8acac09 Compare September 26, 2025 22:33
@peterbell10
Copy link
Contributor

Can you add a lit test that shows an improvement with this PR?

@neildhar
Copy link
Contributor Author

neildhar commented Oct 3, 2025

@peterbell10 I'm not sure it's possible to observe an improvement from this since the existing conversion is almost always itself a convert_layout. This PR is intended to simplify and document the interface to set up the bug fix in #8292.

@ThomasRaoux
Copy link
Collaborator

@peterbell10 I'm not sure it's possible to observe an improvement from this since the existing conversion is almost always itself a convert_layout. This PR is intended to simplify and document the interface to set up the bug fix in #8292.

are you saying it is an NFC change? If so can you stack the future changes somewhere so that we can review it together?

@neildhar
Copy link
Contributor Author

neildhar commented Oct 3, 2025

@ThomasRaoux Yes, I believe the way the pass is currently set up, this doesn't have any effect. My second PR #8292 stacks both changes, and includes a TTGIR lit test that crashes before the change, but works after it.

Copy link
Contributor

@peterbell10 peterbell10 left a comment

Choose a reason for hiding this comment

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

Okay, I guess it's hard to test this as it's in the middle of such a large pass. This definitely isn't NFC though if as you say it can change the rematerialization heuristic meaning we should rematerialize more in some cases.

@neildhar
Copy link
Contributor Author

neildhar commented Oct 7, 2025

This was combined with #8292 and merged in e3cf2ad.

@neildhar neildhar closed this Oct 7, 2025
@neildhar neildhar deleted the simplify-backward-remat branch October 7, 2025 20:38
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.

3 participants