1
0
mirror of https://github.com/huggingface/diffusers.git synced 2026-10-24 20:59:27 +03:00
Commit Graph

21 Commits

Author SHA1 Message Date
Sayak Paul
d77d530445 [torchao]: fix how FqnConfig is resolved and handled (#14686)
* fix: how fqnconfig passed to torchaoconfig is resolved.

* testing with quantize_()

* change torchao version in setup.py as well.
2026-09-15 22:01:21 +03:00
Sayak Paul
daad99a04a [tests] remove quanto tests. (#14254)
* remove quanto tests.

* deprecate quanto and remove tests
2026-08-27 13:59:40 +05:30
Sayak Paul
0aa743c08d [tests] migrate lora tests for pipelines to use new mixins (#14268)
* start migrating lora tests.

* massive refactor.

* up

* remove planning doc

* address review: tighten lora bias tests

* move run_pipe()

* collapse.

* up

* done

* update

* only use diffusers api contract in tests.

* fix: pass tmp_path through AuraFlow test_lora_B_bias override

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
2026-08-20 17:19:50 +05:30
Sayak Paul
425b113c21 [tests] refactor pipeline-level quantization tests (#14435)
* fix(torchao): route root-level tensors around safetensors reconstruction

Models with parameters at the root of the module tree (e.g. Wan's
`scale_shift_table`) crashed torchao's `unflatten_tensor_state_dict`
when loading serialized checkpoints, since flattened tensor names are
assumed to carry a module prefix. Filter such tensors and their
metadata entries out of the reconstruction and merge them back
unchanged.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* fix(bnb): defer 8-bit weights split from their SCB stats across shards

Sharded serialization can place an 8-bit weight and its `SCB`
statistics in different shard files, in which case the shard-by-shard
loader failed with "Missing quantization component `SCB`". Hold the
incomplete half of the pair back until its counterpart arrives with a
later shard, mirroring the torchao pending mechanism, and disable
parallel shard loading for prequantized 8-bit checkpoints.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* [tests] extend model-level quantization tester mixins

Migrate remaining model-level coverage from tests/quantization into the
tester mixins so it runs for every wired model:

- base: buffer-placement assertions in the device-map test, and an
  opt-in sharded-serialization test enabled by setting
  `sharded_serialization_config`
- bnb: serialization across all configs (sharded included), dtype
  assignment and adapter training for 8-bit, device moves preserving
  the memory footprint, corrupted-state-dict loading error, and a fixed
  modules-to-not-convert test (BitsAndBytesConfig only exposes
  llm_int8_skip_modules; the old test passed an unsupported kwarg and
  only survived by being skipped)
- torchao: custom device maps with cpu/disk offload, generalized from
  the Flux-specific test
- gguf: the diffusers-format single-file loading path, wired into the
  Flux model tests

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* [tests] fix model-level quantization test wiring

- SD3.5: the quantized testers reused the random-init dummy inputs
  (4 latent channels, fp32) while the tiny Hub checkpoint has
  in_channels=8 and the quantizers load the model in half precision;
  give them matching inputs and relax the 4-bit memory expectation for
  the tiny checkpoint.
- QwenImage / Flux2: the quantized testers had no Hub checkpoint wired
  at all, so every test errored; point them at
  hf-internal-testing/tiny-qwenimage-pipe and tiny-flux2 with matching
  inputs.
- NucleusMoE: no tiny checkpoint exists on the Hub yet; comment the
  testers out like the LTX ones.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* [tests] split tests/quantization into pipeline-level and backend-level tiers

Pipeline-level quantization tests (pipeline quality slices, cpu offload,
LoRA loading, compile, PipelineQuantizationConfig) move to
tests/pipelines/testing_utils/quantization.py, marked per backend so the
nightly CI can select them with `pytest -m`. tests/quantization keeps
only backend-level tests that fit neither tier: config validation,
utility warnings, and GGUF CUDA kernel correctness. Tests already
covered by the model-level mixins are dropped.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* [ci] select nightly quantization tests by marker across test tiers

Each backend job now runs `pytest -m <marker>` over tests/models,
tests/quantization, and tests/pipelines/testing_utils/quantization.py,
giving the model-level mixin tests a nightly home with the backend
dependencies installed. The torchao job additionally installs mslk.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

---------

Co-authored-by: sayak@huggingface.co <sayak@ip-10-53-90-45.ec2.internal>
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
2026-08-18 20:53:32 +02:00
Sayak Paul
50e7158093 [tests] fix torchao tests (#14258)
fix torchao tests

Co-authored-by: dg845 <58458699+dg845@users.noreply.github.com>
2026-08-07 20:10:08 +08:00
Sayak Paul
8a29f3139a [tests] standardize model-level quant tests (#14332)
standardize model-level quant tests
2026-08-01 07:53:56 +07:00
Álvaro Somoza
8b33b47332 [quantization] SDNQ core loading (#14277)
* initial

* fix code quality

* dependency test fix

* apply review suggestions

* add extras and version check

* fix gating and prefer local cache for modular

* simplify transformers registration and make the version warning silenceable

* remove pipeline level test

* only model level testing

* layers to quantizze, change em dashes

* env flag for transformers

---------

Co-authored-by: Sayak Paul <spsayakpaul@gmail.com>
2026-07-30 13:09:11 +05:30
Sayak Paul
3c468926ff [tests] unify keep_in_32 tests in quantization test suites (#14257)
unify keep_in_32 tests in quantization test suites
2026-07-30 07:50:09 +05:30
Vinh H. Pham
60ec6f7242 Add Nunchaku Lite single-file quantization (#14100)
* Add Nunchaku Lite single-file quantization

* Support config-backed Nunchaku Lite loading

* Remove Nunchaku runtime manifest metadata loading

* Simplify Nunchaku compact config loading

* Add Nunchaku Lite quantization tests

* Document Nunchaku Lite checkpoint loading

* Refine Nunchaku Lite quantization docs

* Remove unused Nunchaku smooth factor original weights

* Update docs/source/en/quantization/nunchaku.md

Co-authored-by: sergereview[bot] <283583894+sergereview[bot]@users.noreply.github.com>

* Update src/diffusers/quantizers/nunchaku/utils.py

Co-authored-by: sergereview[bot] <283583894+sergereview[bot]@users.noreply.github.com>

* Update src/diffusers/quantizers/nunchaku/nunchaku_quantizer.py

Co-authored-by: sergereview[bot] <283583894+sergereview[bot]@users.noreply.github.com>

* Address Nunchaku Lite review feedback

* Update Nunchaku Lite quantizer

* Rename Nunchaku Lite fp4 precision to nvfp4

* Allow torch_dtype to override Nunchaku compute dtype

* Keep Nunchaku replacement modules on meta during loading

* Require kernels when importing Nunchaku runtime utils

* Use kernels requirement decorators for Nunchaku tests

* Validate Nunchaku CUDA capability requirements

* Apply suggestions from code review

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

* docs: update nunchaku quantization guide

* test: remove nunchaku quantization tests

* fix: reject hopper for nunchaku lite

* Apply suggestion from @rootonchair

* docs: update nunchaku lite compile example

* Apply style fixes

* Apply suggestions from code review

Co-authored-by: Steven Liu <59462357+stevhliu@users.noreply.github.com>
Co-authored-by: Vinh H. Pham  <phamvinh257@gmail.com>

* update doc to be more reasonable

* fix import that requires kernels

---------

Co-authored-by: sergereview[bot] <283583894+sergereview[bot]@users.noreply.github.com>
Co-authored-by: Sayak Paul <spsayakpaul@gmail.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: Steven Liu <59462357+stevhliu@users.noreply.github.com>
2026-07-14 10:09:08 +05:30
Sayak Paul
5f33428194 update licensing for others to 2026. (#14128)
Co-authored-by: dg845 <58458699+dg845@users.noreply.github.com>
2026-07-08 07:40:20 +05:30
hlky
0b838125b9 Incorporate safetensors support to TorchAO (#13719)
* Incorporate safetensors support to TorchAO

* Address TorchAO safetensors review comments

* Address TorchAO safetensors review feedback

* Address follow-up TorchAO review feedback

* Simplify TorchAO metadata loading guard

* Address TorchAO test utility review feedback

* Scope TorchAO safetensors to quantizer hooks

* Use tensor assertion helper in TorchAO tests

* ruff

---------

Co-authored-by: Dhruv Nair <dhruv.nair@gmail.com>
Co-authored-by: Sayak Paul <spsayakpaul@gmail.com>
2026-06-12 10:01:38 +05:30
Xin He
c31bb1c148 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>
2026-06-10 11:41:18 +05:30
jiqing-feng
907c0c2c76 Implement _dequantize for TorchAO quantizer (#13538)
* Implement _dequantize for TorchAO quantizer

- Add _dequantize() method in TorchAoHfQuantizer that dequantizes
  TorchAOBaseTensor weights back to standard nn.Parameter
- Fix _verify_if_layer_quantized to check isinstance(weight, TorchAOBaseTensor)
  so dequantized layers are correctly detected as non-quantized

* enable dequantize for TorchAO tester mixin

Signed-off-by: jiqing-feng <jiqing.feng@intel.com>

* check dequantize

Signed-off-by: jiqing-feng <jiqing.feng@intel.com>

* fix dequantize: clear is_quantized flag and cast dtype after dequantize

* fix

Signed-off-by: jiqing-feng <jiqing.feng@intel.com>

* fix error report

Signed-off-by: jiqing-feng <jiqing.feng@intel.com>

---------

Signed-off-by: jiqing-feng <jiqing.feng@intel.com>
Co-authored-by: Sayak Paul <spsayakpaul@gmail.com>
2026-05-18 18:39:50 +05:30
jiqing-feng
2f4a7177f0 Fix training gradient underflow in quantization tests (#13539)
* Fix training gradient underflow in quantization tests

Change autocast dtype from float16 to bfloat16 in _test_quantization_training.
Float16's limited dynamic range causes gradients to underflow to zero when
passing through quantized tensor subclass operations.

* fix autocast dtype check

Signed-off-by: jiqing-feng <jiqing.feng@intel.com>

---------

Signed-off-by: jiqing-feng <jiqing.feng@intel.com>
Co-authored-by: Sayak Paul <spsayakpaul@gmail.com>
2026-05-18 15:20:07 +05:30
Sayak Paul
5fd27277b8 [tests] fix bitsandbytes compile tests for flux. (#13750)
fix bitsandbytes compile tests for flux.
2026-05-15 14:24:15 +09:00
jiqing-feng
8ee10d8536 Enable TorchAO int4wo quantization tests on XPU (#13537)
* Enable TorchAO int4wo quantization tests on XPU

- Remove _int4wo_skip marker that restricted int4wo tests to CUDA only
- Add XPU-specific int4_packing_format='plain_int32' for Int4WeightOnlyConfig

* add xpu to not skip

Signed-off-by: jiqing-feng <jiqing.feng@intel.com>

* Apply style fixes

---------

Signed-off-by: jiqing-feng <jiqing.feng@intel.com>
Co-authored-by: Sayak Paul <spsayakpaul@gmail.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2026-05-06 12:31:49 +09:00
Dhruv Nair
50987b1290 [CI] Fix BnB tests (#13481)
* update

* update

* update
2026-04-22 13:19:32 +05:30
Howard Zhang
1fe2125802 remove str option for quantization config in torchao (#13291)
* remove str option for quantization config in torchao

* Apply style fixes

* minor fixes

* Added AOBaseConfig docs to torchao.md

* minor fixes for removing str option torchao

* minor change to add back int and uint check

* minor fixes

* minor fixes to tests

* Update tests/quantization/torchao/test_torchao.py

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

* Update docs/source/en/quantization/torchao.md

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

* Update tests/quantization/torchao/test_torchao.py

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

* version=2 update to test_torchao.py

---------

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: Sayak Paul <spsayakpaul@gmail.com>
2026-03-27 08:52:37 +05:30
Sayak Paul
35086ac06a [core] support device type device_maps to work with offloading. (#12811)
* support device type device_maps to work with offloading.

* add tests.

* fix tests

* skip tests where it's not supported.

* empty

* up

* up

* fix allegro.
2026-02-16 16:31:45 +05:30
Dhruv Nair
c3a4cd14b8 [CI] Refactor Wan Model Tests (#13082)
* update

* update

* update

* update

* update

* update

* update

* update
2026-02-11 14:42:58 +05:30
Dhruv Nair
0b76728e27 Refactor Model Tests (#12822)
* update

* update

* update

* update

* update

* update

* update

* update

* update

* update

* update

* update

* update

* update

* update

* update

* update

* update

* update

* update

* update

* update

* update

* update

* update

* update

---------

Co-authored-by: Sayak Paul <spsayakpaul@gmail.com>
2026-02-02 18:51:44 +05:30