Skip to content

Namespace immutable constants per method in to_native (#23891) - #23891

Merged
meta-codesync[bot] merged 2 commits into
pytorch:mainfrom
JakeStevens:export-D125294428
Oct 28, 2026
Merged

meta-codesync[bot] merged 2 commits into
pytorch:mainfrom
JakeStevens:export-D125294428

Conversation

@JakeStevens

@JakeStevens JakeStevens commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

Summary:

Exported methods can reuse a constant name with different immutable tensors, causing to_native to reject the combined program. Namespace every immutable constant as <method>/<key>, including single-method programs, and update its graph references, including quantization metadata and nested graphs. Identical tensors still deduplicate when saving the .ptn.

Keys mutated by any method use shared state/<key> names throughout the program, preserving state shared by readers and writers. Update non-persistent buffer bindings and mutation outputs consistently, and reserve the state method namespace. Reject differing values for shared mutable keys and collisions between final names.

Authored with assistance from OpenAI Codex.

Reviewed By: digantdesai

Differential Revision: D125294428

@pytorch-bot

pytorch-bot Bot commented Oct 15, 2026 •

Copy link
Copy Markdown

🔗 Helpful Links

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

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

❌ 2 New Failures, 1 Unrelated Failure

As of commit 53825b9 with merge base e683360 (image):

NEW FAILURES - The following jobs have failed:

BROKEN TRUNK - The following job failed but were present on the merge base:

👉 Rebase onto the `viable/strict` branch to avoid these failures

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 15, 2026
@meta-codesync

meta-codesync Bot commented Oct 15, 2026

Copy link
Copy Markdown
Contributor

@JakeStevens has exported this pull request. If you are a Meta employee, you can view the originating Diff in D125294428.

@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.

@meta-codesync meta-codesync Bot changed the title Namespace colliding lifted tensor constants in to_native Namespace colliding lifted tensor constants in to_native (#23891) Oct 15, 2026
JakeStevens added a commit to JakeStevens/executorch that referenced this pull request Oct 15, 2026
Summary:

Edge lowering mints `_lifted_tensor_constant{i}` names independently
per method, so unrelated scalars (e.g. an fp32 attention scale and an
int64 zero) collide under one data key when packaging multiple
methods, and `to_native` rejected the package. Namespace only those
auto-generated keys per method (`<method>/<key>`) in both the merged
graph blob (new `rename_data_keys` in `graph_serialize.py`, walking
the same references as `collect_data_keys`) and the constant dicts;
identical tensors stay shared, mutated keys are never renamed, and
genuine parameter/buffer fqn collisions still raise.

Differential Revision: D125294428
JakeStevens added a commit to JakeStevens/executorch that referenced this pull request Oct 15, 2026
Summary:
Pull Request resolved: pytorch#23891

Edge lowering mints `_lifted_tensor_constant{i}` names independently
per method, so unrelated scalars (e.g. an fp32 attention scale and an
int64 zero) collide under one data key when packaging multiple
methods, and `to_native` rejected the package. Namespace only those
auto-generated keys per method (`<method>/<key>`) in both the merged
graph blob (new `rename_data_keys` in `graph_serialize.py`, walking
the same references as `collect_data_keys`) and the constant dicts;
identical tensors stay shared, mutated keys are never renamed, and
genuine parameter/buffer fqn collisions still raise.

Differential Revision: D125294428
JakeStevens added a commit to JakeStevens/executorch that referenced this pull request Oct 15, 2026
Summary:

Edge lowering mints `_lifted_tensor_constant{i}` names independently
per method, so unrelated scalars (e.g. an fp32 attention scale and an
int64 zero) collide under one data key when packaging multiple
methods, and `to_native` rejected the package. Namespace only those
auto-generated keys per method (`<method>/<key>`) in both the merged
graph blob (new `rename_data_keys` in `graph_serialize.py`, walking
the same references as `collect_data_keys`) and the constant dicts;
identical tensors stay shared, mutated keys are never renamed, and
genuine parameter/buffer fqn collisions still raise.

Differential Revision: D125294428
JakeStevens added a commit to JakeStevens/executorch that referenced this pull request Oct 15, 2026
Summary:
Pull Request resolved: pytorch#23891

Edge lowering mints `_lifted_tensor_constant{i}` names independently
per method, so unrelated scalars (e.g. an fp32 attention scale and an
int64 zero) collide under one data key when packaging multiple
methods, and `to_native` rejected the package. Namespace only those
auto-generated keys per method (`<method>/<key>`) in both the merged
graph blob (new `rename_data_keys` in `graph_serialize.py`, walking
the same references as `collect_data_keys`) and the constant dicts;
identical tensors stay shared, mutated keys are never renamed, and
genuine parameter/buffer fqn collisions still raise.

Differential Revision: D125294428
JakeStevens added a commit to JakeStevens/executorch that referenced this pull request Oct 15, 2026
…23891)

Summary:
Pull Request resolved: pytorch#23891

Edge lowering generates `_lifted_tensor_constant{i}` keys independently for each method. When methods use different scalar values under the same generated key, `to_native` rejects the combined program.

Always namespace generated immutable lifted constants as `<method>/<key>`, including single-method programs. Update the constant dictionaries and graph references together through a shared `map_data_keys` traversal, including quantization metadata and nested graphs. Equal tensors under different keys still deduplicate when saving the `.ptn`. Mutable keys keep their existing names, parameter/buffer conflicts continue to raise, and explicit keys occupying a generated namespace are rejected.

Authored with assistance from OpenAI Codex.

Differential Revision: D125294428
@meta-codesync meta-codesync Bot changed the title Namespace colliding lifted tensor constants in to_native (#23891) Namespace lifted tensor constants per method in to_native (#23891) Oct 15, 2026
JakeStevens added a commit to JakeStevens/executorch that referenced this pull request Oct 15, 2026
…23891)

Summary:

Edge lowering generates `_lifted_tensor_constant{i}` keys independently for each method. When methods use different scalar values under the same generated key, `to_native` rejects the combined program.

Always namespace generated immutable lifted constants as `<method>/<key>`, including single-method programs. Update the constant dictionaries and graph references together through a shared `map_data_keys` traversal, including quantization metadata and nested graphs. Equal tensors under different keys still deduplicate when saving the `.ptn`. Mutable keys keep their existing names, parameter/buffer conflicts continue to raise, and explicit keys occupying a generated namespace are rejected.

Authored with assistance from OpenAI Codex.

Differential Revision: D125294428

@digantdesai digantdesai left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review automatically exported from Phabricator review in Meta.

JakeStevens added a commit to JakeStevens/executorch that referenced this pull request Oct 16, 2026
Summary:
Pull Request resolved: pytorch#23891

Exported methods can reuse a constant name with different immutable tensors, causing `to_native` to reject the combined program. Namespace every immutable constant as `<method>/<key>`, including single-method programs, and update its graph references, including quantization metadata and nested graphs. Identical tensors still deduplicate when saving the `.ptn`.

Keys mutated by any method retain their original names throughout the program, preserving shared state for readers and writers. Reject differing values for shared mutable keys and collisions between final names.

Authored with assistance from OpenAI Codex.

Differential Revision: D125294428
@meta-codesync meta-codesync Bot changed the title Namespace lifted tensor constants per method in to_native (#23891) Namespace immutable constants per method in to_native (#23891) Oct 16, 2026
JakeStevens added a commit to JakeStevens/executorch that referenced this pull request Oct 16, 2026
Summary:
Pull Request resolved: pytorch#23891

Exported methods can reuse a constant name with different immutable tensors, causing `to_native` to reject the combined program. Namespace every immutable constant as `<method>/<key>`, including single-method programs, and update its graph references, including quantization metadata and nested graphs. Identical tensors still deduplicate when saving the `.ptn`.

Keys mutated by any method retain their original names throughout the program, preserving shared state for readers and writers. Reject differing values for shared mutable keys and collisions between final names.

Authored with assistance from OpenAI Codex.

Differential Revision: D125294428
@JakeStevens
JakeStevens force-pushed the export-D125294428 branch 2 times, most recently from f807a6e to fb49267 Compare October 16, 2026 18:27
JakeStevens added a commit to JakeStevens/executorch that referenced this pull request Oct 16, 2026
Summary:
Pull Request resolved: pytorch#23891

Exported methods can reuse a constant name with different immutable tensors, causing `to_native` to reject the combined program. Namespace every immutable constant as `<method>/<key>`, including single-method programs, and update its graph references, including quantization metadata and nested graphs. Identical tensors still deduplicate when saving the `.ptn`.

Keys mutated by any method retain their original names throughout the program, preserving shared state for readers and writers. Reject differing values for shared mutable keys and collisions between final names.

Authored with assistance from OpenAI Codex.

Differential Revision: D125294428
JakeStevens added a commit to JakeStevens/executorch that referenced this pull request Oct 16, 2026
Summary:
Pull Request resolved: pytorch#23891

Exported methods can reuse a constant name with different immutable tensors, causing `to_native` to reject the combined program. Namespace every immutable constant as `<method>/<key>`, including single-method programs, and update its graph references, including quantization metadata and nested graphs. Identical tensors still deduplicate when saving the `.ptn`.

Keys mutated by any method retain their original names throughout the program, preserving shared state for readers and writers. Reject differing values for shared mutable keys and collisions between final names.

Authored with assistance from OpenAI Codex.

Differential Revision: D125294428

@digantdesai digantdesai left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review automatically exported from Phabricator review in Meta.

JakeStevens added a commit to JakeStevens/executorch that referenced this pull request Oct 27, 2026
Summary:

Exported methods can reuse a constant name with different immutable tensors, causing `to_native` to reject the combined program. Namespace every immutable constant as `<method>/<key>`, including single-method programs, and update its graph references, including quantization metadata and nested graphs. Identical tensors still deduplicate when saving the `.ptn`.

Keys mutated by any method use shared `state/<key>` names throughout the program, preserving state shared by readers and writers. Update non-persistent buffer bindings and mutation outputs consistently, and reserve the `state` method namespace. Reject differing values for shared mutable keys and collisions between final names.

Authored with assistance from OpenAI Codex.

Reviewed By: digantdesai

Differential Revision: D125294428
JakeStevens added a commit to JakeStevens/executorch that referenced this pull request Oct 27, 2026
Summary:

Exported methods can reuse a constant name with different immutable tensors, causing `to_native` to reject the combined program. Namespace every immutable constant as `<method>/<key>`, including single-method programs, and update its graph references, including quantization metadata and nested graphs. Identical tensors still deduplicate when saving the `.ptn`.

Keys mutated by any method use shared `state/<key>` names throughout the program, preserving state shared by readers and writers. Update non-persistent buffer bindings and mutation outputs consistently, and reserve the `state` method namespace. Reject differing values for shared mutable keys and collisions between final names.

Authored with assistance from OpenAI Codex.

Reviewed By: digantdesai

Differential Revision: D125294428
JakeStevens added a commit to JakeStevens/executorch that referenced this pull request Oct 27, 2026
Summary:

Exported methods can reuse a constant name with different immutable tensors, causing `to_native` to reject the combined program. Namespace every immutable constant as `<method>/<key>`, including single-method programs, and update its graph references, including quantization metadata and nested graphs. Identical tensors still deduplicate when saving the `.ptn`.

Keys mutated by any method use shared `state/<key>` names throughout the program, preserving state shared by readers and writers. Update non-persistent buffer bindings and mutation outputs consistently, and reserve the `state` method namespace. Reject differing values for shared mutable keys and collisions between final names.

Authored with assistance from OpenAI Codex.

Reviewed By: digantdesai

Differential Revision: D125294428
JakeStevens added a commit to JakeStevens/executorch that referenced this pull request Oct 27, 2026
Summary:

Exported methods can reuse a constant name with different immutable tensors, causing `to_native` to reject the combined program. Namespace every immutable constant as `<method>/<key>`, including single-method programs, and update its graph references, including quantization metadata and nested graphs. Identical tensors still deduplicate when saving the `.ptn`.

Keys mutated by any method use shared `state/<key>` names throughout the program, preserving state shared by readers and writers. Update non-persistent buffer bindings and mutation outputs consistently, and reserve the `state` method namespace. Reject differing values for shared mutable keys and collisions between final names.

Authored with assistance from OpenAI Codex.

Reviewed By: digantdesai

Differential Revision: D125294428
Summary:

Add `EXECUTORCH_BUILD_NATIVE_LLM_RUNNER` to build and install `run_hf_llm_vulkan` and `run_hf_llm_ggml` for the enabled engines. Share gflags setup with the vision runner, resolve tokenizers with regex lookahead support, and add `native_llm_runner_utils_test`. Document building and running the GGML CPU LLM runner.

Authored with assistance from Codex.

Reviewed By: digantdesai

Differential Revision: D125479665
Summary:

Exported methods can reuse a constant name with different immutable tensors, causing `to_native` to reject the combined program. Namespace every immutable constant as `<method>/<key>`, including single-method programs, and update its graph references, including quantization metadata and nested graphs. Identical tensors still deduplicate when saving the `.ptn`.

Keys mutated by any method use shared `state/<key>` names throughout the program, preserving state shared by readers and writers. Update non-persistent buffer bindings and mutation outputs consistently, and reserve the `state` method namespace. Reject differing values for shared mutable keys and collisions between final names.

Authored with assistance from OpenAI Codex.

Reviewed By: digantdesai

Differential Revision: D125294428
@meta-codesync
meta-codesync Bot merged commit 8d7cce8 into pytorch:main Oct 28, 2026
412 of 415 checks passed
Erik-Lundell pushed a commit to Erik-Lundell/executorch that referenced this pull request Oct 28, 2026
Summary:

Exported methods can reuse a constant name with different immutable tensors, causing `to_native` to reject the combined program. Namespace every immutable constant as `<method>/<key>`, including single-method programs, and update its graph references, including quantization metadata and nested graphs. Identical tensors still deduplicate when saving the `.ptn`.

Keys mutated by any method use shared `state/<key>` names throughout the program, preserving state shared by readers and writers. Update non-persistent buffer bindings and mutation outputs consistently, and reserve the `state` method namespace. Reject differing values for shared mutable keys and collisions between final names.

Authored with assistance from OpenAI Codex.

Reviewed By: digantdesai

Differential Revision: D125294428

Pull Request resolved: pytorch#23891
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. meta-exported

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants