Repository navigation
EnzymeHLOOpt: DUSDUSSubsuming moves slices only when it replaces the DUS - #3470
Merged
Merged
Conversation
DUSDUSSubsuming moves the slices of the inner of two dynamic update slices whose value does not change onto the outer one, so that the inner one dies once the outer is replaced by a piecewise select. It counted the move as progress on its own, also when the outer update could not be replaced; SliceOfDynamicUpdate then moves each such slice back (a slice of a DUS clear of its update is a slice of its operand), and the two traded the slices forever. Make the replacement first (it creates nothing when it cannot be made) and move the slices only when it is made. On MFEM's bilininteg_vecdiffusion_pa, enzyme-hlo-opt never finished one function once an unrelated pattern exposed such a pair; it now takes about a second. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016zErYp7upmqr4NHfhod9UD
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #3470 +/- ##
==========================================
+ Coverage 29.92% 29.98% +0.06%
==========================================
Files 241 241
Lines 48628 48670 +42
==========================================
+ Hits 14551 14596 +45
+ Misses 34077 34074 -3 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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
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.
DUSDUSSubsuming, on two stacked dynamic update slices, does two things:It reported success if either happened. When the outer update can't be replaced (here: partial updates whose sources don't span the result), it still moved the slices.
SliceOfDynamicUpdatethen moves each slice back, since a slice of a DUS that's clear of its update is a slice of the DUS's operand. The two patterns traded the slices forever:Fix: make the replacement first and move the slices only when it's made.
rematerializeByPiecewiseSelectreturns null before creating any op when it can't build the replacement, so trying it first leaves the IR untouched on failure.Found via: MFEM
bilininteg_vecdiffusion_pa.cpp. With #3444, one function'senzyme-hlo-optnever finished (> 10 min); with this fix it takes about a second. The cycle is in main's patterns: main hangs on the IR #3444 produces there, and on the 8-line test added here.Test: new
dusdus_slice_clear_of_update.mlirwith full-line goldens. Main doesn't terminate on it; with this fix the IR is left unchanged. All 42*dus*lit tests pass. Full local lit: 1506/1509. The other three fail on main as well:mem2reg_copied_fieldandmem2reg_split_aggregate(fixed by #3471), and//test:neuralgcm_test, which runs out of memory on our 32 GB GPUs.🤖 Generated with Claude Code
https://claude.ai/code/session_016zErYp7upmqr4NHfhod9UD