1
0
mirror of https://github.com/huggingface/diffusers.git synced 2026-10-23 09:09:01 +03:00
Commit Graph

191 Commits

Author SHA1 Message Date
BeyondBirthday07
5ff8e59ff9 Fix LoRA loading for flattened CLIP text encoders (#14872)
Co-authored-by: Aznix07 <sruhilmodi13@gmail.com>
Co-authored-by: Sayak Paul <spsayakpaul@gmail.com>
2026-09-28 19:47:16 +05:30
Sayak Paul
d30c748f5f tests: add lora tester mixin for modular and migrate minimax h3. (#14605)
* tests: add lora tester mixin for modular and migrate minimax h3.

* enable lora testing modular ci.

* remove seed.

* up
2026-09-09 07:59:46 +02:00
Akshan Krithick
a8c33fe99f refactor lumina2 pipeline tests to the new mixin structure (#14629)
* refactor lumina2 pipeline tests to the new mixin structure

* move lumina2 lora tests to the pipeline-level mixins

---------

Co-authored-by: Sayak Paul <spsayakpaul@gmail.com>
2026-08-28 10:14:37 +05:30
Akshan Krithick
741c7d0c60 migrate ideogram4 lora tests to the pipeline-level mixins (#14628)
Co-authored-by: Sayak Paul <spsayakpaul@gmail.com>
2026-08-28 09:43:17 +05:30
Sayak Paul
df07532b39 tests: migrate tests from tests/lora (#14559)
* tests: migrate tests from tests/lora

* up
2026-08-27 15:08:42 +05:30
Sayak Paul
2371082217 [tests] refactor sdxl tests. (#14619)
refactor sdxl tests.
2026-08-27 13:30:12 +05:30
Sayak Paul
3d8d2e7218 [tests] refactor zimage and krea2 pipeline tests (#14563)
* refactor zimage and krea2 pipeline tests

* remove group offloading skip and propaget the refactors to the rest of zimage

* add negative prompt

---------

Co-authored-by: dg845 <58458699+dg845@users.noreply.github.com>
2026-08-27 13:29:56 +05:30
Akshan Krithick
913ab2281a migrate wan lora tests to the pipeline-level mixins (#14613)
Co-authored-by: Sayak Paul <spsayakpaul@gmail.com>
2026-08-27 12:31:17 +05:30
Akshan Krithick
c14a1e80ec migrate wan vace lora tests to the pipeline-level mixins (#14614)
Co-authored-by: Sayak Paul <spsayakpaul@gmail.com>
2026-08-27 10:11:34 +05:30
Sayak Paul
276ac2f8c4 [tests] migrate flux2 lora. (#14610)
migrate flux2 lora.
2026-08-27 10:11:28 +05:30
Akshan Krithick
20dc622fea migrate cogvideox lora tests to the pipeline-level mixins (#14615)
Co-authored-by: Sayak Paul <spsayakpaul@gmail.com>
2026-08-27 10:03:10 +05:30
Sayak Paul
d57cecde92 [tests] migrate acestep, auraflow, cogview4, and helios tests (#14582)
* migrate acestep, auraflow, cogview4, and helios tests

* fixes
2026-08-26 14:59:16 +05:30
Sayak Paul
34d989f7ef [tests] hunyuan, ltx, ltx2 (#14587)
hunyuan, ltx, ltx2
2026-08-25 20:39:05 +05:30
Sayak Paul
a949d3dd90 [tests] refactor flux control lora tests (#14557)
* refactor flux control lora tests

* change layout

---------

Co-authored-by: dg845 <58458699+dg845@users.noreply.github.com>
2026-08-25 09:26:17 +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
apolinário
8c3dcd6da1 Add LoRA loading support for MiniMax-H3 (#14408)
* Add LoRA support for MiniMax-H3

* Address review: Copied-from loader, LoRA badge, docstring caveats, drop generic scale test

* Move the MiniMax-H3 LoRA tests to tests/lora

* Support the remaining published MiniMax-H3 LoRA layouts

Three more published H3 LoRAs did not load. Two were key-layout gaps and the
third was the reason neither was noticed: a layout that reaches no module at
all used to return without an exception.

- musubi-tuner writes one flattened `lora_unet_` name per module. It is
  un-flattened against the H3 module vocabulary, since `qkv_proj`,
  `token_refiner`, `final_layer` and the output heads carry underscores that
  are not path separators, and then goes through the existing kohya path.
- one producer publishes its own converter's output: diffusers module names
  with peft's `.default.` infix left in and no component prefix. The infix is
  dropped and the prefix added.
- a state dict that filters to nothing in both partitions now warns instead of
  loading as a silent no-op, in the wording `load_lora_adapter` uses for the same
  situation.

A fourth loaded, but at the wrong strength. One producer ships no `.alpha` scalars
and records the alpha it trained with in the file's own `__metadata__` instead,
under `alpha`. Its 8-step turbo LoRA pairs that entry's 8 with rank 128, an
effective scale of 0.0625, so synthesizing `alpha == rank` applied the adapter 16x
too strong. That entry is now read as the uniform network alpha. Per-module scalars
still win when a file carries both, since the converter has already folded them into
the weights, and a non-numeric value is warned about and ignored. `__metadata__` only
exists on a file, so `_fetch_state_dict` hands it back on request.

* Simplify the MiniMax-H3 LoRA comments

* Trim the MiniMax-H3 LoRA tests to loading and effectiveness

* Reference the alpha convention in the MiniMax-H3 LoRA docstring

* Drop a redundant format comment

* Test only diffusers-written state dicts

* Rely on get_peft_kwargs for alpha-less files

* Drop the peft version guards after the main cleanup

---------

Co-authored-by: Sayak Paul <spsayakpaul@gmail.com>
2026-08-14 09:50:12 +02:00
apolinário
90c0ffdc04 🚨 Give mixed-rank LoRAs without alpha keys their intended scale (#14409)
Give mixed-rank LoRAs without alpha keys their intended scale

Co-authored-by: Sayak Paul <spsayakpaul@gmail.com>
2026-08-10 18:27:11 +02:00
Sayak Paul
f6e1c4d1e7 [tests] guard peft imports in test_lora_loader_utils (#14434)
The Hub staging-tests job runs `pytest -m "is_staging_test" tests`, which
imports every test module at collection time, but that job doesn't install
peft. The top-level `from peft import ...` added in #14385 therefore breaks
collection with exit code 2 on every PR.

Guard the imports behind `is_peft_available()` (as `tests/lora/utils.py`
already does) and mark the one test that needs them with
`require_peft_backend`.

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-10 10:40:24 +02:00
Aloys Jehwin
d6726f38a0 fix(lora): only drop adapter from _merged_adapters when unfused from all components (#14385)
* fix(lora): only drop adapter from _merged_adapters when unfused from all components

Signed-off-by: Aloys Jehwin <aloysjehwin@gmail.com>

* test(lora): add regression test for unfuse_lora partial component sync

Signed-off-by: Aloys Jehwin <aloysjehwin@gmail.com>

* test(lora): keep regression test in test_lora_loader_utils.py (standalone unit)

Signed-off-by: Aloys Jehwin <aloysjehwin@gmail.com>

* fix(lora): address review — use isinstance, shorten comment, fix imports

Signed-off-by: Aloys Jehwin <aloysjehwin@gmail.com>

* fix: restore tests/lora/utils.py to main (remove stray trailing newline)

Signed-off-by: Aloys Jehwin <aloysjehwin@gmail.com>

* Apply style fixes

---------

Signed-off-by: Aloys Jehwin <aloysjehwin@gmail.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2026-08-08 11:21:15 +05:30
Chenyang Zhu
9f6fc2c136 Add ace step lora support (#14193)
* feat: add LoRA support to AceStepPipeline

Add standard diffusers LoRA API (load_lora_weights, set_adapters,
fuse_lora, save_lora_weights) for AceStepPipeline, targeting the
transformer (AceStepTransformer1DModel) only.

Includes automatic conversion of ACE-Step-1.5 original PEFT format
LoRA weights (q_proj/k_proj/v_proj/o_proj naming) to diffusers format
(to_q/to_k/to_v/to_out.0 naming) during loading.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* fix: use HuggingFace Hub ID for tokenizer in AceStep LoRA test and apply ruff formatting

- Replace hardcoded local path with "Qwen/Qwen3-Embedding-0.6B" so tests
  run on CI
- Apply ruff formatting fix (slice spacing)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* fix: override test_lora_fuse_nan instead of skipping it

The base test hardcodes block attribute names (transformer_blocks,
blocks, etc.) but AceStep uses 'layers'. Override with AceStep-specific
block access path instead of skipping.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* feat: add joint_attention_kwargs to AceStepPipeline for per-step LoRA scale

- Add @apply_lora_scale("joint_attention_kwargs") decorator and
  joint_attention_kwargs param to AceStepTransformer1DModel.forward
- Add joint_attention_kwargs param to AceStepPipeline.__call__ and wire
  it through to all three transformer calls
- Un-skip 4 LoRA scale tests that now pass (39 passed, 13 skipped)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* fix: override test_lora_fuse_nan instead of skipping it

The base test hardcodes block attribute names (transformer_blocks,
blocks, etc.) but AceStep uses 'layers'. Override with AceStep-specific
block access path instead of skipping.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* feat: add joint_attention_kwargs to AceStepPipeline for per-step LoRA scale

- Add @apply_lora_scale("joint_attention_kwargs") decorator and
  joint_attention_kwargs param to AceStepTransformer1DModel.forward
- Add joint_attention_kwargs param to AceStepPipeline.__call__ and wire
  it through to all three transformer calls
- Un-skip 4 LoRA scale tests that now pass (39 passed, 13 skipped)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* refactor: use attention_kwargs instead of joint_attention_kwargs, use torch_device in test

- Rename joint_attention_kwargs to attention_kwargs in transformer
  forward and pipeline __call__ for consistency with the diffusers
  naming convention for new pipelines
- Add docstring for the attention_kwargs parameter
- Use torch_device instead of hardcoded "cpu" in test_lora_fuse_nan

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* Apply style fixes

* docs: document ACE-Step attention kwargs

* docs: document ACE-Step LoRA loader mixin

---------

Co-authored-by: zcy <zhuchenyang.zcy@alibaba-inc.com>
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-authored-by: Sayak Paul <spsayakpaul@gmail.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2026-07-18 15:03:55 +05:30
Yaroslav Romanenko
cca8af298f Fix local LoRA weight auto-discovery in offline mode (#14204)
* Allow local LoRA discovery in offline mode

* Use pytest fixtures for LoRA loader tests
2026-07-16 15:33:42 +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
GiGi Koneti
f09adee565 [Tests] Skip layerwise casting tests on devices without float8_e4m3fn support (#14073)
* Skip layerwise casting tests on devices without float8_e4m3fn support

* Xfail float8 layerwise casting tests on MPS

---------

Co-authored-by: Sayak Paul <spsayakpaul@gmail.com>
2026-06-29 06:38:00 -07:00
apolinário
3993de59e3 Krea 2 LoRA DreamBooth trainer (#14046)
* Add Krea 2 LoRA DreamBooth trainer + Krea2 LoRA loader

Adds examples/dreambooth/train_dreambooth_lora_krea2.py and the
Krea2LoraLoaderMixin (Krea2Pipeline now inherits it) so LoRA adapters
can be saved/loaded for the Krea 2 transformer. The transformer/pipeline
forward now accept attention_kwargs for runtime LoRA scaling.

Co-Authored-By: linoytsaban <linoy.tsaban@gmail.com>

* inline _pack/_unpack_latents in trainer (pipeline methods are instance methods)

* add Krea2LoraLoaderMixin to LoRA loaders docs

* remove mu from validation call to align with pipeline on main

---------

Co-authored-by: linoytsaban <linoy.tsaban@gmail.com>
Co-authored-by: Linoy Tsaban <57615435+linoytsaban@users.noreply.github.com>
2026-06-23 17:39:27 +05:30
Linoy Tsaban
3467efa65a Add Ideogram4LoraLoaderMixin (LoRA loading for Ideogram4) (#13921)
* add Ideogram4LoraLoaderMixin

* Support loading non-diffusers Ideogram4 LoRA checkpoints (#13919)

support loading non-diffusers Ideogram4 LoRAs

* add Ideogram4 LoRA loader tests

* support call-time LoRA scaling via attention_kwargs in Ideogram4

* fix and un-skip Ideogram4 LoRA loader tests

* document attention_kwargs in Ideogram4 forward and pipeline

* style Ideogram4 attention_kwargs docstrings

* fix Ideogram4 LoRA loader CI test failures

- pipeline: run the text encoder on its parameters' current device, then
  move features to the execution device, so encode_prompt works under
  enable_model_cpu_offload. The pipeline calls the text encoder's submodules
  directly to tap intermediate layers, which bypasses accelerate's onload
  hook, so the weights stay on CPU while inputs are on the execution device.
  Fixes test_lora_loading_model_cpu_offload.
- tests: override test_lora_fuse_nan to corrupt a weight under Ideogram4's
  `layers` tower (the base test probes transformer_blocks/blocks/etc.).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* address review nits on Ideogram4 LoRA loader

- pipeline: clarify the te_device comment (per review) — explain the CpuOffload hook
  attaches to forward, why submodule calls bypass it, and that te_device is the offload
  device under enable_model_cpu_offload.
- tests: drop the unused `import sys` and `sys.path.append(".")`.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-authored-by: Sayak Paul <spsayakpaul@gmail.com>
Co-authored-by: dg845 <58458699+dg845@users.noreply.github.com>
2026-06-17 17:39:52 +03:00
Sayak Paul
68a4847768 [tests] fix lora checkpoint serialization issues (#13676)
* fix save load text encoder lora inference

* fix rest

* fix one more.

* fix test_set_adapters_match_attention_kwargs

* fix styling issues.
2026-05-15 16:38:25 +09:00
Sayak Paul
cff1e39f1b [tests] fix lora tests involving clip. (#13675)
fix lora tests involving clip.
2026-05-06 08:23:14 +09:00
Sayak Paul
522b523e40 [ci] hoping to fix is_flaky with wanvace. (#13294)
* hoping to fix is_flaky with wanvace.

* revert changes in src/diffusers/utils/testing_utils.py and propagate them to tests/testing_utils.py.

* up
2026-03-20 16:02:16 +05:30
dg845
33f785b444 Add Helios-14B Video Generation Pipelines (#13208)
* [1/N] add helios

* fix test

* make fix-copies

* change script path

* fix cus script

* update docs

* fix documented check

* update links for docs and examples

* change default config

* small refactor

* add test

* Update src/diffusers/models/transformers/transformer_helios.py

Co-authored-by: YiYi Xu <yixu310@gmail.com>

* remove register_buffer for _scale_cache

* fix non-cuda devices error

* remove "handle the case when timestep is 2D"

* refactor HeliosMultiTermMemoryPatch and process_input_hidden_states

* Update src/diffusers/pipelines/helios/pipeline_helios.py

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

* Update src/diffusers/models/transformers/transformer_helios.py

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

* Update src/diffusers/pipelines/helios/pipeline_helios.py

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

* fix calculate_shift

* Update src/diffusers/pipelines/helios/pipeline_helios.py

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

* rewritten `einops` in pure `torch`

* fix: pass patch_size to apply_schedule_shift instead of hardcoding

* remove the logics of 'vae_decode_type'

* move some validation into check_inputs()

* rename helios scheduler & merge all into one step()

* add some details to doc

* move dmd  step() logics from pipeline to scheduler

* change to Python 3.9+ style type

* fix NoneType error

* refactor DMD scheduler's set_timestep

* change rope related vars name

* fix stage2 sample

* fix dmd sample

* Update src/diffusers/models/transformers/transformer_helios.py

Co-authored-by: YiYi Xu <yixu310@gmail.com>

* Update src/diffusers/models/transformers/transformer_helios.py

Co-authored-by: YiYi Xu <yixu310@gmail.com>

* remove redundant & refactor norm_out

* Update src/diffusers/pipelines/helios/pipeline_helios.py

Co-authored-by: YiYi Xu <yixu310@gmail.com>

* change "is_keep_x0" to "keep_first_frame"

* use a more intuitive name

* refactor dynamic_time_shifting

* remove use_dynamic_shifting args

* remove usage of UniPCMultistepScheduler

* separate stage2 sample to HeliosPyramidPipeline

* Update src/diffusers/models/transformers/transformer_helios.py

Co-authored-by: YiYi Xu <yixu310@gmail.com>

* Update src/diffusers/models/transformers/transformer_helios.py

Co-authored-by: YiYi Xu <yixu310@gmail.com>

* Update src/diffusers/models/transformers/transformer_helios.py

Co-authored-by: YiYi Xu <yixu310@gmail.com>

* Update src/diffusers/models/transformers/transformer_helios.py

Co-authored-by: YiYi Xu <yixu310@gmail.com>

* fix transformer

* use a more intuitive name

* update example script

* fix requirements

* remove redudant attention mask

* fix

* optimize pipelines

* make style .

* update TYPE_CHECKING

* change to use torch.split

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

* derive memory patch sizes from patch_size multiples

* remove some hardcoding

* move some checks into check_inputs

* refactor sample_block_noise

* optimize encoding chunks logits for v2v

* use num_history_latent_frames = sum(history_sizes)

* Update src/diffusers/pipelines/helios/pipeline_helios.py

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

* remove redudant optimized_scale

* Update src/diffusers/pipelines/helios/pipeline_helios_pyramid.py

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

* use more descriptive name

* optimize history_latents

* remove not used "num_inference_steps"

* removed redudant "pyramid_num_stages"

* add "is_cfg_zero_star" and "is_distilled" to HeliosPyramidPipeline

* remove redudant

* change example scripts name

* change example scripts name

* correct docs

* update example

* update docs

* Update tests/models/transformers/test_models_transformer_helios.py

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

* Update tests/models/transformers/test_models_transformer_helios.py

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

* separate HeliosDMDScheduler

* fix numerical stability issue:

* Update src/diffusers/schedulers/scheduling_helios_dmd.py

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

* Update src/diffusers/schedulers/scheduling_helios_dmd.py

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

* Update src/diffusers/schedulers/scheduling_helios_dmd.py

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

* Update src/diffusers/schedulers/scheduling_helios_dmd.py

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

* Update src/diffusers/schedulers/scheduling_helios_dmd.py

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

* remove redudant

* small refactor

* remove use_interpolate_prompt logits

* simplified model test

* fallbackt to BaseModelTesterConfig

* remove _maybe_expand_t2v_lora_for_i2v

* fix HeliosLoraLoaderMixin

* update docs

* use randn_tensor for test

* fix doc typo

* optimize code

* mark torch.compile xfail

* change paper name

* Make get_dummy_inputs deterministic using self.generator

* Set less strict threshold for test_save_load_float16 test for Helios pipeline

* make style and make quality

* Preparation for merging

* add torch.Generator

* Fix HeliosPipelineOutput doc path

* Fix Helios related (optimize docs & remove redudant) (#13210)

* fix docs

* remove redudant

* remove redudant

* fix group offload

* Removed fixes for group offload

---------

Co-authored-by: yuanshenghai <yuanshenghai@bytedance.com>
Co-authored-by: Shenghai Yuan <140951558+SHYuanBest@users.noreply.github.com>
Co-authored-by: YiYi Xu <yixu310@gmail.com>
Co-authored-by: SHYuanBest <shyuan-cs@hotmail.com>
Co-authored-by: Sayak Paul <spsayakpaul@gmail.com>
2026-03-04 21:31:43 +05:30
Sayak Paul
2843b3d37a Sunset Python 3.8 & get rid of explicit typing exports where possible (#12524)
* drop python 3.8

* remove list, tuple, dict from typing

* fold Unions into |

* up

* fix a bunch and please me.

* up

* up

* up

* up

* up

* up

* enforce 3.10.0.

* up

* up

* up

* up

* up

* up

* up

* up

* Update setup.py

Co-authored-by: Dhruv Nair <dhruv.nair@gmail.com>

* up.

* python 3.10.

* ifx

* up

* up

* up

* up

* final

* up

* fix typing utils.

* up

* up

* up

* up

* up

* up

* fix

* up

* up

* up

* up

* up

* up

* handle modern types.

* up

* up

* fix ip adapter type checking.

* up

* up

* up

* up

* up

* up

* up

* revert docstring changes.

* keep deleted files deleted.

* keep deleted files deleted.

---------

Co-authored-by: Dhruv Nair <dhruv.nair@gmail.com>
2026-02-13 18:16:51 +05:30
dg845
f1a93c765f Add Flag to PeftLoraLoaderMixinTests to Enable/Disable Text Encoder LoRA Tests (#12962)
* Improve incorrect LoRA format error message

* Add flag in PeftLoraLoaderMixinTests to disable text encoder LoRA tests

* Apply changes to LTX2LoraTests

* Further improve incorrect LoRA format error msg following review

---------

Co-authored-by: Sayak Paul <spsayakpaul@gmail.com>
2026-01-12 16:01:58 -08:00
Sayak Paul
ed6e5ecf67 [LoRA] add LoRA support to LTX-2 (#12933)
* up

* fixes

* tests

* docs.

* fix

* change loading info.

* up

* up
2026-01-10 11:27:22 +05:30
Sayak Paul
a1f36ee3ef [Z-Image] various small changes, Z-Image transformer tests, etc. (#12741)
* start zimage model tests.

* up

* up

* up

* up

* up

* up

* up

* up

* up

* up

* up

* up

* Revert "up"

This reverts commit bca3e27c96.

* expand upon compilation failure reason.

* Update tests/models/transformers/test_models_transformer_z_image.py

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

* reinitialize the padding tokens to ones to prevent NaN problems.

* updates

* up

* skipping ZImage DiT tests

* up

* up

---------

Co-authored-by: dg845 <58458699+dg845@users.noreply.github.com>
2025-12-03 19:35:46 +05:30
Aditya Borate
5ab5946931 Fix: leaf_level offloading breaks after delete_adapters (#12639)
* Fix(peft): Re-apply group offloading after deleting adapters

* Test: Add regression test for group offloading + delete_adapters

* Test: Add assertions to verify output changes after deletion

* Test: Add try/finally to clean up group offloading hooks

---------

Co-authored-by: Sayak Paul <spsayakpaul@gmail.com>
2025-12-03 17:39:11 +05:30
CalamitousFelicitousness
edf36f5128 Add ZImage LoRA support and integrate into ZImagePipeline (#12750)
* Add ZImage LoRA support and integrate into ZImagePipeline

* Add LoRA test for Z-Image

* Move the LoRA test

* Fix ZImage LoRA scale support and test configuration

* Add ZImage LoRA test overrides for architecture differences

- Override test_lora_fuse_nan to use ZImage's 'layers' attribute
  instead of 'transformer_blocks'
- Skip block-level LoRA scaling test (not supported in ZImage)
- Add required imports: numpy, torch_device, check_if_lora_correctly_set

* Add ZImageLoraLoaderMixin to LoRA documentation

* Use conditional import for peft.LoraConfig in ZImage tests

* Override test_correct_lora_configs_with_different_ranks for ZImage

ZImage uses 'attention.to_k' naming convention instead of 'attn.to_k',
so the base test's module name search loop never finds a match. This
override uses the correct naming pattern for ZImage architecture.

* Add is_flaky decorator to ZImage LoRA tests initialise padding tokens

* Skip ZImage LoRA test class entirely

Skip the entire ZImageLoRATests class due to non-deterministic behavior
from complex64 RoPE operations and torch.empty padding tokens.
LoRA functionality works correctly with real models.

Clean up removed:
- Individual @unittest.skip decorators
- @is_flaky decorator overrides for inherited methods
- Custom test method overrides
- Global torch deterministic settings
- Unused imports (numpy, is_flaky, check_if_lora_correctly_set)

---------

Co-authored-by: Sayak Paul <spsayakpaul@gmail.com>
Co-authored-by: Álvaro Somoza <asomoza@users.noreply.github.com>
2025-12-02 02:16:30 -03:00
Sayak Paul
b91e8c0d0b [lora]: Fix Flux2 LoRA NaN test (#12714)
* up

* Update tests/lora/test_lora_layers_flux2.py

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

---------

Co-authored-by: dg845 <58458699+dg845@users.noreply.github.com>
2025-11-26 09:07:48 +05:30
Sayak Paul
5ffb73d4ae let's go Flux2 🚀 (#12711)
* add vae

* Initial commit for Flux 2 Transformer implementation

* add pipeline part

* small edits to the pipeline and conversion

* update conversion script

* fix

* up up

* finish pipeline

* Remove Flux IP Adapter logic for now

* Remove deprecated 3D id logic

* Remove ControlNet logic for now

* Add link to ViT-22B paper as reference for parallel transformer blocks such as the Flux 2 single stream block

* update pipeline

* Don't use biases for input projs and output AdaNorm

* up

* Remove bias for double stream block text QKV projections

* Add script to convert Flux 2 transformer to diffusers

* make style and make quality

* fix a few things.

* allow sft files to go.

* fix image processor

* fix batch

* style a bit

* Fix some bugs in Flux 2 transformer implementation

* Fix dummy input preparation and fix some test bugs

* fix dtype casting in timestep guidance module.

* resolve conflicts.,

* remove ip adapter stuff.

* Fix Flux 2 transformer consistency test

* Fix bug in Flux2TransformerBlock (double stream block)

* Get remaining Flux 2 transformer tests passing

* make style; make quality; make fix-copies

* remove stuff.

* fix type annotaton.

* remove unneeded stuff from tests

* tests

* up

* up

* add sf support

* Remove unused IP Adapter and ControlNet logic from transformer (#9)

* copied from

* Apply suggestions from code review

Co-authored-by: YiYi Xu <yixu310@gmail.com>
Co-authored-by: apolinário <joaopaulo.passos@gmail.com>

* up

* up

* up

* up

* up

* Refactor Flux2Attention into separate classes for double stream and single stream attention

* Add _supports_qkv_fusion to AttentionModuleMixin to allow subclasses to disable QKV fusion

* Have Flux2ParallelSelfAttention inherit from AttentionModuleMixin with _supports_qkv_fusion=False

* Log debug message when calling fuse_projections on a AttentionModuleMixin subclass that does not support QKV fusion

* Address review comments

* Update src/diffusers/pipelines/flux2/pipeline_flux2.py

Co-authored-by: YiYi Xu <yixu310@gmail.com>

* up

* Remove maybe_allow_in_graph decorators for Flux 2 transformer blocks (#12)

* up

* support ostris loras. (#13)

* up

* update schdule

* up

* up (#17)

* add training scripts (#16)

* add training scripts

Co-authored-by: Linoy Tsaban <linoytsaban@gmail.com>

* model cpu offload in validation.

* add flux.2 readme

* add img2img and tests

* cpu offload in log validation

* Apply suggestions from code review

* fix

* up

* fixes

* remove i2i training tests for now.

---------

Co-authored-by: Linoy Tsaban <linoytsaban@gmail.com>
Co-authored-by: linoytsaban <linoy@huggingface.co>

* up

---------

Co-authored-by: yiyixuxu <yixu310@gmail.com>
Co-authored-by: Daniel Gu <dgu8957@gmail.com>
Co-authored-by: yiyi@huggingface.co <yiyi@ip-10-53-87-203.ec2.internal>
Co-authored-by: dg845 <58458699+dg845@users.noreply.github.com>
Co-authored-by: Dhruv Nair <dhruv.nair@gmail.com>
Co-authored-by: apolinário <joaopaulo.passos@gmail.com>
Co-authored-by: yiyi@huggingface.co <yiyi@ip-26-0-160-103.ec2.internal>
Co-authored-by: Linoy Tsaban <linoytsaban@gmail.com>
Co-authored-by: linoytsaban <linoy@huggingface.co>
2025-11-25 21:49:04 +05:30
Sayak Paul
55d49d4379 [ci] don't run sana layerwise casting tests in CI. (#12551)
* don't run sana layerwise casting tests in CI.

* up
2025-10-28 13:29:51 +05:30
Sayak Paul
814d710e56 [tests] cache non lora pipeline outputs. (#12298)
* cache non lora pipeline outputs.

* up

* up

* up

* up

* Revert "up"

This reverts commit 772c32e433.

* up

* Revert "up"

This reverts commit cca03df7fc.

* up

* up

* add .

* up

* up

* up

* up

* up

* up
2025-10-01 09:02:55 +05:30
Yao Matrix
7a58734994 xpu enabling for 4 cases (#12345)
Signed-off-by: Yao, Matrix <matrix.yao@intel.com>
2025-09-24 09:31:45 +05:30
Sayak Paul
09e777a3e1 [tests] Single scheduler in lora tests (#12315)
* single scheduler please.

* up

* up

* up
2025-09-24 08:36:50 +05:30
Dave Lage
7e7e62c6ff Convert alphas for embedders for sd-scripts to ai toolkit conversion (#12332)
* Convert alphas for embedders for sd-scripts to ai toolkit conversion

* Add kohya embedders conversion test

* Apply style fixes

---------

Co-authored-by: Sayak Paul <spsayakpaul@gmail.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2025-09-18 12:41:22 +05:30
Dhruv Nair
7aa6af1138 [Refactor] Move testing utils out of src (#12238)
* update

* update

* update

* update

* update

* merge main

* Revert "merge main"

This reverts commit 65efbcead5.
2025-08-28 19:53:02 +05:30
Alrott SlimRG
8c48ec05ed Fix bf15/fp16 for pipeline_wan_vace.py (#12143)
* Fix bf15/fp16 for pipeline_wan_vace.py

* Update pipeline_wan_vace.py

* try removing xfail decorator

---------

Co-authored-by: Aryan <aryan@huggingface.co>
2025-08-14 05:04:00 +05:30
Sayak Paul
7b10e4ae65 [tests] device placement for non-denoiser components in group offloading LoRA tests (#12103)
up
2025-08-08 13:34:29 +05:30
Sayak Paul
a8e47978c6 [lora] adapt new LoRA config injection method (#11999)
* use state dict when setting up LoRA.

* up

* up

* up

* comment

* up

* up
2025-08-08 09:22:48 +05:30
Sayak Paul
9c1d4e3be1 [wip] feat: support lora in qwen image and training script (#12056)
* feat: support lora in qwen image and training script

* up

* up

* up

* up

* up

* up

* add lora tests

* fix

* add tests

* fix

* reviewer feedback

* up[

* Apply suggestions from code review

Co-authored-by: Aryan <aryan@huggingface.co>

---------

Co-authored-by: Aryan <aryan@huggingface.co>
2025-08-05 07:06:02 +05:30
Aryan
6f3ac3050f [refactor] some shared parts between hooks + docs (#11968)
* update

* try test fix

* add missing link

* fix tests

* Update src/diffusers/hooks/first_block_cache.py

* make style
2025-07-29 07:44:02 +05:30
Sayak Paul
265840a098 [LoRA] fix: disabling hooks when loading loras. (#11896)
fix: disabling hooks when loading loras.
2025-07-10 10:30:10 +05:30
Sayak Paul
cc1f9a2ce3 [tests] mark the wanvace lora tester flaky (#11883)
* mark wanvace lora tests as flaky

* ability to apply is_flaky at a class-level

* update

* increase max_attempt.

* increase attemtp.
2025-07-09 13:27:15 +05:30