Fix to_edge_transform_and_lower to respect preserve_ops without parti…#17493
Fix to_edge_transform_and_lower to respect preserve_ops without parti…#17493
Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/17493
Note: Links to docs will display an error until the docs builds have been completed. ❌ 1 New Failure, 1 Unrelated FailureAs of commit eebc204 with merge base a24d3e7 ( NEW FAILURE - The following job has failed:
FLAKY - The following job failed but was likely due to flakiness present on trunk:
This comment was automatically generated by Dr. CI and updates every 15 minutes. |
This PR needs a
|
There was a problem hiding this comment.
Pull request overview
Fixes to_edge_transform_and_lower so it respects EdgeCompileConfig.preserve_ops even when no partitioner is provided, aligning behavior with to_edge and preventing unintended decompositions (e.g., aten.linear.default → addmm).
Changes:
- Update
_gen_edge_manager_for_partitionersto removeconfig.preserve_opsentries from the default decomposition table in the no-partitioner path. - Add a regression test ensuring
preserve_opsprevents decomposition into_edge_transform_and_lowerwithout a partitioner.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
exir/program/_program.py |
Pops config.preserve_ops from the decomposition table when partitioners_for_program is empty, preventing unwanted decompositions. |
exir/program/test/test_program.py |
Adds a unit test covering preserve_ops behavior in to_edge_transform_and_lower with no partitioner. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
exir/program/test/test_program.py
Outdated
| def count_nodes(graph_module, target): | ||
| count = 0 | ||
| for node in graph_module.graph.nodes: | ||
| if node.op == "call_function" and node.target == target: | ||
| count += 1 | ||
| return count | ||
|
|
There was a problem hiding this comment.
This test duplicates a count_nodes helper that already exists in _test_to_edge_with_preserved_ops above. Consider extracting count_nodes into a shared helper (e.g., a private method on the test class) to avoid repeating the same graph-walk logic across tests.
There was a problem hiding this comment.
Good suggestion! Will do this in follow up PR..
aad97fa to
1aec3f5
Compare
…tioner Summary: to_edge_transform_and_lower silently ignores EdgeCompileConfig.preserve_ops when no partitioner is provided — ops like aten.linear.default get decomposed to addmm despite being listed in preserve_ops. This is inconsistent with to_edge, which correctly pops preserved ops from the decomposition table. The fix adds 3 lines to _gen_edge_manager_for_partitioners to pop config.preserve_ops from the table in the no-partitioner path, matching the existing to_edge behavior. When preserve_ops is empty (the default for all existing callers), the behavior is unchanged. Test: python3 -m unittest exir.program.test.test_program.TestProgramManagers.test_to_edge_transform_and_lower_with_preserve_ops_no_partitioner -v
1aec3f5 to
eebc204
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
cc @rascani @AdrianLundell |
…tioner
Summary:
to_edge_transform_and_lower silently ignores EdgeCompileConfig.preserve_ops when no partitioner is provided — ops like aten.linear.default get decomposed to addmm despite being listed in preserve_ops. This is inconsistent with to_edge, which correctly pops preserved ops from the decomposition table. The fix adds 3 lines to _gen_edge_manager_for_partitioners to pop config.preserve_ops from the table in the no-partitioner path, matching the existing to_edge behavior. When preserve_ops is empty (the default for all existing callers), the behavior is unchanged.
Test:
python3 -m unittest exir.program.test.test_program.TestProgramManagers.test_to_edge_transform_and_lower_with_preserve_ops_no_partitioner -v