Drop dead torchao.dtypes imports from TorchAO safe-globals setup - #14391
Closed
vkuzo wants to merge 1 commit into
Closed
Drop dead torchao.dtypes imports from TorchAO safe-globals setup#14391vkuzo wants to merge 1 commit into
vkuzo wants to merge 1 commit into
Conversation
torchao removed the torchao/dtypes package (NF4Tensor and the AQT/layout tensor impls such as UintxTensor, UintxAQTTensorImpl, UInt4Tensor and Float8AQTTensorImpl). On current torchao these imports in `_update_torch_safe_globals` always failed into the `except` branch, logging a spurious warning and registering nothing from there. The rest of the diffusers TorchAO integration (quantization_config, quantizer, tests, docs) was already migrated to the AOBaseConfig API upstream, so this is the only remaining torchao.dtypes reference. Remove the dead try/except import block; the function now just registers the still-valid low-bit uint dtypes (torch.uint1..uint7) as safe globals. Test plan: - `python -c "import diffusers.quantizers.torchao.torchao_quantizer, diffusers.quantizers.quantization_config"` imports cleanly. - Repo-wide grep for `torchao.dtypes` / `torchao/dtypes` returns no matches. - `pytest tests/quantization/torchao/test_torchao.py`: 11 passed, 5 skipped, 5 failed. The 5 failures pre-exist on main independent of this change (verified by stashing it) and are unrelated to torchao.dtypes removal: test_quantization constructs `IntxWeightOnlyConfig(dtype=...)` which current torchao renamed to `weight_dtype`; test_memory_footprint / test_model_memory_usage assert on old Int4/Int8 tensor packing sizes; test_device_map produces nan output on the test GPU; and test_sequential_cpu_offload hits an Int8Tensor/accelerate `requires_grad` kwarg incompatibility. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Contributor
Author
|
cc @sayakpaul |
sayakpaul
reviewed
Aug 5, 2026
| (torch.uint6, "torch.uint6"), | ||
| (torch.uint7, "torch.uint7"), | ||
| ] | ||
| try: |
Member
There was a problem hiding this comment.
We should then pin the minimum version of torchao in here. Otherwise, this seems like a breaking change to me.
Contributor
Author
There was a problem hiding this comment.
sounds good, i'll defer this change to a time when diffusers upgrades minimum torchao version. The try-catch already handles the deletion I am mentioning gracefully. Thanks!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary:
torchao removed the torchao/dtypes package in pytorch/ao#4696, this PR does the appropriate deprecation in
diffusersto matchTest plan:
python -c "import diffusers.quantizers.torchao.torchao_quantizer, diffusers.quantizers.quantization_config"imports cleanly.torchao.dtypes/torchao/dtypesreturns no matches.pytest tests/quantization/torchao/test_torchao.py: 11 passed, 5 skipped, 5 failed. The 5 failures pre-exist on main independent of this change (verified by stashing it) and are unrelated to torchao.dtypes removal: test_quantization constructsIntxWeightOnlyConfig(dtype=...)which current torchao renamed toweight_dtype; test_memory_footprint / test_model_memory_usage assert on old Int4/Int8 tensor packing sizes; test_device_map produces nan output on the test GPU; and test_sequential_cpu_offload hits an Int8Tensor/acceleraterequires_gradkwarg incompatibility.Before submitting
self-reviewskill on the diff?documentation guidelines, and
here are tips on formatting docstrings.
Who can review?
Anyone in the community is free to review the PR once the tests have passed. Feel free to tag
members/contributors who may be interested in your PR.