Skip to content

Stop getitem quantizer propagation on numel change - #4143

Open
tej-1916 wants to merge 1 commit into
openvinotoolkit:developfrom
tej-1916:fix/3109-getitem-quantizer-propagation
Open

Stop getitem quantizer propagation on numel change#4143
tej-1916 wants to merge 1 commit into
openvinotoolkit:developfrom
tej-1916:fix/3109-getitem-quantizer-propagation

Conversation

@tej-1916

Copy link
Copy Markdown

Summary

Fixes TorchFX quantizer propagation through operator.getitem when the selected tensor has a different number of elements than the source tensor.

Root cause

TorchFX graph conversion always classified operator.getitem as PTGatherMetatype, and gather is quantization-agnostic. As a result, activation quantizers could propagate backward through split/getitem boundaries and land on the producer tensor even when downstream weighted ops consumed smaller selected tensors.

Changes

  • Add a TorchFX metadata check that proves whether operator.getitem preserves tensor numel.
  • Mark unsafe or unproven getitems with an internal NNCF node propagation-barrier attribute while preserving their public PTGatherMetatype.
  • Route marked getitems through existing autogenerated ignored-node handling and exclude them as activation post-hook insertion points.
  • Add focused TorchFX regression tests for different-numel and same-numel getitem behavior.

Validation

  • python -m pytest tests/torch/fx/test_quantizer_config.py -k "getitem_different_numel or getitem_same_numel" -vv
  • python -m pytest tests/torch/fx/test_quantizer_config.py -q
  • python -m pytest tests/torch/fx/test_models.py -k "yolo26 or yolo11n or split or getitem" -q
  • python -m ruff format --check src/nncf/common/graph/graph.py src/nncf/experimental/torch/fx/nncf_graph_builder.py src/nncf/quantization/algorithms/min_max/algorithm.py tests/torch/fx/test_quantizer_config.py
  • python -m ruff check src/nncf/common/graph/graph.py src/nncf/experimental/torch/fx/nncf_graph_builder.py src/nncf/quantization/algorithms/min_max/algorithm.py tests/torch/fx/test_quantizer_config.py
  • git diff --check

@github-actions github-actions Bot added the NNCF PT Pull requests that updates NNCF PyTorch label Jul 18, 2026
@tej-1916
tej-1916 force-pushed the fix/3109-getitem-quantizer-propagation branch from b928096 to 3f5e844 Compare July 18, 2026 00:24
@tej-1916
tej-1916 force-pushed the fix/3109-getitem-quantizer-propagation branch from 3f5e844 to 7cd253e Compare July 18, 2026 00:25
@tej-1916
tej-1916 marked this pull request as ready for review July 18, 2026 00:30
@tej-1916
tej-1916 requested a review from a team as a code owner July 18, 2026 00:30
@tej-1916

Copy link
Copy Markdown
Author

The implementation and focused regression tests are ready for review. CI workflows currently show action required; could a maintainer please approve the workflow runs when convenient? Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

NNCF PT Pull requests that updates NNCF PyTorch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants