Skip to content

Integrate AutoRound into Diffusers#13552

Open
xin3he wants to merge 7 commits intohuggingface:mainfrom
xin3he:auto_round
Open

Integrate AutoRound into Diffusers#13552
xin3he wants to merge 7 commits intohuggingface:mainfrom
xin3he:auto_round

Conversation

@xin3he
Copy link
Copy Markdown

@xin3he xin3he commented Apr 23, 2026

What does this PR do?

This pull request introduces support for the AutoRound quantization algorithm in the Diffusers library. AutoRound is a weight-only quantization method that enables efficient inference by optimizing weight rounding and min-max ranges, primarily targeting the W4A16 configuration (4-bit weights, 16-bit activations). The changes add a new quantization config, quantizer class, backend integration, and comprehensive documentation, while ensuring proper handling of optional dependencies.

Key changes:

AutoRound quantization support

  • Added a new AutoRoundConfig class to quantization_config.py for configuring AutoRound quantization parameters, including bits, group size, symmetry, backend, and modules to exclude from quantization.
  • Introduced the AutoRoundQuantizer class in quantizers/autoround/autoround_quantizer.py, implementing the logic for loading pre-quantized AutoRound models and integrating with the auto-round library.
  • Registered AutoRoundConfig and AutoRoundQuantizer in the quantization auto-mapping logic, enabling selection via the "auto-round" key

Dependency management and import handling

  • Added is_auto_round_available utility and integrated it into the main import structure and conditional imports, ensuring that AutoRound features are only available if the dependency is installed. Dummy objects are provided otherwise.
  • Implemented a test utility require_auto_round_version_greater_or_equal for version-gated testing of AutoRound features.

Documentation

  • Added a comprehensive user guide at docs/source/en/quantization/autoround.md, including usage examples, backend options, configuration details, and resource links.

These changes collectively enable seamless integration of AutoRound quantization into Diffusers, with robust configuration, backend selection, and user guidance.

Existed Model

cc @wenhuach21 @thuang6 @hshen14

Before submitting

Who can review?

@yiyixuxu @asomoza @stevhliu @sayakpaul

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.

xin3he added 3 commits April 10, 2026 15:19
Signed-off-by: Xin He <xin3.he@intel.com>
Signed-off-by: Xin He <xin3.he@intel.com>
Signed-off-by: Xin He <xin3.he@intel.com>
@github-actions github-actions Bot added documentation Improvements or additions to documentation quantization tests utils size/L PR with diff > 200 LOC labels Apr 23, 2026
@github-actions github-actions Bot added size/L PR with diff > 200 LOC and removed size/L PR with diff > 200 LOC labels Apr 23, 2026
@xin3he xin3he changed the title Auto round Integrate AutoRound into Diffusers Apr 23, 2026
@xin3he
Copy link
Copy Markdown
Author

xin3he commented Apr 23, 2026

  • [2025/05] AutoRound has been integrated into vLLM: Usage, Medium blog, 小红书.

  • [2025/05] AutoRound has been integrated into Transformers: Blog.

I would like to integrate AutoRound into Diffusers to support diffusion models. Although the performance improvement is not significant, memory usage is notably reduced.

@sayakpaul
Copy link
Copy Markdown
Member

Thanks for this PR! Could you provide some example code using AutoRound and also some example outputs? Feel free to also report latency and memory consumption so that there's some signal into its effectiveness.

Cc: @SunMarc

Copy link
Copy Markdown
Member

@stevhliu stevhliu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for the integration!

Comment thread docs/source/en/quantization/autoround.md Outdated
Comment thread docs/source/en/quantization/autoround.md Outdated
Comment thread docs/source/en/quantization/autoround.md Outdated
Comment thread docs/source/en/quantization/autoround.md Outdated
Comment thread docs/source/en/quantization/autoround.md Outdated
Comment thread docs/source/en/quantization/autoround.md Outdated
Comment thread docs/source/en/quantization/autoround.md Outdated
Comment thread docs/source/en/quantization/autoround.md Outdated
Comment thread docs/source/en/quantization/autoround.md Outdated
Comment thread docs/source/en/quantization/autoround.md Outdated
Co-authored-by: Steven Liu <59462357+stevhliu@users.noreply.github.com>
@github-actions github-actions Bot added size/L PR with diff > 200 LOC and removed size/L PR with diff > 200 LOC labels Apr 24, 2026
Comment thread docs/source/en/quantization/autoround.md Outdated
Comment thread docs/source/en/quantization/autoround.md Outdated
Comment thread docs/source/en/quantization/autoround.md Outdated
Comment thread docs/source/en/quantization/autoround.md Outdated
Comment thread docs/source/en/quantization/autoround.md Outdated
Comment thread docs/source/en/quantization/autoround.md Outdated
@github-actions github-actions Bot added size/L PR with diff > 200 LOC and removed size/L PR with diff > 200 LOC labels Apr 24, 2026
Copy link
Copy Markdown

@thuang6 thuang6 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

…ecified backend.

Signed-off-by: Xin He <xin3.he@intel.com>
@xin3he
Copy link
Copy Markdown
Author

xin3he commented Apr 24, 2026

Thank you all for your valuable feedback; I have updated the document and fixed the errors.

@github-actions github-actions Bot added size/L PR with diff > 200 LOC and removed size/L PR with diff > 200 LOC labels Apr 24, 2026
Signed-off-by: Xin He <xin3.he@intel.com>
@xin3he
Copy link
Copy Markdown
Author

xin3he commented Apr 24, 2026

Thanks for this PR! Could you provide some example code using AutoRound and also some example outputs? Feel free to also report latency and memory consumption so that there's some signal into its effectiveness.

Cc: @SunMarc

Apologies; due to policy restrictions, I am unable to provide specific latency data. Based on local testing, the time consumed by the W4A16 Marlin backend is comparable to that of BF16.

For the memory consumption, I observe that the original z-image takes about 25GB and the quantized one takes about 16GB

You are welcome to use the code provided in the model card to attempt to reproduce these results. the generated picture looks good.


model_id = "INCModel/Z-Image-W4A16-AutoRound"

quantization_config = AutoRoundConfig(backend="marlin")
Copy link
Copy Markdown

@wenhuach21 wenhuach21 Apr 24, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in case there is a better backend in the future, we'd better not to explicitly code like this. Besides, If users have install gptqmodel, we will use marlin. Otherwise, we will remind user to install it.

pipe = ZImagePipeline.from_pretrained(
model_id,
torch_dtype=torch.bfloat16,
device_map="cuda",
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how about just setting the device_map to "auto"

model_id,
transformer=transformer,
torch_dtype=torch.bfloat16,
device_map="cuda",
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

device->auto

if not is_auto_round_available():
raise ImportError(
"Loading an AutoRound quantized model requires the auto-round library "
"(`pip install 'auto-round>=0.5'`)"
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

0.10 ?

@sayakpaul
Copy link
Copy Markdown
Member

Thanks for this PR! Could you provide some example code using AutoRound and also some example outputs? Feel free to also report latency and memory consumption so that there's some signal into its effectiveness.
Cc: @SunMarc

Apologies; due to policy restrictions, I am unable to provide specific latency data. Based on local testing, the time consumed by the W4A16 Marlin backend is comparable to that of BF16.

For the memory consumption, I observe that the original z-image takes about 25GB and the quantized one takes about 16GB

You are welcome to use the code provided in the model card to attempt to reproduce these results. the generated picture looks good.

I don't understand. Won't it run on a CUDA GPU? You cannot expect maintainers to run the code to address the bare minimums, I am afraid. Having the output samples and having comparisons to other methods gives us confidence in the quantization method itself.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation quantization size/L PR with diff > 200 LOC tests utils

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants