Skip to content

More generic slice propagation before unary ops which works for non-contiguous slices (#19345)#19345

Merged
meta-codesync[bot] merged 1 commit intopytorch:mainfrom
DrJessop:export-D103752840
May 7, 2026
Merged

More generic slice propagation before unary ops which works for non-contiguous slices (#19345)#19345
meta-codesync[bot] merged 1 commit intopytorch:mainfrom
DrJessop:export-D103752840

Conversation

@DrJessop
Copy link
Copy Markdown
Contributor

@DrJessop DrJessop commented May 6, 2026

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

@pytorch-bot
Copy link
Copy Markdown

pytorch-bot Bot commented May 6, 2026

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/19345

Note: Links to docs will display an error until the docs builds have been completed.

❌ 30 Cancelled Jobs, 2 Unrelated Failures

As of commit b6f35de with merge base 851cffb (image):

CANCELLED JOBS - The following jobs were cancelled. Please retry:

FLAKY - The following job failed but was likely due to flakiness present on trunk:

BROKEN TRUNK - The following job failed but was present on the merge base:

👉 Rebase onto the `viable/strict` branch to avoid these failures

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label May 6, 2026
@meta-codesync
Copy link
Copy Markdown
Contributor

meta-codesync Bot commented May 6, 2026

@DrJessop has exported this pull request. If you are a Meta employee, you can view the originating Diff in D103752840.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 6, 2026

This PR needs a release notes: label

If your change should be included in the release notes (i.e. would users of this library care about this change?), please use a label starting with release notes:. This helps us keep track and include your important work in the next release notes.

To add a label, you can comment to pytorchbot, for example
@pytorchbot label "release notes: none"

For more information, see
https://github.com/pytorch/pytorch/wiki/PyTorch-AutoLabel-Bot#why-categorize-for-release-notes-and-how-does-it-work.

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
@meta-codesync meta-codesync Bot changed the title More generic slice propagation before unary ops which works for non-contiguous slices More generic slice propagation before unary ops which works for non-contiguous slices (#19345) May 6, 2026
@DrJessop DrJessop force-pushed the export-D103752840 branch from b6f35de to f591926 Compare May 6, 2026 21:48
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
@meta-codesync meta-codesync Bot merged commit 76d941e into pytorch:main May 7, 2026
156 of 174 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. fb-exported meta-exported

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants