Repository navigation
Conversation
…ti node source partitions
aseemw
force-pushed
the
u/awadhwa/quantizer_fixes_3
branch
from
October 26, 2026 18:32
eee2937 to
f1f7eb3
Compare
aseemw
marked this pull request as ready for review
October 26, 2026 18:41
This branch has not been deployed
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 free
to 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.
This PR fixes a failure in graph-mode quantization when a model contains the same op written in two different ways, for example one add written as
x + yand another astorch.add(x, y).Quantizer.prepare()currently fails on such models with:A minimal example that reproduces it:
Cause
Op-list patterns (add, mul, cat, pooling, ...) were matched with torchao's
find_sequential_partitions, which gets the ops from torch'sget_source_partitions. That groups nodes into partitions based on the first element ofnode.meta["torch_fn"], a name made of the called function's__name__and a count of that function's calls.x + y(traced astorch.Tensor.add) andtorch.addare different functions with the same__name__, counted separately, so both nodes are named"add_1"and end up in a single partition. The annotation expects one op per partition and raises.Fix
torchao.quantization.pt2e.find_sequential_partitionsand adds a local_find_sequential_partitions. It matches ops node by node, using each node's op type, and returns results in the same format, but with every op in its ownSourcePartition, so both adds in the example above are matched and quantized._get_call_function_node_from_partitionfor partitions of SymInt shape-assert nodes, which can no longer occur.tuple[SourcePartition]type annotations totuple[SourcePartition, ...], since a match holds one partition per op in the pattern.