Skip to content

Arm backend: Rework reporting of qspecs and qconfigs#19016

Open
martinlsm wants to merge 4 commits intopytorch:mainfrom
martinlsm:qspecs
Open

Arm backend: Rework reporting of qspecs and qconfigs#19016
martinlsm wants to merge 4 commits intopytorch:mainfrom
martinlsm:qspecs

Conversation

@martinlsm
Copy link
Copy Markdown
Collaborator

@martinlsm martinlsm commented Apr 21, 2026

This PR contains four commits:

  1. Move quantizer_reporter out from cortex_m.quantizer
    When importing backends.cortex_m.quantizer.quantizer_reporter from
    backends.arm.quantizer.arm_quantizer_utils, a cyclic dependency chain is
    is formed. The problem is that quantizer_reporter triggers
    backends/cortex_m/quantizer/__init__.py when imported, which in turn has
    imports leading back to the Arm backend. To fix this problem, move
    quantizer_reporter to backends/cortex_m so it can be imported without
    forming any cycle.

  2. Arm backend: Remove _QuantizerReporterUserMixin
    _QuantizerReporterUserMixin was a duplicated class with the name
    QuantizerReporterUser. Remove the former to instead use the latter.

  3. Arm backend: Add label attribute to QuantizationConfig
    The quantizer reporter logs the quantization config in a human-readable
    format. Prior to this patch, this was done with the help of a dict
    called SUPPORTED_QCONFIGS, which was defined in quantizer_reporter.py
    and populated by the user. This patch reworks this concept by instead
    adding a label attribute to QuantizationConfig that the reporter can
    use to print the config in a human-readable format.

  4. Arm backend: Rework reporting of qspecs
    The quantization reporter prints quantization specs in human-readable
    format. Prior to this patch, this was implemented such that
    quantizer_reporter.py defined a dict SUPPORTED_QSPECS which was
    populated by the user. This dict would map qspec objects to string
    representations. This patch removes this dict and instead modifies
    the helper function _qspec_repr to return a compact string
    representation based on the attributes of the qspec.

cc @digantdesai @freddan80 @per @zingo @oscarandersson8218 @mansnils @Sebastian-Larsson @robell

Martin Lindström added 4 commits April 21, 2026 10:30
When importing backends.cortex_m.quantizer.quantizer_reporter from
backends.arm.quantizer.arm_quantizer_utils, a cyclic dependency chain is
is formed. The problem is that quantizer_reporter triggers
backends/cortex_m/quantizer/__init__.py when imported, which in turn has
imports leading back to the Arm backend.

To fix this problem, move quantizer_reporter to backends/cortex_m so it
can be imported without forming any cycle.

Signed-off-by: Martin Lindström <Martin.Lindstroem@arm.com>
Change-Id: I757aa090d35f47bdce4d523b064217c3069adf41
_QuantizerReporterUserMixin was a duplicated class with the name
QuantizerReporterUser. Remove the former to instead use the latter.

Signed-off-by: Martin Lindström <Martin.Lindstroem@arm.com>
Change-Id: Iafe28304ab1813a8f88f58e75fc9a277158e7773
The quantizer reporter logs the quantization config in a human-readable
format. Prior to this patch, this was done with the help of a dict
called `SUPPORTED_QCONFIGS`, which was defined in quantizer_reporter.py
and populated by the user. This patch reworks this concept by instead
adding a label attribute to `QuantizationConfig` that the reporter can
use to print the config in a human-readable format.

Signed-off-by: Martin Lindström <Martin.Lindstroem@arm.com>
Change-Id: I38e80c9c3d57fb9d858119fe4281b713bf472475
The quantization reporter prints quantization specs in human-readable
format. Prior to this patch, this was implemented such that
quantizer_reporter.py defined a dict `SUPPORTED_QSPECS` which was
populated by the user. This dict would map qspec objects to string
representations. This patch removes this dict and instead modifies
the helper function `_qspec_repr` to return a compact string
representation based on the attributes of the qspec.

Signed-off-by: Martin Lindström <Martin.Lindstroem@arm.com>
Change-Id: I9ccd9127b8c332e7c30662be6986ccad4a38881f
@martinlsm martinlsm requested a review from rascani as a code owner April 21, 2026 08:36
Copilot AI review requested due to automatic review settings April 21, 2026 08:36
@martinlsm martinlsm requested a review from digantdesai as a code owner April 21, 2026 08:36
@pytorch-bot
Copy link
Copy Markdown

pytorch-bot Bot commented Apr 21, 2026

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/19016

Note: Links to docs will display an error until the docs builds have been completed.

❌ 1 New Failure, 6 Unrelated Failures

As of commit 3476cd8 with merge base e281726 (image):

NEW FAILURE - The following job has failed:

FLAKY - The following job failed but was likely due to flakiness present on trunk:

BROKEN TRUNK - The following jobs failed but was present on the merge base:

👉 Rebase onto the `viable/strict` branch to avoid these failures

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Apr 21, 2026
@martinlsm
Copy link
Copy Markdown
Collaborator Author

@pytorchbot label ciflow/trunk

@martinlsm
Copy link
Copy Markdown
Collaborator Author

@pytorchbot label "partner: arm"

@pytorch-bot pytorch-bot Bot added the partner: arm For backend delegation, kernels, demo, etc. from the 3rd-party partner, Arm label Apr 21, 2026
@martinlsm
Copy link
Copy Markdown
Collaborator Author

@pytorchbot label "release notes: none"

@pytorch-bot pytorch-bot Bot added the release notes: none Do not include this in the release notes label Apr 21, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refactors quantization reporting for Arm/Cortex-M backends to avoid import cycles and to make qconfig/qspec reporting self-describing (via QuantizationConfig.label and attribute-based qspec formatting) rather than relying on external registration dicts.

Changes:

  • Move quantizer_reporter to backends/cortex_m/ and update imports/build targets to eliminate a Cortex-M ↔ Arm cyclic dependency.
  • Replace qconfig/qspec “registry dict” reporting with QuantizationConfig.label and a new qspec_repr() helper for compact, attribute-based qspec formatting.
  • Update Arm/Cortex-M quantizers and tests to use the new reporter API (QuantizerInfo.qconfig_label) and new string representations.

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
backends/cortex_m/test/misc/test_quantizer_reporter.py Updates tests to use the relocated reporter module and asserts new qspec string formatting via qspec_repr().
backends/cortex_m/quantizer_reporter.py Relocates and refactors reporter: removes qspec/qconfig registries, adds qspec_repr(), and changes QuantizerInfo to use qconfig_label.
backends/cortex_m/quantizer/quantizer.py Updates reporter import path to the new module location.
backends/cortex_m/quantizer/quantization_configs.py Stops registering qspec/qconfig dicts; instead sets human-readable labels directly on config instances.
backends/cortex_m/quantizer/TARGETS Removes per-subdir reporter target; depends on the new top-level //executorch/backends/cortex_m:quantizer_reporter.
backends/cortex_m/TARGETS Adds a new Buck target exporting quantizer_reporter.py from the Cortex-M root.
backends/arm/quantizer/quantization_config.py Adds optional label field to QuantizationConfig for debug/reporting.
backends/arm/quantizer/arm_quantizer_utils.py Removes duplicated reporter mixin and switches to QuantizerReporterUser; updates qconfig labeling logic.
backends/arm/quantizer/arm_quantizer.py Constructs and propagates meaningful label strings when creating quantization configs (instead of external registration).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +261 to 265
qconfig_label = (
self.quantization_config.label
if self.quantization_config.label is not None
else self.quantization_config.__class__.__name__ # no label, fallback to class name
)
@rascani rascani requested a review from AdrianLundell April 21, 2026 15:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ciflow/trunk CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. partner: arm For backend delegation, kernels, demo, etc. from the 3rd-party partner, Arm release notes: none Do not include this in the release notes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants