Skip to content

Make delete_constant_placeholder edit the graph signature in place - #24111

Open
borys3kk wants to merge 2 commits into
pytorch:mainfrom
borys3kk:transforms-delete-constant-placeholder-signature-main
Open

borys3kk wants to merge 2 commits into
pytorch:mainfrom
borys3kk:transforms-delete-constant-placeholder-signature-main

Conversation

@borys3kk

@borys3kk borys3kk commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Backend passes keep a reference to the ExportedProgram they were built from (XNNPACKPass.exported_program, for one), while ExportedProgramPassManager runs them on a shallow copy of it and rebuilds that copy's signature afterwards. delete_constant_placeholder replaced the original program's signature object, so the copy kept the old one, still listing the deleted placeholder, and its verifier failed with:

torch._export.verifier.SpecViolationError: Parameter <name> is not in the state dict.

create_constant_placeholder already inserts into the shared input_specs list in place; deletion now removes from that list in place too.

Test plan

New tests in backends/transforms/test/test_create_delete_constant_placeholder.py delete a placeholder from inside a pass run through ExportedProgramPassManager, one per kind: parameter, persistent buffer, non-persistent buffer and lifted constant tensor.

python -m pytest backends/transforms/test/test_create_delete_constant_placeholder.py

Without the fix, the 4 new tests fail (SpecViolationError for parameter, buffer and constant tensor, KeyError for the non-persistent buffer) and the 6 existing ones pass. With the fix, all 10 pass.

python -m pytest -n auto backends/transforms/test
python -m pytest backends/xnnpack/test/passes/test_batch_norm_fusion.py

325 passed, 50 skipped, 1 xfailed; and 5 passed. I could not run the Arm pass tests that call delete_constant_placeholder because they need tosa_serializer.

cc @GregoryComer @digantdesai @cbilgin @JakeStevens @cccclai @nil-is-all @rascani @msluszniak

Backend passes keep a reference to the ExportedProgram they were built from
(XNNPACKPass.exported_program, for one), while ExportedProgramPassManager runs
them on a shallow copy of it and rebuilds the signature of that copy afterwards.
delete_constant_placeholder replaced the original program's signature object,
so the copy kept the old one and its verifier failed with

  Parameter <name> is not in the state dict.

create_constant_placeholder already inserts into the shared input_specs list in
place; do the same for deletion. Tests cover a deletion made inside a pass run
through the manager for every constant placeholder kind.

Authored with Claude Code.
@pytorch-bot

pytorch-bot Bot commented Oct 23, 2026 •

Copy link
Copy Markdown

🔗 Helpful Links

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

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

❌ 2 Unclassified Failures

As of commit 6789b71 with merge base 422cc39 (image):

UNCLASSIFIED FAILURES - DrCI could not classify the following jobs because the workflow did not run on the merge base. The failures may be pre-existing on trunk or introduced by this PR:

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 Oct 23, 2026
@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.

@borys3kk
borys3kk marked this pull request as ready for review October 26, 2026 14:22
@executorch-triage executorch-triage Bot added the community: contribution PRs coming from community (excluding hardware partners) label Oct 26, 2026
@nil-is-all nil-is-all added module: xnnpack Issues related to xnnpack delegation and the code under backends/xnnpack/ module: backend Issues related to backend APIs or requests for new backends labels Oct 26, 2026

This branch has not been deployed

No deployments
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. community: contribution PRs coming from community (excluding hardware partners) module: backend Issues related to backend APIs or requests for new backends module: xnnpack Issues related to xnnpack delegation and the code under backends/xnnpack/

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants