Skip to content

Fix PT2E Mul weight detection for parameters - #4173

Open
ricardoasouz wants to merge 1 commit into
openvinotoolkit:developfrom
ricardoasouz:fix/3576-pt2e-weight-detection
Open

Fix PT2E Mul weight detection for parameters#4173
ricardoasouz wants to merge 1 commit into
openvinotoolkit:developfrom
ricardoasouz:fix/3576-pt2e-weight-detection

Conversation

@ricardoasouz

Copy link
Copy Markdown

Summary

Fixes PT2E/TorchAO weight detection for aten.mul.Tensor when a learned parameter can appear on either operand.

Previously, TorchAOQuantizerAdapter relied on metatype.weight_port_ids to determine whether a get_attr node represented a weight. PTMulMetatype has no fixed weight port because both

  • activation * weight
  • weight * activation

are valid.

As a result, a torch.nn.Parameter feeding Mul could be classified as an activation.

This change adds a Mul-specific fallback: when the source get_attr corresponds to a named torch.nn.Parameter, it is treated as a weight. Other operations continue to use the existing weight_port_ids behavior.

Tests

Added coverage for:

  • activation * Parameter -> WeightQuantizationInsertionPoint
  • Parameter * activation -> WeightQuantizationInsertionPoint
  • activation * buffer -> remains ActivationQuantizationInsertionPoint
  • custom TorchAO quantizer with batch size 2
  • automatic batchwise_statistics=True
  • explicit verification that quantization is not silently skipped
  • explicit Q/DQ presence in the resulting FX graph

Validation:

  • focused issue coverage: 4 passed
  • ViT regression checks: 2 passed
  • tests/executorch/test_ptq.py: 57 passed
  • make pre-commit: passed
  • git diff --check: passed

Notes

The behavior change is intentionally limited to PTMulMetatype so 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.

@ricardoasouz
ricardoasouz requested a review from a team as a code owner August 15, 2026 10:55
@ricardoasouz
ricardoasouz force-pushed the fix/3576-pt2e-weight-detection branch from 54d6cb4 to 471a982 Compare August 15, 2026 10:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants