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
diffusers.quantizers.pipe_quant_config references an undefined logger instance.
Reproduction
Install torch, torchvision, and torchao nightly, then import PipelineQuantizationConfig, TorchAoConfig from diffusers.
Logs
Traceback (most recent call last):
File ".venv/lib/python3.14/site-packages/diffusers/quantizers/torchao/torchao_quantizer.py", line 90, in _update_torch_safe_globals
from torchao.dtypes.uintx.uint4_layout import UInt4Tensor
ModuleNotFoundError: No module named 'torchao.dtypes.uintx.uint4_layout'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File ".venv/lib/python3.14/site-packages/diffusers/utils/import_utils.py", line 1016, in _get_module
return importlib.import_module("." + module_name, self.__name__)
~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.14/importlib/__init__.py", line 88, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "<frozen importlib._bootstrap>", line 1398, in _gcd_import
File "<frozen importlib._bootstrap>", line 1371, in _find_and_load
File "<frozen importlib._bootstrap>", line 1314, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 491, in _call_with_frames_removed
File "<frozen importlib._bootstrap>", line 1398, in _gcd_import
File "<frozen importlib._bootstrap>", line 1371, in _find_and_load
File "<frozen importlib._bootstrap>", line 1342, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 938, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 759, in exec_module
File "<frozen importlib._bootstrap>", line 491, in _call_with_frames_removed
File ".venv/lib/python3.14/site-packages/diffusers/quantizers/__init__.py", line 16, in<module>
from .auto import DiffusersAutoQuantizer
File ".venv/lib/python3.14/site-packages/diffusers/quantizers/auto.py", line 35, in<module>
from .torchao import TorchAoHfQuantizer
File ".venv/lib/python3.14/site-packages/diffusers/quantizers/torchao/__init__.py", line 15, in<module>
from .torchao_quantizer import TorchAoHfQuantizer
File ".venv/lib/python3.14/site-packages/diffusers/quantizers/torchao/torchao_quantizer.py", line 111, in<module>_update_torch_safe_globals()
~~~~~~~~~~~~~~~~~~~~~~~~~~^^
File ".venv/lib/python3.14/site-packages/diffusers/quantizers/torchao/torchao_quantizer.py", line 96, in _update_torch_safe_globals
logger.warning(
^^^^^^
NameError: name 'logger' is not defined
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "<frozen runpy>", line 198, in _run_module_as_main
File "<frozen runpy>", line 88, in _run_code
File "txt2img.py", line 14, in<module>
from diffusers import PipelineQuantizationConfig, TorchAoConfig, ZImagePipeline
File "<frozen importlib._bootstrap>", line 1423, in _handle_fromlist
File ".venv/lib/python3.14/site-packages/diffusers/utils/import_utils.py", line 1006, in __getattr__
module = self._get_module(self._class_to_module[name])
File ".venv/lib/python3.14/site-packages/diffusers/utils/import_utils.py", line 1018, in _get_module
raise RuntimeError(
...<2 lines>...
) from e
RuntimeError: Failed to import diffusers.quantizers.pipe_quant_config because of the following error (look up to see its traceback):
name 'logger' is not defined
System Info
$ diffusers-cli env
Copy-and-paste the text below in your GitHub issue and FILL OUT the two last points.
- 🤗 Diffusers version: 0.36.0
- Platform: Linux-6.12.69-1-lts-x86_64-with-glibc2.42
- Running on Google Colab?: No
- Python version: 3.14.2
- PyTorch version (GPU?): 2.11.0.dev20260207+rocm7.1 (True)
- Flax version (CPU?/GPU?/TPU?): not installed (NA)
- Jax version: not installed
- JaxLib version: not installed
- Huggingface_hub version: 1.4.1
- Transformers version: 5.1.0
- Accelerate version: 1.12.0
- PEFT version: 0.18.1
- Bitsandbytes version: not installed
- Safetensors version: 0.7.0
- xFormers version: not installed
- Accelerator: NA
- Using GPU in script?: <fill in>
- Using distributed or parallel set-up in script?: <fill in>
Who can help?
I was able to resolve the issue by simply referencing the default logger.
from ...utils.loggingimport_get_library_root_logger
Then adding the following line after checking for torch and torchao.
logger=_get_library_root_logger()
I'm not sure if this is the right way to fix it, but it the issue is resolved after adding these 2 lines to diffusers/quantizers/torchao/torchao_quantizer.py.
This is a nightly release, so I expect issues to appear from time to time. This seems like a simple oversight and is easy to fix.
I just wanted to add that torchao does not have the UInt4Tensor class definition nor the uint4_layout module.
This blocks quantization execution due to lazy loading.
fromtorchao.dtypesimportNF4Tensorfromtorchao.dtypes.floatx.float8_layoutimportFloat8AQTTensorImpl# There is no uint4_layout module and there is no UInt4Tensor class# for torchao >= 0.15.0# from torchao.dtypes.uintx.uint4_layout import UInt4Tensorfromtorchao.dtypes.uintx.uintx_layoutimportUintxAQTTensorImpl, UintxTensor# Remove the UInt4Tensor reference so that the code can be executed# safe_globals.extend([UintxTensor, UInt4Tensor, UintxAQTTensorImpl, Float8AQTTensorImpl, NF4Tensor])safe_globals.extend([UintxTensor, UintxAQTTensorImpl, Float8AQTTensorImpl, NF4Tensor])
The exception ends up blocking what would otherwise execute just fine.
Batching the imports is messy. Each import can be handled individually, but a better path might be to handle them conditionally.
It appears this is already been fixed on the main branch. A quick workaround is to simply edit your local copy of site-packages/diffusers/quantizers/torchao/torchao_quantizer.py and move the line at L126
@sayakpaul@yiyixuxu how does this slip through? cant you push a new release? pretty big issue. also, flux2 klein isn't even supported on the pypi release. it's been 2 months, and plenty of things are in main that need to be published.
the logger instance being missing is just a side-effect of the torchao uint4 import failing in diffusers vo.36 - it's a torchao breaking change in v0.16 which was released last night.
diffusers would be fine with v0.16 if it had the logger instance defined, though users would lose int4.
Activity
teleprint-me commentedon Feb 9, 2026
I accidentally closed this issue.
I just wanted to add that
torchaodoes not have theUInt4Tensorclass definition nor theuint4_layoutmodule.This blocks quantization execution due to lazy loading.
The exception ends up blocking what would otherwise execute just fine.
Batching the imports is messy. Each import can be handled individually, but a better path might be to handle them conditionally.
cardamon commentedon Feb 9, 2026
It appears this is already been fixed on the main branch. A quick workaround is to simply edit your local copy of
site-packages/diffusers/quantizers/torchao/torchao_quantizer.pyand move the line at L126up to around L74 (or higher)
teleprint-me commentedon Feb 9, 2026
Yes, I see the logger has been updated, but the import for uint4 is still invalid.
jdluzen commentedon Feb 10, 2026
I am also getting both the logger and import when I use
accelerate.teleprint-me commentedon Feb 10, 2026
It looks like it was fixed, but not packaged yet. So, the only way to resolve it is to install latest commit as:
Otherwise, you have hunt down and patch it manually or write a script that applies the patch automatically.
bghira commentedon Feb 11, 2026
@sayakpaul @yiyixuxu how does this slip through? cant you push a new release? pretty big issue. also, flux2 klein isn't even supported on the pypi release. it's been 2 months, and plenty of things are in main that need to be published.
bghira commentedon Feb 11, 2026
the logger instance being missing is just a side-effect of the torchao uint4 import failing in diffusers vo.36 - it's a torchao breaking change in v0.16 which was released last night.
diffusers would be fine with v0.16 if it had the logger instance defined, though users would lose int4.
tests: add regression test for logger NameError in torchao_quantizer (f…
use nightly diffusers to workaround huggingface/diffusers#13104 [no ci]
DN6 commentedon Mar 11, 2026
Should be fixed in release
0.37. Feel free to reopen if issue persists.