You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Removed torch.ao.quantization.quantizer imports in coremltools/optimize/torch break on torch 2.11 — request for decision on removal/deprecation of CoreMLQuantizer #2823
Three files under coremltools/optimize/torch/quantization/ import from torch.ao.quantization.quantizer, removed in torch 2.11 (PT2E quantization
migrated to torchao):
File
Lines
_annotation_config.py
11–13 from torch.ao.quantization.quantizer.quantizer import QuantizationSpec
_coreml_quantizer.py
12–13 from torch.ao.quantization.quantizer.quantizer import Quantizer / ...xnnpack_quantizer import _get_module_name_filter
Not wired into the public API, but still used by the test suite, and loading
any of them on torch 2.11+ fails immediately: ModuleNotFoundError: No module named 'torch.ao.quantization.quantizer'.
Verified with torch 2.11.0 (crash) vs 2.9.1 (control, succeeds).
How to reproduce
pip install torch==2.11.0 # or newer; 2.9.x does not reproduce
pip install coremltools
fromcoremltools.optimize.torch.quantization._annotation_configimportAnnotationConfig# ModuleNotFoundError: No module named 'torch.ao.quantization.quantizer'
A migration attempt already exists: pytorch/pytorch#169151
removed PT2E quantization from torch, and jerryzh168 (pytorch/ao maintainer)
opened apple/coremltools#2634
"Update callsite for pt2e quant" migrating these files to torchao. It was closed without merging (2026-01-24); the stated plan is to remove
CoreMLQuantizer from coremltools in favor of the ExecuTorch implementation
(executorch#16473).
See the PR for details.
Request
Please make a decision on the future of CoreMLQuantizer and act on it:
Remove the three modules (and their tests) as planned in PR Update callsite for pt2e quant #2634, or
formally deprecate them with a clear support statement (including a torch < 2.11 requirement or a torchao dependency for torch 2.11+); or
At minimum, keep these files from crashing on torch 2.11+: delete the
stale imports or gate them behind a version check with a clear error
message pointing to the replacement.
We'd appreciate an explicit statement on the support status, since the
current release allows torch 2.11+ (unbounded torch requirement) and ships
files that crash on load.
Suggested fix
Given PR #2634, deletion is the preferred direction (migration is blocked by
the observer/fake_quant incompatibility noted in the PR discussion). If
keeping the modules, the minimal fix is a guarded import:
try:
fromtorch.ao.quantization.quantizer.quantizerimport (
QuantizationSpecas_TorchQuantizationSpec,
)
exceptImportError: # torch>=2.11: PT2E quantization moved to torchaofromtorchao.quantization.pt2e.quantizer.quantizerimport (
QuantizationSpecas_TorchQuantizationSpec,
)
(torchao.quantization.pt2e.quantizer.quantizer.QuantizationSpec verified
present in torchao 0.16.0.)
Summary
Three files under
coremltools/optimize/torch/quantization/import fromtorch.ao.quantization.quantizer, removed in torch 2.11 (PT2E quantizationmigrated to torchao):
_annotation_config.pyfrom torch.ao.quantization.quantizer.quantizer import QuantizationSpec_coreml_quantizer.pyfrom torch.ao.quantization.quantizer.quantizer import Quantizer/...xnnpack_quantizer import _get_module_name_filter_coreml_quantizer_utils.pyQuantizationSpec,xnnpack_quantizer,xnnpack_quantizer_utilsimports)Not wired into the public API, but still used by the test suite, and loading
any of them on torch 2.11+ fails immediately:
ModuleNotFoundError: No module named 'torch.ao.quantization.quantizer'.Verified with torch 2.11.0 (crash) vs 2.9.1 (control, succeeds).
How to reproduce
pip install torch==2.11.0 # or newer; 2.9.x does not reproduce pip install coremltoolsRelated discussion: PR #2634
A migration attempt already exists: pytorch/pytorch#169151
removed PT2E quantization from torch, and jerryzh168 (pytorch/ao maintainer)
opened apple/coremltools#2634
"Update callsite for pt2e quant" migrating these files to torchao. It was
closed without merging (2026-01-24); the stated plan is to remove
CoreMLQuantizer from coremltools in favor of the ExecuTorch implementation
(executorch#16473).
See the PR for details.
Request
Please make a decision on the future of
CoreMLQuantizerand act on it:formally deprecate them with a clear support statement (including a
torch < 2.11requirement or atorchaodependency for torch 2.11+); orstale imports or gate them behind a version check with a clear error
message pointing to the replacement.
We'd appreciate an explicit statement on the support status, since the
current release allows torch 2.11+ (unbounded torch requirement) and ships
files that crash on load.
Suggested fix
Given PR #2634, deletion is the preferred direction (migration is blocked by
the observer/fake_quant incompatibility noted in the PR discussion). If
keeping the modules, the minimal fix is a guarded import:
(
torchao.quantization.pt2e.quantizer.quantizer.QuantizationSpecverifiedpresent in torchao 0.16.0.)
References
torch.ao.quantizationpytorch/pytorch#153892 ("torch.ao.quantization is deprecated")torchao.quantization.pt2e.quantizer.quantizer.QuantizationSpec