Add targeted_ops to core ExportPass passes for fast-copy optimization (#21702) - #21702
Open
apullin wants to merge 2 commits into
Open
Add targeted_ops to core ExportPass passes for fast-copy optimization (#21702)#21702apullin wants to merge 2 commits into
apullin wants to merge 2 commits into
Conversation
apullin
requested review from
JacobSzwejbka,
digantdesai and
larryliu0820
as code owners
August 9, 2026 22:51
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/21702
Note: Links to docs will display an error until the docs builds have been completed. ❌ 2 New FailuresAs of commit 6caf061 with merge base fb5eedc ( NEW FAILURES - The following jobs have failed:
This comment was automatically generated by Dr. CI and updates every 15 minutes. |
Contributor
This PR needs a
|
apullin
added a commit
to apullin/executorch
that referenced
this pull request
Aug 10, 2026
…pytorch#21702) Summary: Annotate four core `ExportPass` subclasses across three files with `targeted_ops` so they participate in the cold-node fast-copy path introduced by parent D97528110. When fast-copy remains safe, D975 copies eligible non-targeted `call_function` nodes with existing `val` metadata instead of replaying them through FakeTensor dispatch. This diff does not add generic pass skipping: every pass still enters replay, and hot nodes continue through each existing `call_operator` implementation. Each set exactly mirrors the rewrite guard already present in its pass: - `MemoryFormatOpsPass` targets `DimOrderOpsMap` keys. - `DimOrderOpsRevertPass` targets `MemoryFormatOpsMap` keys. - `NormalizeTransposePass` targets `aten.t.default`. - `RemoveMixedTypeOperators` targets `add.Tensor`, `mul.Tensor`, `sub.Tensor`, both tensor `div` overloads, and `minimum.default`. The diff is now stacked directly on D97528110, which owns the consumer infrastructure. Its previous D109215317 parent left these attributes inert. Direct raw-graph regressions prove that transpose normalization and mixed-type rewriting still dispatch hot operators while eligible unrelated operators bypass `call_operator`; the mixed-type test also verifies inserted promotion casts and output dtypes. A/B against D97528110 on the same host, with each revision run twice: - Synthetic add/conv/fc/mul U55 suite: 79.000s / 79.516s here versus 81.238s / 82.371s in D975. Mean speedup 3.1%; warmed speedup 3.5%. - CombinedControl U55 LOWERING: 145.801s / 145.888s here versus 148.465s / 149.726s in D975. Mean speedup 2.2%; warmed speedup 2.6%. Differential Revision: D96247716
apullin
force-pushed
the
export-D96247716
branch
from
August 10, 2026 00:05
059fc38 to
08dd81c
Compare
Summary: After ARM pass-skipping and targeted-op ownership landed separately in D106781989, this diff optimizes the remaining `ExportPass` replay cost for passes that declare `target_ops` or `targeted_ops`. Cold operator nodes are copied with `graph.node_copy` instead of being re-dispatched through FakeTensor. Old-to-new node remapping preserves dependencies and `get_attr` values. Fast-copy is disabled when `call()` is overridden, for exact convolution or linear targets, or after a hot node changes nested tensor metadata. The fast path preflights every input before mutating the new graph or module tree, so a remapping fallback cannot leave orphaned nodes, attributes, or remap entries. An explicitly empty `targeted_ops` remains authoritative instead of falling back to legacy `target_ops`. Nested ARM control-flow submodules use the established `ArmPass.should_run_pass()` contract. This diff does not duplicate pass auto-discovery or generic skipping logic owned by D106781989. Per review from `jrstevens`, the process-global FakeTensor cache extension is now isolated in child D115374097 so its monkeypatching design and incremental performance can be reviewed independently. A/B benchmark against the parent revision on the same host, each side run twice: - CombinedControl U55 lowering: 148.465s / 149.726s with fast-copy vs 165.886s / 171.181s before it. Warm speedup: 12.5%; two-run mean speedup: 11.5%. - Synthetic U55 suite: 81.238s / 82.371s vs 83.816s / 80.802s. The difference is within run-to-run noise; the large model is the representative workload. Differential Revision: D97528110
…pytorch#21702) Summary: Annotate four core `ExportPass` subclasses across three files with `targeted_ops` so they participate in the cold-node fast-copy path introduced by parent D97528110. When fast-copy remains safe, D975 copies eligible non-targeted `call_function` nodes with existing `val` metadata instead of replaying them through FakeTensor dispatch. This diff does not add generic pass skipping: every pass still enters replay, and hot nodes continue through each existing `call_operator` implementation. Each set exactly mirrors the rewrite guard already present in its pass: - `MemoryFormatOpsPass` targets `DimOrderOpsMap` keys. - `DimOrderOpsRevertPass` targets `MemoryFormatOpsMap` keys. - `NormalizeTransposePass` targets `aten.t.default`. - `RemoveMixedTypeOperators` targets `add.Tensor`, `mul.Tensor`, `sub.Tensor`, both tensor `div` overloads, and `minimum.default`. The diff is now stacked directly on D97528110, which owns the consumer infrastructure. Its previous D109215317 parent left these attributes inert. Direct raw-graph regressions prove that transpose normalization and mixed-type rewriting still dispatch hot operators while eligible unrelated operators bypass `call_operator`; the mixed-type test also verifies inserted promotion casts and output dtypes. A/B against D97528110 on the same host, with each revision run twice: - Synthetic add/conv/fc/mul U55 suite: 79.000s / 79.516s here versus 81.238s / 82.371s in D975. Mean speedup 3.1%; warmed speedup 3.5%. - CombinedControl U55 LOWERING: 145.801s / 145.888s here versus 148.465s / 149.726s in D975. Mean speedup 2.2%; warmed speedup 2.6%. Differential Revision: D96247716
apullin
force-pushed
the
export-D96247716
branch
from
August 10, 2026 00:28
08dd81c to
6caf061
Compare
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:
Annotate four core
ExportPasssubclasses across three files withtargeted_opsso they participate in the cold-node fast-copy path introduced by parent D97528110.When fast-copy remains safe, D975 copies eligible non-targeted
call_functionnodes with existingvalmetadata instead of replaying them through FakeTensor dispatch. This diff does not add generic pass skipping: every pass still enters replay, and hot nodes continue through each existingcall_operatorimplementation.Each set exactly mirrors the rewrite guard already present in its pass:
MemoryFormatOpsPasstargetsDimOrderOpsMapkeys.DimOrderOpsRevertPasstargetsMemoryFormatOpsMapkeys.NormalizeTransposePasstargetsaten.t.default.RemoveMixedTypeOperatorstargetsadd.Tensor,mul.Tensor,sub.Tensor, both tensordivoverloads, andminimum.default.The diff is now stacked directly on D97528110, which owns the consumer infrastructure. Its previous D109215317 parent left these attributes inert.
Direct raw-graph regressions prove that transpose normalization and mixed-type rewriting still dispatch hot operators while eligible unrelated operators bypass
call_operator; the mixed-type test also verifies inserted promotion casts and output dtypes.A/B against D97528110 on the same host, with each revision run twice:
Differential Revision: D96247716