Skip to content

bug: torchao>=0.16.0 breaks model initialization due to diffusers 0.36.0 incompatibility (PR #974) #982

@ChuxiJ

Description

@ChuxiJ

Bug Description

After PR #974 (fd92d96) bumped torchao from >=0.14.1,<0.16.0 to >=0.16.0,<0.17.0, model initialization fails with:

RuntimeError: Failed to import diffusers.models.autoencoders.autoencoder_oobleck because of the following error:
name 'logger' is not defined

Root Cause

  1. torchao 0.16.0 removed the torchao.dtypes.uintx.uint4_layout module (which contained UInt4Tensor)
  2. diffusers 0.36.0 (the currently resolved version, since diffusers is unpinned in pyproject.toml) imports this removed module at module level in diffusers/quantizers/torchao/torchao_quantizer.py:89
  3. The ImportError handler at line 93 calls logger.warning(), but logger is not defined until line 126 — a bug in diffusers 0.36.0
  4. This causes a NameError that propagates up and crashes VAE model loading

diffusers 0.37.0+ fixed this by:

  • Moving logger definition before the function call
  • Adding a version gate: if is_torchao_version(">", "0.15.0"): pass to skip the UInt4Tensor import entirely for torchao 0.16.0+

Reference: huggingface/diffusers#11018

Impact

  • Gradio server starts but model initialization fails — users see the UI but cannot generate music
  • The LLM handler initializes fine, but the DiT handler (which needs AutoencoderOobleck from diffusers) crashes

Proposed Fix

Pin diffusers>=0.37.0 in pyproject.toml to ensure compatibility with torchao>=0.16.0.

diffusers was previously unpinned ("diffusers" with no version constraint), which allowed uv to resolve to 0.36.0 — a version incompatible with torchao 0.16.0.

Reproduction

# With torchao>=0.16.0 and diffusers<0.37.0 installed:
python -c "from diffusers.models import AutoencoderOobleck"
# → NameError: name 'logger' is not defined

Environment

  • torch: 2.10.0+cu128
  • torchao: 0.16.0
  • diffusers: 0.36.0
  • GPU: NVIDIA H200

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions