Skip to content

Export: avoid reused lifted-constant names - #24567

Draft
psiddh wants to merge 2 commits into
pytorch:mainfrom
psiddh:stack2/pr02-lift-constants
Draft

psiddh wants to merge 2 commits into
pytorch:mainfrom
psiddh:stack2/pr02-lift-constants

Conversation

@psiddh

@psiddh psiddh commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

Avoid constant-name collisions when lifting tensors

A program with a buffer already named _lifted_tensor_constant1 could lift a new scalar into the same name. The resulting signature has duplicate buffer names and can lose a folded constant. Reserve existing names before assigning names to newly lifted tensors.

Review order: the name allocation in lift_constant_tensor_pass, then test_lift_constant_tensor_pass_avoids_buffer_name_collision. This is PR 2 of the Stack 2 series. Its local parent is stack2/pr01-partitioner-transforms; the GitHub base is main, so it includes PR 1's commits followed by this constant-name fix.

Test Plan

On this PR's branch:

python -m pytest -q exir/tests/test_partitioner_transform_passes.py exir/tests/test_passes.py \
  -k 'partitioner_transform or caller_transform or pass_manager_argument or lift_constant_tensor_pass'
6 passed, 80 deselected in 6.81s

Against unmodified main, the collision regression fails with AssertionError: 2 != 1 (duplicate buffer names). After the fix, buffer names are unique and the original [2,2,2,2] buffer is unchanged.

No external memory-planning changes are carried in this PR. The reachable base is 5f72739cf26ed53df21a746fb5b022fb8e4266d9; GitHub main fetch returned proxy 403.

Stack (review in order)

  1. Partitioner: run backend-contributed edge transform passes #24566 Partitioner: run backend-contributed edge transform passes
  2. Export: avoid reused lifted-constant names #24567 Export: avoid reused lifted-constant names
  3. LLM runner: select I/O contracts and accept custom buffer allocators #24568 LLM runner: select I/O contracts and accept custom buffer allocators
  4. QNN: construct partitioners from options and allocate LLM I/O in rpcmem #24569 QNN: construct partitioners from options and allocate LLM I/O in rpcmem
  5. QNN: bind delegate outputs in exported program order #24570 QNN: bind delegate outputs in exported program order
  6. Export hf_static float-cache programs and register their Python runner #24571 Export hf_static float-cache programs and register their Python runner
  7. LLM runner: validate and drive hf_static float-cache programs #24572 LLM runner: validate and drive hf_static float-cache programs
  8. Document the version-1 hf_static I/O contract #24573 Document the version-1 hf_static I/O contract

Each PR includes the commits of the ones above it; review only its own top commits.

Run each partitioner’s edge transforms after caller-supplied passes so backends can use the standard lowering entry point. QNN contributes its existing transforms through the new hook.
Reserve names for constant tensors already present in the exported program before lifting new constants, so methods with folded tables retain distinct constants.
@pytorch-bot

pytorch-bot Bot commented Nov 3, 2026 •

Copy link
Copy Markdown

🔗 Helpful Links

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

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

✅ No Failures

As of commit 33eee76 with merge base 5f72739 (image):
💚 Looks good so far! There are no failures yet. 💚

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@github-actions

github-actions Bot commented Nov 3, 2026

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.

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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant