Delete AffineQuantizedTensor, AQTTensorImpl, and Layout#4245
Delete AffineQuantizedTensor, AQTTensorImpl, and Layout#4245andrewor14 wants to merge 1 commit intomainfrom
Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/ao/4245
Note: Links to docs will display an error until the docs builds have been completed. ✅ No FailuresAs of commit 9eb99cb with merge base 1a1debb ( This comment was automatically generated by Dr. CI and updates every 15 minutes. |
|
@claude review please? |
|
Claude finished @andrewor14's task in 6m 11s —— View job Review of PR #4245: [draft] Delete AQT
Overall this is a clean deletion of the deprecated Issues1. Unrelated change to This PR removes
This should either be reverted or split into a separate PR with proper justification. 2. Weak assertion in assert "Tensor" in ql_str, (
f"Expected quantized tensor in repr, got: {ql_str}"
)The string 3. Stale comments referencing deleted functions Two files still reference the now-deleted
These comments should be updated to reference the current implementation. Nits4. The dict maps 5. The function body was entirely replaced with a What looks good
|
There was a problem hiding this comment.
we can follow up to delete this as well I think, maybe migrate the useful ones if any
| setattr(other_cls, f"{name}_{suffix}", new_test) | ||
|
|
||
|
|
||
| class TorchAOBasicTestCase(common_utils.TestCase): |
There was a problem hiding this comment.
we can probably delete this as well later
There was a problem hiding this comment.
this doesn't seem related to AQT?
There was a problem hiding this comment.
not related, but we already have tests in workflow tests, so not needed anymore
dc8f0eb to
84cdede
Compare
|
@claude review again please? |
|
Claude finished @andrewor14's task in 8m 19s —— View job Re-review of PR #4245: Delete AffineQuantizedTensor (AQT)
Previous review issues #1 (unrelated Issues1. CI failure: The Import chain: This is a top-level import in Fix options:
2. The old code had: not isinstance(mod.weight, AffineQuantizedTensor)This was removed, but no replacement guard was added. The remaining checks only cover The comment on line 183 explicitly states this check exists "to make sure the weight is only quantized once when it is shared by multiple linear modules." Suggested fix: Replace the removed and not isinstance(mod.weight, TorchAOBaseTensor)This covers all v2 quantized tensor types since they all inherit from Nits3. Doc path for
4. Dead code after The code after What looks good
|
ac92ac1 to
bf3628c
Compare
| class StretchedIntxWeightConfig(AOBaseConfig): | ||
| granularity: Granularity = PerAxis(0) | ||
| scale_dtype: Optional[torch.dtype] = None | ||
| layout: Optional[Layout] = None |
There was a problem hiding this comment.
@lisjin FYI deleting this field which I think is unused
|
@claude review again please |
|
Claude finished @andrewor14's task in 5m 2s —— View job Re-review of PR #4245: Delete AffineQuantizedTensor (AQT)
Previous review status: Issues #1 (unrelated Issue
This was flagged in the second review and the TODO was added, but since this is a behavioral regression (calling # Suggested fix at line 185-192:
return (
isinstance(mod, torch.nn.Linear)
and hasattr(mod, "weight")
and not isinstance(mod.weight, TorchAOBaseTensor)
and not isinstance(mod, nn.modules.linear.NonDynamicallyQuantizableLinear)
)Nits1. Dead code after
2.
3. Tutorial files will fail at import time Five tutorial files will
All have TODO comments — just noting for visibility since andrewor14 confirmed these are deferred to follow-up PRs. What looks good
| |
|
@andrewor14 has imported this pull request. If you are a Meta employee, you can view this in D100013598. |
|
@claude For "_is_linear no longer prevents double-quantization of v2 tensor types", this doesn't seem like a regression because for all v2 configs we already don't guard the double quantization before this PR? We just do this for v1 configs which use AQT. Can you check again? |
|
Claude finished @andrewor14's task in 1m 45s —— View job Re-examining
|
torchao/dtypes/utils.py
Outdated
| ) | ||
|
|
||
|
|
||
| def is_device(target_device_str: str, device: Union[str, torch.device]): |
There was a problem hiding this comment.
we can follow up to move this to torchao/utils.py
torchao/dtypes/utils.py
Outdated
| pack_dim = -1 | ||
| _layout = UintxLayout(dtype=dtype, pack_dim=pack_dim) | ||
| return to_affine_quantized_intx_static( | ||
| return to_affine_quantized_intx_static( # noqa: F821 |
There was a problem hiding this comment.
Yeah this whole block is dead code (AssertionError above), it already used deleted functions before
**Summary:** AffineQuantizedTensor was the v1 quantized tensor
system, now fully superseded by v2 tensor types (Int8Tensor,
Int4Tensor, Float8Tensor, IntxUnpackedToInt8Tensor, etc.) that
inherit from TorchAOBaseTensor.
**BC-Breaking notes:**
Before (AQT):
```python
from torchao.dtypes import to_affine_quantized_intx
from torchao.quantization import quantize_, Int4WeightOnlyConfig
# Low-level AQT API
weight = to_affine_quantized_intx(
weight, mapping_type, block_size, target_dtype,
quant_min, quant_max, eps, _layout=Layout(),
)
# High-level API (unchanged)
quantize_(model, Int4WeightOnlyConfig())
```
After (v2 tensors):
```python
from torchao.quantization import quantize_, Int4WeightOnlyConfig
# High-level API (unchanged, recommended)
quantize_(model, Int4WeightOnlyConfig())
# Low-level v2 API (if needed)
from torchao.quantization import Int4Tensor, IntxUnpackedToInt8Tensor
weight = Int4Tensor.from_hp(weight, block_size)
weight = IntxUnpackedToInt8Tensor.from_hp(weight, block_size, torch.int4)
```
**Detailed changes:**
Core deletions:
- torchao/dtypes/affine_quantized_tensor.py (class definition)
- torchao/dtypes/affine_quantized_tensor_ops.py (aten dispatch)
- torchao/dtypes/floatx/, torchao/dtypes/uintx/ (empty subpackages)
- torchao/dtypes/README.md (stale AQT-centric docs)
- torchao/dtypes/utils.py: removed Layout class and AQTTensorImpl class
- torchao/dtypes/__init__.py: removed all AQT and Layout exports
- torchao/utils.py: removed _register_layout, _get_tensor_impl_constructor,
and their classmethod registrations on TorchAOBaseTensor
- test/dtypes/test_affine_quantized.py
- test/dtypes/test_affine_quantized_tensor_parallel.py
Core updates:
- quant_api.py: removed AQT from _is_linear check, removed 5 dead
activation quant helpers
- testing/utils.py: switched defaults from AQT to Int8Tensor
- Updated test assertions, docstrings, and docs to remove AQT references
Prototype updates:
- prototype/autoround/: removed broken AQT imports, updated isinstance
checks to TorchAOBaseTensor. Everything works except apply_auto_round()
which was already broken before this PR (issue #1690).
- prototype/dtypes/uintx/uintx_utils.py: removed UintxLayout,
UintxAQTTensorImpl, and AQT imports (fixes codebook import breakage)
- prototype/quantization/mixed_precision/: added assertion error since
feature was already broken by PlainLayout deletion (#4151)
Still broken (tracked with TODOs):
- tutorials/calibration_flow/ (uses to_affine_quantized_intx_static)
- tutorials/developer_api_guide/ (uses Layout)
Docs/comments only (not broken, just stale references):
- prototype/quantization/module_swap/ (README)
- prototype/parq/ (README)
- prototype/quantized_training/ (comments)
Summary: AffineQuantizedTensor was the v1 quantized tensor
system, now fully superseded by v2 tensor types (Int8Tensor,
Int4Tensor, Float8Tensor, IntxUnpackedToInt8Tensor, etc.) that
inherit from TorchAOBaseTensor.
BC-Breaking notes:
Before (AQT):
After (v2 tensors):
Detailed changes:
Core deletions:
and their classmethod registrations on TorchAOBaseTensor
Core updates:
activation quant helpers
Prototype updates:
checks to TorchAOBaseTensor. Everything works except apply_auto_round()
which was already broken before this PR (issue migration of
quantize_workflow configuration from callables to configs #1690).UintxAQTTensorImpl, and AQT imports (fixes codebook import breakage)
feature was already broken by PlainLayout deletion (Delete deprecated PlainLayout, PlainAQTTensorImpl and related v1 code paths #4151)
Still broken (tracked with TODOs):
Docs/comments only (not broken, just stale references):