Add RemoveBNTrackingMutationsPass (#19980)#19980
Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/19980
Note: Links to docs will display an error until the docs builds have been completed. ✅ No FailuresAs of commit 78e6ebc with merge base 1b7008b ( This comment was automatically generated by Dr. CI and updates every 15 minutes. |
|
@JakeStevens has exported this pull request. If you are a Meta employee, you can view the originating Diff in D107395650. |
This PR needs a
|
Summary:
`run_decompositions({})` in core PyTorch re-introduces `num_batches_tracked` mutable buffer outputs even when `batch_norm` uses `training=False`. This happens because the AOTAutograd functionalization pass unconditionally captures `BatchNorm`'s `num_batches_tracked` as a mutable buffer. The `to_edge_transform_and_lower` path avoids this, but the separate `to_edge()` path hits it.
Add a pass to `remove_ops.py` that strips `num_batches_tracked` buffer mutations from ExportedPrograms. We use the full ExportedProgramPassBase instead of just ExportPass so that we have access to the full program and signature, as we remove part of the input/output spec.
Add tests for a pass that removes `num_batches_tracked` buffer mutations from the edge program.
Differential Revision: D107395650
ea88f57 to
af800b7
Compare
Summary:
`run_decompositions({})` in core PyTorch re-introduces `num_batches_tracked` mutable buffer outputs even when `batch_norm` uses `training=False`. This happens because the AOTAutograd functionalization pass unconditionally captures `BatchNorm`'s `num_batches_tracked` as a mutable buffer. The `to_edge_transform_and_lower` path avoids this, but the separate `to_edge()` path hits it.
Add a pass to `remove_ops.py` that strips `num_batches_tracked` buffer mutations from ExportedPrograms. We use the full ExportedProgramPassBase instead of just ExportPass so that we have access to the full program and signature, as we remove part of the input/output spec.
Add tests for a pass that removes `num_batches_tracked` buffer mutations from the edge program.
Differential Revision: D107395650
Summary:
`run_decompositions({})` in core PyTorch re-introduces `num_batches_tracked` mutable buffer outputs even when `batch_norm` uses `training=False`. This happens because the AOTAutograd functionalization pass unconditionally captures `BatchNorm`'s `num_batches_tracked` as a mutable buffer. The `to_edge_transform_and_lower` path avoids this, but the separate `to_edge()` path hits it.
Add a pass to `remove_ops.py` that strips `num_batches_tracked` buffer mutations from ExportedPrograms. We use the full ExportedProgramPassBase instead of just ExportPass so that we have access to the full program and signature, as we remove part of the input/output spec.
Add tests for a pass that removes `num_batches_tracked` buffer mutations from the edge program.
Differential Revision: D107395650
af800b7 to
e3eec03
Compare
Summary: Add `ConvBNReluBasePattern` and concrete patterns (`Conv1dBNReluPattern0/1`, `Conv2dBNReluPattern0/1`) that match the 3-op `conv → batch_norm → relu` chain in QAT graphs. The existing `ConvReluBasePattern` only matches `conv → relu` (2-op), but in QAT graphs BatchNorm sits between conv and relu, preventing fusion. This produces separate `quantized_relu` and `requantize` ops in the lowered graph instead of a single fused quantized conv. The new patterns are registered only in `CadenceFusedConvReluQuantizer` (not default/wakeword), ordered before the 2-op patterns so the 3-op match takes priority. Differential Revision: D107396240
Summary:
`run_decompositions({})` in core PyTorch re-introduces `num_batches_tracked` mutable buffer outputs even when `batch_norm` uses `training=False`. This happens because the AOTAutograd functionalization pass unconditionally captures `BatchNorm`'s `num_batches_tracked` as a mutable buffer. The `to_edge_transform_and_lower` path avoids this, but the separate `to_edge()` path hits it.
Add a pass to `remove_ops.py` that strips `num_batches_tracked` buffer mutations from ExportedPrograms. We use the full ExportedProgramPassBase instead of just ExportPass so that we have access to the full program and signature, as we remove part of the input/output spec.
Add tests for a pass that removes `num_batches_tracked` buffer mutations from the edge program.
Differential Revision: D107395650
e3eec03 to
78e6ebc
Compare
Summary:
run_decompositions({})in core PyTorch re-introducesnum_batches_trackedmutable buffer outputs even whenbatch_normusestraining=False. This happens because the AOTAutograd functionalization pass unconditionally capturesBatchNorm'snum_batches_trackedas a mutable buffer. Theto_edge_transform_and_lowerpath avoids this, but the separateto_edge()path hits it.Add a pass to
remove_ops.pythat stripsnum_batches_trackedbuffer mutations from ExportedPrograms. We use the full ExportedProgramPassBase instead of just ExportPass so that we have access to the full program and signature, as we remove part of the input/output spec.Add tests for a pass that removes
num_batches_trackedbuffer mutations from the edge program.Differential Revision: D107395650