Skip to content

[chore] log quant config to the user_agent#13850

Merged
sayakpaul merged 4 commits into
mainfrom
user-agent-quant-config
Jun 10, 2026
Merged

[chore] log quant config to the user_agent#13850
sayakpaul merged 4 commits into
mainfrom
user-agent-quant-config

Conversation

@sayakpaul

Copy link
Copy Markdown
Member

What does this PR do?

To get finegrained understanding of which quant configs are most used, allow quant configs to also go in user_agent.

Example value:

user_agent['quant_config']='{"modules_to_not_convert": null, "quant_method": "torchao", "quant_type": {"default": {"_data": {"granularity": {"_data": {"dim": -1}, "_type": "PerRow", "_version": 1}, "group_size": null, "set_inductor_config": true}, "_type": "Int8WeightOnlyConfig", "_version": 2}}}'

For:

from diffusers import AutoModel, TorchAoConfig
import torch 
from torchao.quantization import Int8WeightOnlyConfig

model = AutoModel.from_pretrained(
    "black-forest-labs/FLUX.1-dev",
    subfolder="transformer",
    torch_dtype=torch.bfloat16,
    quantization_config=TorchAoConfig(Int8WeightOnlyConfig(group_size=None, version=2))
)

Additionally, also pass the model class to user_agent to better understand which quantization classes are usually used for a particular class of models.

@github-actions github-actions Bot added size/S PR with diff < 50 LOC models labels Jun 1, 2026
@sayakpaul sayakpaul requested a review from SunMarc June 1, 2026 05:09
@HuggingFaceDocBuilderDev

Copy link
Copy Markdown

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

@SunMarc SunMarc left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks a lot !

@sayakpaul sayakpaul merged commit 89512d2 into main Jun 10, 2026
35 of 37 checks passed
@sayakpaul sayakpaul deleted the user-agent-quant-config branch June 10, 2026 05:35
@Disty0

Disty0 commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

This change broke loading of pre-quants.

Changing this line:

user_agent["quant_config"] = json.dumps(quantization_config.to_dict(), sort_keys=True)

To

user_agent["quant_config"] = json.dumps(hf_quantizer.quantization_config.to_dict(), sort_keys=True)

The line above works fine.
Aka using hf_quantizer.quantization_config instead of quantization_config works fine.

Simple reproduction code:

import torch
import diffusers

dit = diffusers.Ideogram4Transformer2DModel.from_pretrained("ideogram-ai/ideogram-4-nf4-diffusers", subfolder="transformer", device_map="cpu", torch_dtype=torch.bfloat16)
print(dit)

Error trace:

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
Cell In[2], line 4
      1 import torch
      2 import diffusers
      3 
----> 4 dit = diffusers.Ideogram4Transformer2DModel.from_pretrained("ideogram-ai/ideogram-4-nf4-diffusers", subfolder="transformer", device_map="cpu", torch_dtype=torch.bfloat16)
      5 print(dit)

File ~/AI/Apps/diffusion-trainer/venv/lib/python3.12/site-packages/huggingface_hub/utils/_validators.py:88, in validate_hf_hub_args.<locals>._inner_fn(*args, **kwargs)
     84         validate_repo_id(arg_value)
     86 kwargs = smoothly_deprecate_legacy_arguments(fn_name=fn.__name__, kwargs=kwargs)
---> 88 return fn(*args, **kwargs)

File ~/AI/Apps/diffusion-trainer/venv/lib/python3.12/site-packages/diffusers/models/modeling_utils.py:1152, in ModelMixin.from_pretrained(cls, pretrained_model_name_or_path, **kwargs)
   1150 # In order to ensure popular quantization methods are supported. Can be disabled with `disable_telemetry`
   1151 user_agent["quant"] = hf_quantizer.quantization_config.quant_method.value
-> 1152 user_agent["quant_config"] = json.dumps(quantization_config.to_dict(), sort_keys=True)
   1154 # Force-set to `True` for more mem efficiency
   1155 if low_cpu_mem_usage is None:

AttributeError: 'NoneType' object has no attribute 'to_dict'

@sayakpaul sayakpaul mentioned this pull request Jun 10, 2026
@sayakpaul

Copy link
Copy Markdown
Member Author

#13906

DN6 pushed a commit that referenced this pull request Jun 10, 2026
log quant config to the user_agent
sayakpaul added a commit that referenced this pull request Jun 16, 2026
* update

* update

* update

* update

* [CI] Refactor SD3 Transformer Test (#13340)

* update

* update

---------

Co-authored-by: Sayak Paul <spsayakpaul@gmail.com>

* refactor unet tests (3d_condition, motion, controlnetxs) (#13897)

* refactor unet_3d_condition tests

* refactor unet_motion tests

* refactor unet_controlnetxs tests

* refactor unet_1d tests (#13898)

* refactor unet_1d tests

* use per-sample output_shape for unet_1d tests

---------

Co-authored-by: Sayak Paul <spsayakpaul@gmail.com>

* refactor unet_2d tests (#13901)

Co-authored-by: Sayak Paul <spsayakpaul@gmail.com>

* [chore] log quant config to the user_agent (#13850)

log quant config to the user_agent

* Integrate AutoRound into Diffusers (#13552)

* support auto_round

Signed-off-by: Xin He <xin3.he@intel.com>

* add document and unit tests

Signed-off-by: Xin He <xin3.he@intel.com>

* fix CI

Signed-off-by: Xin He <xin3.he@intel.com>

* Apply suggestions from code review

Co-authored-by: Steven Liu <59462357+stevhliu@users.noreply.github.com>

* update document and overwrite the default quantization_config with specified backend.

Signed-off-by: Xin He <xin3.he@intel.com>

* add UT and fix bug

Signed-off-by: Xin He <xin3.he@intel.com>

* update per comments

Signed-off-by: Xin He <xin3.he@intel.com>

* update per comments

Signed-off-by: Xin He <xin3.he@intel.com>

* fix compile error in doc

Signed-off-by: Xin He <xin3.he@intel.com>

* Apply style fixes

* small nits

* Add auto_round dependency to the versions table

Signed-off-by: Xin He <xin3.he@intel.com>

* fix make deps_table_check_updated

Signed-off-by: Xin He <xin3.he@intel.com>

* fix CI

Signed-off-by: Xin He <xin3.he@intel.com>

---------

Signed-off-by: Xin He <xin3.he@intel.com>
Co-authored-by: Steven Liu <59462357+stevhliu@users.noreply.github.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: Sayak Paul <spsayakpaul@gmail.com>

* [tests] refactor UNet model tests to align with the new pattern (#13153)

* refactor unet2d condition model tests.

* fix tests

* up

* fix

* Revert "fix"

This reverts commit 46d44b7.

* up

* recompile limit

* [tests] refactor test_models_unet_1d.py to use modular testing mixins

Refactor UNet1D model tests to follow the modern testing pattern using
BaseModelTesterConfig and focused mixin classes (ModelTesterMixin,
MemoryTesterMixin, TrainingTesterMixin, LoraTesterMixin).

Both UNet1D standard and RL variants now have separate config classes
and dedicated test classes organized by concern (core, memory, training,
LoRA, hub loading).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* [tests] refactor test_models_unet_2d.py to use modular testing mixins

Refactor UNet2D model tests (standard, LDM, NCSN++) to follow the
modern testing pattern. Each variant gets its own config class and
dedicated test classes organized by concern (core, memory, training,
LoRA, hub loading).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* [tests] refactor test_models_unet_3d_condition.py to use modular testing mixins

Refactor UNet3DConditionModel tests to follow the modern testing pattern
with separate classes for core, attention, memory, training, and LoRA.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* [tests] refactor test_models_unet_controlnetxs.py to use modular testing mixins

Refactor UNetControlNetXSModel tests to follow the modern testing
pattern with separate classes for core, memory, training, and LoRA.
Specialized tests (from_unet, freeze_unet, forward_no_control,
time_embedding_mixing) remain in the core test class.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* [tests] refactor test_models_unet_spatiotemporal.py to use modular testing mixins

Refactored the spatiotemporal UNet test file to follow the modern modular testing
pattern with BaseModelTesterConfig and focused test classes:

- UNetSpatioTemporalTesterConfig: Base configuration with model setup
- TestUNetSpatioTemporal: Core model tests (ModelTesterMixin, UNetTesterMixin)
- TestUNetSpatioTemporalAttention: Attention-related tests (AttentionTesterMixin)
- TestUNetSpatioTemporalMemory: Memory/offloading tests (MemoryTesterMixin)
- TestUNetSpatioTemporalTraining: Training tests (TrainingTesterMixin)
- TestUNetSpatioTemporalLoRA: LoRA adapter tests (LoraTesterMixin)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* remove test suites that are passed.

* fix consistencydecodervae tests

* Revert "fix consistencydecodervae tests"

This reverts commit 41b036b.

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Co-authored-by: dg845 <58458699+dg845@users.noreply.github.com>

* [tests] fix vidtok tests (#13894)

* fix vidtok tests

* style

* Update tests/models/autoencoders/test_models_autoencoder_vidtok.py

Co-authored-by: dg845 <58458699+dg845@users.noreply.github.com>

* Apply style fixes

---------

Co-authored-by: dg845 <58458699+dg845@users.noreply.github.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>

* clean up

---------

Signed-off-by: Xin He <xin3.he@intel.com>
Co-authored-by: Sayak Paul <spsayakpaul@gmail.com>
Co-authored-by: Akshan Krithick <97239696+akshan-main@users.noreply.github.com>
Co-authored-by: Xin He <xin3.he@intel.com>
Co-authored-by: Steven Liu <59462357+stevhliu@users.noreply.github.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Co-authored-by: dg845 <58458699+dg845@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

models size/S PR with diff < 50 LOC

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants