More generic slice propagation before unary ops which works for non-contiguous slices (#19345)#19345
Merged
meta-codesync[bot] merged 1 commit intopytorch:mainfrom May 7, 2026
Merged
Conversation
Contributor
|
@DrJessop has exported this pull request. If you are a Meta employee, you can view the originating Diff in D103752840. |
This PR needs a
|
ethansfng
approved these changes
May 6, 2026
DrJessop
pushed a commit
to DrJessop/executorch
that referenced
this pull request
May 6, 2026
…ontiguous slices (pytorch#19345) Summary: Pull Request resolved: pytorch#19345 The existing MoveSliceToInputPass in the Jarvis compiler propagates slices backward through computation chains using the tiling/region infrastructure. However, it only supports contiguous slices (step=1) because non-unitary steps cannot be represented as contiguous regions. This diff adds PropagateSlice, a lightweight pass that swaps slice_copy past element-wise quantize/dequantize ops when a cost model indicates it reduces data movement. Unlike MoveSliceToInputPass, it handles any step size (including non-contiguous slices like step=2), but only swaps past a single adjacent op rather than walking entire chains. The two passes are complementary: MoveSliceToInputPass handles deep propagation of contiguous slices through complex op chains with tiling, while PropagateSlice handles the simpler case of moving strided slices past quant/dequant boundaries where tiling is irrelevant (so far, but will be extended to other cases). The idea is eventually it can be applied iteratively to keep pushing the slice up. Changes: - Add PropagateSlice pass to reorder_ops.py with a dispatch-table design for extensibility - Cost model: only swap when the slice actually reduces tensor volume (sliced < full) - Supported ops: quantize_per_tensor, dequantize_per_tensor (both cadence and quantized_decomposed variants) - Tests moved into test_reorder_ops_passes.py alongside other reorder pass tests Differential Revision: D103752840 Reviewed By: ethansfng
…ontiguous slices (pytorch#19345) Summary: The existing MoveSliceToInputPass in the Jarvis compiler propagates slices backward through computation chains using the tiling/region infrastructure. However, it only supports contiguous slices (step=1) because non-unitary steps cannot be represented as contiguous regions. This diff adds PropagateSlice, a lightweight pass that swaps slice_copy past element-wise quantize/dequantize ops when a cost model indicates it reduces data movement. Unlike MoveSliceToInputPass, it handles any step size (including non-contiguous slices like step=2), but only swaps past a single adjacent op rather than walking entire chains. The two passes are complementary: MoveSliceToInputPass handles deep propagation of contiguous slices through complex op chains with tiling, while PropagateSlice handles the simpler case of moving strided slices past quant/dequant boundaries where tiling is irrelevant (so far, but will be extended to other cases). The idea is eventually it can be applied iteratively to keep pushing the slice up. Changes: - Add PropagateSlice pass to reorder_ops.py with a dispatch-table design for extensibility - Cost model: only swap when the slice actually reduces tensor volume (sliced < full) - Supported ops: quantize_per_tensor, dequantize_per_tensor (both cadence and quantized_decomposed variants) - Tests moved into test_reorder_ops_passes.py alongside other reorder pass tests Reviewed By: ethansfng Differential Revision: D103752840
b6f35de to
f591926
Compare
DrJessop
pushed a commit
to DrJessop/executorch
that referenced
this pull request
May 6, 2026
…ontiguous slices (pytorch#19345) Summary: The existing MoveSliceToInputPass in the Jarvis compiler propagates slices backward through computation chains using the tiling/region infrastructure. However, it only supports contiguous slices (step=1) because non-unitary steps cannot be represented as contiguous regions. This diff adds PropagateSlice, a lightweight pass that swaps slice_copy past element-wise quantize/dequantize ops when a cost model indicates it reduces data movement. Unlike MoveSliceToInputPass, it handles any step size (including non-contiguous slices like step=2), but only swaps past a single adjacent op rather than walking entire chains. The two passes are complementary: MoveSliceToInputPass handles deep propagation of contiguous slices through complex op chains with tiling, while PropagateSlice handles the simpler case of moving strided slices past quant/dequant boundaries where tiling is irrelevant (so far, but will be extended to other cases). The idea is eventually it can be applied iteratively to keep pushing the slice up. Changes: - Add PropagateSlice pass to reorder_ops.py with a dispatch-table design for extensibility - Cost model: only swap when the slice actually reduces tensor volume (sliced < full) - Supported ops: quantize_per_tensor, dequantize_per_tensor (both cadence and quantized_decomposed variants) - Tests moved into test_reorder_ops_passes.py alongside other reorder pass tests Reviewed By: ethansfng Differential Revision: D103752840
DrJessop
pushed a commit
to DrJessop/executorch
that referenced
this pull request
May 6, 2026
…ontiguous slices (pytorch#19345) Summary: The existing MoveSliceToInputPass in the Jarvis compiler propagates slices backward through computation chains using the tiling/region infrastructure. However, it only supports contiguous slices (step=1) because non-unitary steps cannot be represented as contiguous regions. This diff adds PropagateSlice, a lightweight pass that swaps slice_copy past element-wise quantize/dequantize ops when a cost model indicates it reduces data movement. Unlike MoveSliceToInputPass, it handles any step size (including non-contiguous slices like step=2), but only swaps past a single adjacent op rather than walking entire chains. The two passes are complementary: MoveSliceToInputPass handles deep propagation of contiguous slices through complex op chains with tiling, while PropagateSlice handles the simpler case of moving strided slices past quant/dequant boundaries where tiling is irrelevant (so far, but will be extended to other cases). The idea is eventually it can be applied iteratively to keep pushing the slice up. Changes: - Add PropagateSlice pass to reorder_ops.py with a dispatch-table design for extensibility - Cost model: only swap when the slice actually reduces tensor volume (sliced < full) - Supported ops: quantize_per_tensor, dequantize_per_tensor (both cadence and quantized_decomposed variants) - Tests moved into test_reorder_ops_passes.py alongside other reorder pass tests Reviewed By: ethansfng Differential Revision: D103752840
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.
Summary:
The existing MoveSliceToInputPass in the Jarvis compiler propagates slices backward through computation chains using the tiling/region infrastructure. However, it only supports contiguous slices (step=1) because non-unitary steps cannot be represented as contiguous regions.
This diff adds PropagateSlice, a lightweight pass that swaps slice_copy past element-wise quantize/dequantize ops when a cost model indicates it reduces data movement. Unlike MoveSliceToInputPass, it handles any step size (including non-contiguous slices like step=2), but only swaps past a single adjacent op rather than walking entire chains. The two passes are complementary: MoveSliceToInputPass handles deep propagation of contiguous slices through complex op chains with tiling, while PropagateSlice handles the simpler case of moving strided slices past quant/dequant boundaries where tiling is irrelevant (so far, but will be extended to other cases). The idea is eventually it can be applied iteratively to keep pushing the slice up.
Changes:
Reviewed By: ethansfng
Differential Revision: D103752840