Fix PT2E Mul weight detection for parameters - #4173
Open
ricardoasouz wants to merge 1 commit into
Open
Conversation
ricardoasouz
force-pushed
the
fix/3576-pt2e-weight-detection
branch
from
August 15, 2026 10:59
54d6cb4 to
471a982
Compare
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.
Summary
Fixes PT2E/TorchAO weight detection for
aten.mul.Tensorwhen a learned parameter can appear on either operand.Previously,
TorchAOQuantizerAdapterrelied onmetatype.weight_port_idsto determine whether aget_attrnode represented a weight.PTMulMetatypehas no fixed weight port because bothactivation * weightweight * activationare valid.
As a result, a
torch.nn.ParameterfeedingMulcould be classified as an activation.This change adds a Mul-specific fallback: when the source
get_attrcorresponds to a namedtorch.nn.Parameter, it is treated as a weight. Other operations continue to use the existingweight_port_idsbehavior.Tests
Added coverage for:
activation * Parameter->WeightQuantizationInsertionPointParameter * activation->WeightQuantizationInsertionPointactivation * buffer-> remainsActivationQuantizationInsertionPointbatchwise_statistics=TrueValidation:
tests/executorch/test_ptq.py: 57 passedmake pre-commit: passedgit diff --check: passedNotes
The behavior change is intentionally limited to
PTMulMetatypeso parameters used by other operations continue to follow their existing metatype-defined weight-port semantics.Related to #3576.
AI-assisted development
AI tools were used during codebase exploration, hypothesis generation, and drafting. I personally reviewed, tested, and validated the final implementation and can explain and maintain the submitted changes.