Arm backend: Rework reporting of qspecs and qconfigs#19016
Arm backend: Rework reporting of qspecs and qconfigs#19016martinlsm wants to merge 4 commits intopytorch:mainfrom
Conversation
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
🔗 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 FailuresAs of commit 3476cd8 with merge base e281726 ( 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. |
|
@pytorchbot label ciflow/trunk |
|
@pytorchbot label "partner: arm" |
|
@pytorchbot label "release notes: none" |
There was a problem hiding this comment.
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_reportertobackends/cortex_m/and update imports/build targets to eliminate a Cortex-M ↔ Arm cyclic dependency. - Replace qconfig/qspec “registry dict” reporting with
QuantizationConfig.labeland a newqspec_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.
| 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 | ||
| ) |
This PR contains four commits:
Move quantizer_reporter out from cortex_m.quantizer
When importing
backends.cortex_m.quantizer.quantizer_reporterfrombackends.arm.quantizer.arm_quantizer_utils, a cyclic dependency chain isis formed. The problem is that quantizer_reporter triggers
backends/cortex_m/quantizer/__init__.pywhen imported, which in turn hasimports 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.
Arm backend: Remove _QuantizerReporterUserMixin
_QuantizerReporterUserMixin was a duplicated class with the name
QuantizerReporterUser. Remove the former to instead use the latter.
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.pyand populated by the user. This patch reworks this concept by instead
adding a label attribute to
QuantizationConfigthat the reporter canuse to print the config in a human-readable format.
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_QSPECSwhich waspopulated by the user. This dict would map qspec objects to string
representations. This patch removes this dict and instead modifies
the helper function
_qspec_reprto return a compact stringrepresentation based on the attributes of the qspec.
cc @digantdesai @freddan80 @per @zingo @oscarandersson8218 @mansnils @Sebastian-Larsson @robell