Uh oh!
There was an error while loading. Please reload this page.
Lift each constant once when exporting a partitioned graph - #4642
Open
shoumikhin wants to merge 1 commit into
Open
Lift each constant once when exporting a partitioned graph#4642shoumikhin wants to merge 1 commit into
shoumikhin wants to merge 1 commit into
Conversation
shoumikhinforce-pushed
the
fix/lift-duplicate-constant-placeholder
branch
from
August 30, 2026 18:04
ff312d1 to
9a9bfbfCompareInlining a partitioned graph leaves one get_attr node per partition that reads a constant, all carrying the same target. The lifting pass turned each of those into its own placeholder. fx makes a placeholder's name unique but not its target, and placeholder codegen emits the target, so the generated forward ended up with the same argument twice and failed to compile with "SyntaxError: duplicate argument". The signature also gained one input spec per read, all pointing at the same state dict key. Lifting each target once and pointing the later readers at that placeholder fixes both. One get_attr node with several users was always fine; what breaks is several get_attr nodes with the same target, which is what the partitions left in PyTorch produce once the inliner copies them back into one graph. Test plan: Added a test that builds that graph directly: three get_attr nodes for one buffer. It checks the lifted graph has two placeholders rather than four, that their targets are unique, that the signature carries one buffer spec, that the module recompiles, and that running it gives the right value. Without the change all five of those fail, including the recompile with the duplicate argument error. The value check is there because a version of the fix that rewires the later readers to the wrong placeholder passes every structural check while computing the wrong answer, and the buffer holds distinct values so that a wrong read is visible. It sits beside the other tests for lift rather than with the exporter's inlining tests, because it needs no GPU and no TensorRT engine, so it runs in the lane that every pull request runs. The tests it was written next to are only collected by suites that run on a schedule, so it would not otherwise have run before merge. The rest of the exporter inlining file still passes.
shoumikhinforce-pushed
the
fix/lift-duplicate-constant-placeholder
branch
from
August 30, 2026 20:10
9a9bfbf to
6935e4cCompare
This was referenced Aug 30, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for freeto join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Inlining a partitioned graph leaves one get_attr node per partition that reads a
constant, all carrying the same target. The lifting pass turned each of those into
its own placeholder. fx makes a placeholder's name unique but not its target, and
placeholder codegen emits the target, so the generated forward ended up with the
same argument twice and failed to compile with "SyntaxError: duplicate argument".
The signature also gained one input spec per read, all pointing at the same state
dict key.
Lifting each target once and pointing the later readers at that placeholder fixes
both. One get_attr node with several users was always fine; what breaks is several
get_attr nodes with the same target, which is what the partitions left in PyTorch
produce once the inliner copies them back into one graph.
Test plan:
Added a test that builds that graph directly: three get_attr nodes for one buffer.
It checks the lifted graph has two placeholders rather than four, that their
targets are unique, that the signature carries one buffer spec, that the module
recompiles, and that running it gives the right value.
Without the change all five of those fail, including the recompile with the
duplicate argument error. The value check is there because a version of the fix
that rewires the later readers to the wrong placeholder passes every structural
check while computing the wrong answer, and the buffer holds distinct values so
that a wrong read is visible.
It sits beside the other tests for lift rather than with the exporter's inlining
tests, because it needs no GPU and no TensorRT engine, so it runs in the lane that
every pull request runs. The tests it was written next to are only collected by
suites that run on a schedule, so it would not otherwise have run before merge.
The rest of the exporter inlining file still passes.