Skip to content

Remove unused exported tensor constants after Cortex-M lowering - #22862

Open
rascani wants to merge 11 commits into
mainfrom
gh/rascani/45/head
Open

rascani wants to merge 11 commits into
mainfrom
gh/rascani/45/head

Conversation

@rascani

@rascani rascani commented Sep 15, 2026

Copy link
Copy Markdown
Contributor

Cortex-M layout conversion leaves original constant placeholders that FX dead-code elimination preserves. Add a separate RemoveUnusedConstantsPass to retire unused input specs and storage in linear time. Include it after constant lifting in both default pass lists, after padding fusion and scratch sizing.

Lift constants exactly once through the pass list before pruning, avoiding generated buffer-name collisions. Remove the unconditional final lifting call: explicit custom lists define the complete pipeline and can select no cleanup, lifting only, or lifting followed by pruning. The small lifting adapter makes the existing utility usable by the standard ExportedProgram pass runner.

Preserve user inputs, mutation and gradient targets, preserved module-call signatures, and state shared with other entry points. The existing EXIR pass and other backend defaults remain unchanged. Eleven focused Python tests passed, including buffer-name collision and all three custom-list behaviors.

Authored with AI assistance from Codex.

[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
@rascani

rascani commented Sep 15, 2026 •

Copy link
Copy Markdown
Contributor Author

@pytorch-bot

pytorch-bot Bot commented Sep 15, 2026 •

Copy link
Copy Markdown

🔗 Helpful Links

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

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

✅ No Failures

As of commit 6991dda with merge base 1cd22ed (image):
💚 Looks good so far! There are no failures yet. 💚

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 Sep 15, 2026
rascani added a commit that referenced this pull request Sep 16, 2026
Cortex-M layout conversion leaves original constant placeholders that FX dead-code elimination preserves. Add a separate RemoveUnusedConstantsPass to retire unused input specs and storage in linear time. Include it after constant lifting in both default pass lists, after padding fusion and scratch sizing.

Lift constants exactly once through the pass list before pruning, avoiding generated buffer-name collisions. Remove the unconditional final lifting call: explicit custom lists define the complete pipeline and can select no cleanup, lifting only, or lifting followed by pruning. The small lifting adapter makes the existing utility usable by the standard ExportedProgram pass runner.

Preserve user inputs, mutation and gradient targets, preserved module-call signatures, and state shared with other entry points. The existing EXIR pass and other backend defaults remain unchanged. Eleven focused Python tests passed, including buffer-name collision and all three custom-list behaviors.

Authored with AI assistance from Codex.

ghstack-source-id: d1c398d
ghstack-comment-id: 5689274130
Pull-Request: #22862
@rascani
rascani marked this pull request as ready for review September 16, 2026 17:51
rascani added a commit that referenced this pull request Sep 16, 2026
Cortex-M layout conversion leaves original constant placeholders that FX dead-code elimination preserves. Add a separate RemoveUnusedConstantsPass to retire unused input specs and storage in linear time. Include it after constant lifting in both default pass lists, after padding fusion and scratch sizing.

Lift constants exactly once through the pass list before pruning, avoiding generated buffer-name collisions. Remove the unconditional final lifting call: explicit custom lists define the complete pipeline and can select no cleanup, lifting only, or lifting followed by pruning. The small lifting adapter makes the existing utility usable by the standard ExportedProgram pass runner.

Preserve user inputs, mutation and gradient targets, preserved module-call signatures, and state shared with other entry points. The existing EXIR pass and other backend defaults remain unchanged. Eleven focused Python tests passed, including buffer-name collision and all three custom-list behaviors.

Authored with AI assistance from Codex.

ghstack-source-id: e825659
ghstack-comment-id: 5689274130
Pull-Request: #22862
Base automatically changed from gh/rascani/44/head to main September 16, 2026 21:51
@github-actions

Copy link
Copy Markdown

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.

Comment thread backends/cortex_m/passes/cortex_m_pass_manager.py
Detach the graph, signature, and state dictionary before the Cortex-M lifting adapter invokes the in-place lifting utility. This preserves the original program and prevents a generated buffer name from overwriting another entry point's shared state.

Regression coverage exercises lift-only and lift-then-prune through both the Cortex-M manager and edge.transform(). The 19 focused tests and four MLPerf Tiny dialect tests pass.

Authored with AI assistance from Codex.

[ghstack-poisoned]
rascani added a commit that referenced this pull request Sep 18, 2026
Cortex-M layout conversion leaves original constant placeholders that FX dead-code elimination preserves. Add a separate RemoveUnusedConstantsPass to retire unused input specs and storage in linear time. Include it after constant lifting in both default pass lists, after padding fusion and scratch sizing.

Lift constants exactly once through the pass list before pruning, avoiding generated buffer-name collisions. Remove the unconditional final lifting call: explicit custom lists define the complete pipeline and can select no cleanup, lifting only, or lifting followed by pruning. The small lifting adapter makes the existing utility usable by the standard ExportedProgram pass runner.

Preserve user inputs, mutation and gradient targets, preserved module-call signatures, and state shared with other entry points. The existing EXIR pass and other backend defaults remain unchanged. Eleven focused Python tests passed, including buffer-name collision and all three custom-list behaviors.

Authored with AI assistance from Codex.

ghstack-source-id: 3f25b1c
ghstack-comment-id: 5689274130
Pull-Request: #22862
rascani added a commit that referenced this pull request Sep 22, 2026
Cortex-M layout conversion leaves original constant placeholders that FX dead-code elimination preserves. Add a separate RemoveUnusedConstantsPass to retire unused input specs and storage in linear time. Include it after constant lifting in both default pass lists, after padding fusion and scratch sizing.

Lift constants exactly once through the pass list before pruning, avoiding generated buffer-name collisions. Remove the unconditional final lifting call: explicit custom lists define the complete pipeline and can select no cleanup, lifting only, or lifting followed by pruning. The small lifting adapter makes the existing utility usable by the standard ExportedProgram pass runner.

Preserve user inputs, mutation and gradient targets, preserved module-call signatures, and state shared with other entry points. The existing EXIR pass and other backend defaults remain unchanged. Eleven focused Python tests passed, including buffer-name collision and all three custom-list behaviors.

Authored with AI assistance from Codex.

ghstack-source-id: f68d6ae
ghstack-comment-id: 5689274130
Pull-Request: #22862
@rascani

rascani commented Sep 23, 2026

Copy link
Copy Markdown
Contributor Author

Bump on this one @JakeStevens & @AdrianLundell

This branch was successfully deployed

1 active deployment
cadence — 6991dda6 Deployed Sep 23, 2026 by rascani via hifi-op-test / hifi4 #29446
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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants