Uh oh!
There was an error while loading. Please reload this page.
Fold DyT affine maps into following convolutions (#21953) - #21953
Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/21953
Note: Links to docs will display an error until the docs builds have been completed. ❌ 1 Unclassified FailureAs of commit a66e691 with merge base 1afd07f ( UNCLASSIFIED FAILURE - DrCI could not classify the following job because the workflow did not run on the merge base. The failure may be pre-existing on trunk or introduced by this PR:
This comment was automatically generated by Dr. CI and updates every 15 minutes. |
@cgreenberg has exported this pull request. If you are a Meta employee, you can view the originating Diff in D116573000. |
d5c698a to
7a77626Compare
|
7a77626 to
05c0192Compare52fe599 to
90cba80Compare90cba80 to
bab6aabCompareSummary: Second half of the Dynamic Tanh (DyT) lowering cost, and a companion to `FoldDyTAlphaIntoLUTPass`. Once the alpha multiply has been folded into the tanh TABLE, a DyT site still emits a per-channel gamma Mul and a per-channel beta Add between the TABLE and the convolution that consumes it. Both are full-tensor elementwise ops on Ethos-U. This adds `FoldDyTAffineIntoConvPass` in `backends/arm/_passes/`, which folds that affine into the weights and bias of the following convolution, the same algebra as BatchNorm folding: `conv(gamma * x + beta) == conv_with_scaled_weights(x) + conv(beta)`. Doing this in floating point is not safe here, because the intermediate INT8 requantization between the affine and the convolution is nonlinear, so a float fold can change rounding. The pass instead evaluates the site's real TOSA integer path over the materialized 256-entry TABLE and only rewrites when the resulting per-channel map is provably exactly integer-affine. Everything else fails closed: saturating or nonlinear maps, unsupported constant layouts, non-exclusive passthrough edges, rank or shape mismatches, and singleton-channel broadcast are all rejected rather than approximated. Padded convolutions are a special case. Gamma still folds exactly, but beta does not: with constant padding its contribution becomes position dependent at the boundary and cannot be represented by a single conv bias. For those sites the pass folds gamma only when gamma is an exact identity and leaves the beta Add in place. Also exposes a small hook in `insert_table_ops` that the fold needs to locate the materialized TABLE. As with the alpha fold, `register_pass_factories_before` is imported inside `register_fold_dyt_affine_into_conv_pass()` rather than at module scope, to avoid a circular import through `_passes/__init__.py`. The pass is inert until a model registers it, so this diff changes no behaviour on its own. Differential Revision: D116573000
bab6aab to
bef6d1dComparecgreenberg
commented
Aug 20, 2026
@pytorchbot label "release notes: arm" |
cgreenberg
commented
Aug 20, 2026
/easycla |
digantdesai
commented
Aug 20, 2026
@claude review this PR. |
Claude finished @digantdesai's task in 6m 0s —— View job PR Review: Fold DyT affine maps into following convolutions
I reviewed the affine-fold commit ( Correctness1. The conv accumulator equivalence assumes 2. Scale is intentionally left as the original conv input scale (:591) even though the input edge is now the TABLE, whose scale differs. This is correct at the code level (the integer accumulator and the output-rescale multiplier 3. Singleton-x affine ( Robustness / smaller notes
TestsCoverage is strong: exact fold, shared-weight distinct folds, identity removal, padded-beta retention, and every fail-closed path has a dedicated test with an explanatory docstring. The pipeline test correctly documents why CIThe two red jobs ( Overall this looks solid and safe-by-construction. My only substantive ask is guard #1 to keep the pass consistent with its own fail-closed contract. |
Summary: Companion to FoldDyTAlphaIntoLUTPass. FoldDyTAffineIntoConvPass removes the per-channel gamma Mul and beta Add after the DyT TABLE by folding their exact integer-affine map into the following convolution weights and bias. The pass evaluates the materialized 256-entry TABLE path and rewrites only when the map is provably exact. It fails closed on nonlinear or saturating maps, unsupported layouts or constants, mismatched quantization metadata, and ambiguous layout provenance. Padded convolutions retain beta when its boundary contribution cannot be represented by one bias. Coverage includes non-uniform gamma/beta, unpadded depthwise convolutions, output-zero-point equality, unused-constant cleanup, and exact-one-permute layout provenance. This revision contains only the public pass implementation, tests, and package export; pass registration is intentionally outside this public change. Differential Revision: D116573000
da09b25 to
6f5caa3Comparecgreenberg
commented
Aug 21, 2026
@claude review this PR |
rascani
left a comment
There was a problem hiding this comment.
Review automatically exported from Phabricator review in Meta.
Summary: Companion to FoldDyTAlphaIntoLUTPass. FoldDyTAffineIntoConvPass removes the per-channel gamma Mul and beta Add after the DyT TABLE by folding their exact integer-affine map into the following convolution weights and bias. The pass evaluates the materialized 256-entry TABLE path and rewrites only when the map is provably exact. It fails closed on nonlinear or saturating maps, unsupported layouts or constants, mismatched quantization metadata, and ambiguous layout provenance. Padded convolutions retain beta when its boundary contribution cannot be represented by one bias. Coverage includes non-uniform gamma/beta, unpadded depthwise convolutions, output-zero-point equality, unused-constant cleanup, and exact-one-permute layout provenance. This revision contains only the public pass implementation, tests, and package export; pass registration is intentionally outside this public change. Reviewed By: rascani Differential Revision: D116573000
6f5caa3 to
cf7b655CompareSummary: Companion to FoldDyTAlphaIntoLUTPass. FoldDyTAffineIntoConvPass removes the per-channel gamma Mul and beta Add after the DyT TABLE by folding their exact integer-affine map into the following convolution weights and bias. The pass evaluates the materialized 256-entry TABLE path and rewrites only when the map is provably exact. It fails closed on nonlinear or saturating maps, unsupported layouts or constants, mismatched quantization metadata, and ambiguous layout provenance. Padded convolutions retain beta when its boundary contribution cannot be represented by one bias. Coverage includes non-uniform gamma/beta, unpadded depthwise convolutions, output-zero-point equality, unused-constant cleanup, and exact-one-permute layout provenance. This revision contains only the public pass implementation, tests, and package export; pass registration is intentionally outside this public change. Reviewed By: rascani Differential Revision: D116573000
cf7b655 to
ccc5104CompareSummary: Companion to FoldDyTAlphaIntoLUTPass. FoldDyTAffineIntoConvPass removes the per-channel gamma Mul and beta Add after the DyT TABLE by folding their exact integer-affine map into the following convolution weights and bias. The pass evaluates the materialized 256-entry TABLE path and rewrites only when the map is provably exact. It fails closed on nonlinear or saturating maps, unsupported layouts or constants, mismatched quantization metadata, and ambiguous layout provenance. Padded convolutions retain beta when its boundary contribution cannot be represented by one bias. Coverage includes non-uniform gamma/beta, unpadded depthwise convolutions, output-zero-point equality, unused-constant cleanup, and exact-one-permute layout provenance. This revision contains only the public pass implementation, tests, and package export; pass registration is intentionally outside this public change. Reviewed By: rascani Differential Revision: D116573000
ccc5104 to
79d40aaCompareSummary: Companion to FoldDyTAlphaIntoLUTPass. FoldDyTAffineIntoConvPass removes the per-channel gamma Mul and beta Add after the DyT TABLE by folding their exact integer-affine map into the following convolution weights and bias. The pass evaluates the materialized 256-entry TABLE path and rewrites only when the map is provably exact. It fails closed on nonlinear or saturating maps, unsupported layouts or constants, mismatched quantization metadata, and ambiguous layout provenance. Padded convolutions retain beta when its boundary contribution cannot be represented by one bias. Coverage includes non-uniform gamma/beta, unpadded depthwise convolutions, output-zero-point equality, unused-constant cleanup, and exact-one-permute layout provenance. This revision contains only the public pass implementation, tests, and package export; pass registration is intentionally outside this public change. Reviewed By: rascani Differential Revision: D116573000
79d40aa to
ba4c79aCompareSummary: Companion to FoldDyTAlphaIntoLUTPass. FoldDyTAffineIntoConvPass removes the per-channel gamma Mul and beta Add after the DyT TABLE by folding their exact integer-affine map into the following convolution weights and bias. The pass evaluates the materialized 256-entry TABLE path and rewrites only when the map is provably exact. It fails closed on nonlinear or saturating maps, unsupported layouts or constants, mismatched quantization metadata, and ambiguous layout provenance. Padded convolutions retain beta when its boundary contribution cannot be represented by one bias. Coverage includes non-uniform gamma/beta, unpadded depthwise convolutions, output-zero-point equality, unused-constant cleanup, and exact-one-permute layout provenance. This revision contains only the public pass implementation, tests, and package export; pass registration is intentionally outside this public change. Reviewed By: rascani Differential Revision: D116573000
ba4c79a to
4bdc63cCompareSummary: Companion to FoldDyTAlphaIntoLUTPass. FoldDyTAffineIntoConvPass removes the per-channel gamma Mul and beta Add after the DyT TABLE by folding their exact integer-affine map into the following convolution weights and bias. The pass evaluates the materialized 256-entry TABLE path and rewrites only when the map is provably exact. It fails closed on nonlinear or saturating maps, unsupported layouts or constants, mismatched quantization metadata, and ambiguous layout provenance. Padded convolutions retain beta when its boundary contribution cannot be represented by one bias. Coverage includes non-uniform gamma/beta, unpadded depthwise convolutions, output-zero-point equality, unused-constant cleanup, and exact-one-permute layout provenance. This revision contains only the public pass implementation, tests, and package export; pass registration is intentionally outside this public change. Reviewed By: rascani Differential Revision: D116573000
4bdc63c to
232f4aeCompareSummary: Companion to FoldDyTAlphaIntoLUTPass. FoldDyTAffineIntoConvPass removes the per-channel gamma Mul and beta Add after the DyT TABLE by folding their exact integer-affine map into the following convolution weights and bias. The pass evaluates the materialized 256-entry TABLE path and rewrites only when the map is provably exact. It fails closed on nonlinear or saturating maps, unsupported layouts or constants, mismatched quantization metadata, and ambiguous layout provenance. Padded convolutions retain beta when its boundary contribution cannot be represented by one bias. Coverage includes non-uniform gamma/beta, unpadded depthwise convolutions, output-zero-point equality, unused-constant cleanup, and exact-one-permute layout provenance. This revision contains only the public pass implementation, tests, and package export; pass registration is intentionally outside this public change. Reviewed By: rascani Differential Revision: D116573000
232f4ae to
30319ccCompareSummary: Companion to FoldDyTAlphaIntoLUTPass. FoldDyTAffineIntoConvPass removes the per-channel gamma Mul and beta Add after the DyT TABLE by folding their exact integer-affine map into the following convolution weights and bias. The pass evaluates the materialized 256-entry TABLE path and rewrites only when the map is provably exact. It fails closed on nonlinear or saturating maps, unsupported layouts or constants, mismatched quantization metadata, and ambiguous layout provenance. Padded convolutions retain beta when its boundary contribution cannot be represented by one bias. Coverage includes non-uniform gamma/beta, unpadded depthwise convolutions, output-zero-point equality, unused-constant cleanup, and exact-one-permute layout provenance. This revision contains only the public pass implementation, tests, and package export; pass registration is intentionally outside this public change. Reviewed By: rascani Differential Revision: D116573000
30319cc to
5cb7173CompareSummary: Companion to FoldDyTAlphaIntoLUTPass. FoldDyTAffineIntoConvPass removes the per-channel gamma Mul and beta Add after the DyT TABLE by folding their exact integer-affine map into the following convolution weights and bias. The pass evaluates the materialized 256-entry TABLE path and rewrites only when the map is provably exact. It fails closed on nonlinear or saturating maps, unsupported layouts or constants, mismatched quantization metadata, and ambiguous layout provenance. Padded convolutions retain beta when its boundary contribution cannot be represented by one bias. Coverage includes non-uniform gamma/beta, unpadded depthwise convolutions, output-zero-point equality, unused-constant cleanup, and exact-one-permute layout provenance. This revision contains only the public pass implementation, tests, and package export; pass registration is intentionally outside this public change. Reviewed By: rascani Differential Revision: D116573000
5cb7173 to
d2db979CompareSummary: Companion to FoldDyTAlphaIntoLUTPass. FoldDyTAffineIntoConvPass removes the per-channel gamma Mul and beta Add after the DyT TABLE by folding their exact integer-affine map into the following convolution weights and bias. The pass evaluates the materialized 256-entry TABLE path and rewrites only when the map is provably exact. It fails closed on nonlinear or saturating maps, unsupported layouts or constants, mismatched quantization metadata, and ambiguous layout provenance. Padded convolutions retain beta when its boundary contribution cannot be represented by one bias. Coverage includes non-uniform gamma/beta, unpadded depthwise convolutions, output-zero-point equality, unused-constant cleanup, and exact-one-permute layout provenance. This revision contains only the public pass implementation, tests, and package export; pass registration is intentionally outside this public change. Reviewed By: rascani Differential Revision: D116573000
d2db979 to
0556b77CompareSummary: Companion to FoldDyTAlphaIntoLUTPass. FoldDyTAffineIntoConvPass removes the per-channel gamma Mul and beta Add after the DyT TABLE by folding their exact integer-affine map into the following convolution weights and bias. The pass evaluates the materialized 256-entry TABLE path and rewrites only when the map is provably exact. It fails closed on nonlinear or saturating maps, unsupported layouts or constants, mismatched quantization metadata, and ambiguous layout provenance. Padded convolutions retain beta when its boundary contribution cannot be represented by one bias. Coverage includes non-uniform gamma/beta, unpadded depthwise convolutions, output-zero-point equality, unused-constant cleanup, and exact-one-permute layout provenance. This revision contains only the public pass implementation, tests, and package export; pass registration is intentionally outside this public change. Reviewed By: rascani Differential Revision: D116573000
0556b77 to
1f8fcf7CompareSummary: Companion to FoldDyTAlphaIntoLUTPass. FoldDyTAffineIntoConvPass removes the per-channel gamma Mul and beta Add after the DyT TABLE by folding their exact integer-affine map into the following convolution weights and bias. The pass evaluates the materialized 256-entry TABLE path and rewrites only when the map is provably exact. It fails closed on nonlinear or saturating maps, unsupported layouts or constants, mismatched quantization metadata, and ambiguous layout provenance. Padded convolutions retain beta when its boundary contribution cannot be represented by one bias. Coverage includes non-uniform gamma/beta, unpadded depthwise convolutions, output-zero-point equality, unused-constant cleanup, and exact-one-permute layout provenance. This revision contains only the public pass implementation, tests, and package export; pass registration is intentionally outside this public change. Reviewed By: rascani Differential Revision: D116573000
1f8fcf7 to
a66e691CompareUh oh!
There was an error while loading. Please reload this page.
Summary:
Companion to FoldDyTAlphaIntoLUTPass. FoldDyTAffineIntoConvPass removes the per-channel gamma Mul and beta Add after the DyT TABLE by folding their exact integer-affine map into the following convolution weights and bias.
The pass evaluates the materialized 256-entry TABLE path and rewrites only when the map is provably exact. It fails closed on nonlinear or saturating maps, unsupported layouts or constants, mismatched quantization metadata, and ambiguous layout provenance. Padded convolutions retain beta when its boundary contribution cannot be represented by one bias.
Coverage includes non-uniform gamma/beta, unpadded depthwise convolutions, output-zero-point equality, unused-constant cleanup, and exact-one-permute layout provenance. This revision contains only the public pass implementation, tests, and package export; pass registration is intentionally outside this public change.
Reviewed By: rascani
Differential Revision: D116573000