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

6650 Commits

Author SHA1 Message Date
sayakpaul
a3608b512e Release: v0.39.0-release v0.39.0 2026-07-03 14:15:02 +05:30
Sayak Paul
72eb60c2da [tests] fix test_from_save_pretrained_dtype_inference (#13872)
* fix test_from_save_pretrained_dtype_inference

* fix

* add warning to to()

* address feedback

* fix

* fix

* fix

* logger.debug -> logger.warning

* Update src/diffusers/models/modeling_utils.py

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

* fix

---------

Co-authored-by: Dhruv Nair <dhruv.nair@gmail.com>
2026-07-03 09:16:56 +05:30
Sayak Paul
c4123258d2 diffusers test installation package (#14078) 2026-07-03 08:04:28 +05:30
YiYi Xu
5dc153bc4a support loading pipeline from transformer style (flat) repo (#14096)
* Support root-hosted weights + add _allow_files download hook

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-02 08:04:31 -10:00
Zaid
761d72b19c Fix FA3 varlen wrapper when hub kernel returns single tensor (#14102) 2026-07-02 22:17:50 +05:30
Prakshaale Jain
9159a587b1 Fix mutable default args in lora_base.py (#14064)
Fix mutable default args in LoRA mixin

Co-authored-by: Sayak Paul <spsayakpaul@gmail.com>
2026-07-02 18:36:53 +05:30
dependabot[bot]
dbe1258991 Bump transformers from 4.47.0 to 5.3.0 in /examples/cogview4-control (#14109)
Bumps [transformers](https://github.com/huggingface/transformers) from 4.47.0 to 5.3.0.
- [Release notes](https://github.com/huggingface/transformers/releases)
- [Commits](https://github.com/huggingface/transformers/compare/v4.47.0...v5.3.0)

---
updated-dependencies:
- dependency-name: transformers
  dependency-version: 5.3.0
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-07-02 17:36:11 +05:30
Sayak Paul
0d32f80544 [docs] fix qwen tokenizer in docstrings. (#14098)
* fix qwen tokenizer in docstrings.

* Apply style fixes

---------

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2026-07-02 09:29:49 +05:30
Hz_Zhang
1ffa4236a4 ovis_image: fix guidance_scale / max_sequence_length / batched CFG / precomputed embeds + add pipeline test (#13944)
* ovis_image: fix guidance_scale / max_sequence_length / batched-CFG / precomputed embeds + add pipeline test

Addresses items 3/4/5/6/7 of #13630.

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

* ovis_image: complete pipeline review (#13630)

- thread joint_attention_kwargs through the transformer forward + blocks
  (item 2) and pass it from the pipeline's transformer calls.
- encode_prompt now returns both positive and negative embeds (the z_image /
  PixArt convention) so precomputed embeds work end-to-end and the prompt is
  encoded in a single call.
- switch the pipeline test to the full PipelineTesterMixin.

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

* ovis_image: remove now-unused tokenizer_max_length

The pipeline computes max_length inline from max_sequence_length, so the attribute is dead. Addresses review feedback.

---------

Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
Co-authored-by: dg845 <58458699+dg845@users.noreply.github.com>
2026-07-01 16:15:50 -07:00
apolinário
26ec30e8ad Ideogram4 lora training (#13861)
* Ideogram4 DreamBooth LoRA training

Add examples/dreambooth/train_dreambooth_lora_ideogram4.py + README + requirements:
- DreamBooth LoRA training for Ideogram 4 (flow-matching, dual transformer, Qwen3-VL TE)
- nf4 QLoRA and SDNQ fp8 bases: --do_fp8_training trains the fp8 checkpoint in place
  (scaled matmul), or omit it to dequantize the SDNQ base to bf16
- --disable_training_autocast (Ideogram4's forward is corrupted by autocast)
- structured JSON caption support + --upsample_prompt
- model card with a validation-image gallery

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

* Apply style fixes

* Fix base model repo reference in Ideogram4 LoRA README

* Align Ideogram4 script deps with requirements file

---------

Co-authored-by: linoytsaban <linoy.tsaban@gmail.com>
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-authored-by: dg845 <58458699+dg845@users.noreply.github.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: Linoy Tsaban <57615435+linoytsaban@users.noreply.github.com>
2026-07-01 18:10:33 +03:00
dxqb
6d71b76ace Complete Kohya LoRA conversion for Qwen and Z-Image (#14080)
* Fix Kohya LoRA conversion for Z-Image modules whose names contain underscores

_convert_non_diffusers_z_image_lora_to_diffusers reverses Kohya's `.`->`_`
flattening with a blanket `_`->`.` split, guarded only by a small
protected-n-gram list (attention to_q/k/v/out, feed_forward) plus post-hoc
fixes for context_refiner/noise_refiner. Z-Image's other modules whose names
contain underscores were over-split: all_final_layer, all_x_embedder,
adaLN_modulation, cap_embedder and t_embedder came out as all.final.layer,
adaLN.modulation, ... and failed to load with "unexpected keys".

Extend the existing dot->underscore post-normalization to re-merge these
names, so Kohya (lora_unet_) Z-Image LoRAs load.

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

* Fix Kohya LoRA conversion for Qwen top-level (non-block) modules

_convert_non_diffusers_qwen_lora_to_diffusers's convert_key hardcodes the
transformer_blocks prefix and assumes every lora_unet_ key lives under a block:
it strips a transformer_blocks_ prefix and re-prepends transformer_blocks.,
which collapses the top-level modules (img_in, txt_in, proj_out, norm_out.linear,
time_text_embed.timestep_embedder.linear_1/2) onto each other. They end up as
transformer_blocks..weight / ...a.down.weight and trip the 'state_dict should be
empty' guard.

Resolve these six modules via an explicit flattened->dotted map before the block
logic runs, preserving the .lora_down/.lora_up/.alpha suffix, so Kohya (lora_unet_)
Qwen LoRAs load.

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

---------

Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
Co-authored-by: Sayak Paul <spsayakpaul@gmail.com>
2026-06-30 20:02:49 +03:00
kaixuanliu
b549ca91ac fix #14063 for Kandinsky5 pipeline load with device_map=balanced (#14050)
fix bug for Kandinsky5 pipeline load with device_map=balanced

Signed-off-by: Liu, Kaixuan <kaixuan.liu@intel.com>
Co-authored-by: dg845 <58458699+dg845@users.noreply.github.com>
2026-06-29 23:06:22 -07:00
Sayak Paul
4f37263ab7 [chore] update to 2026 finally. (#14079)
update to 2026 finally.
2026-06-29 20:20:44 -04:00
Kashif Rasul
1f9c201083 Add doc pages for the DiffusionGemma schedulers (#14092)
* add doc pages for the discrete ddim and entropy bound schedulers

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

* fix the cited paper titles to match the linked papers

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

---------

Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-29 22:10:42 +02:00
Linoy Tsaban
c112837d16 [lora] add non-diffusers LoRA loading support for Krea 2 LoRAs (#14074)
Support loading non-diffusers Krea 2 LoRAs (ComfyUI / AI-Toolkit)

Krea 2 LoRAs in the wild are trained against the original krea-ai/krea-2
module names and ship under either the `diffusion_model.` prefix (Krea 2
reference trainer / ComfyUI exports) or the `base_model.model.` prefix
(Ostris AI-Toolkit exports). Add a converter that maps these onto the
diffusers Krea2Transformer2DModel names so they load directly via
`Krea2Pipeline.load_lora_weights`.

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-29 16:44:53 +03:00
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
dxqb
ea802951f5 Fix Kohya UNet LoRA key conversion for conv_in/conv_out/time_embedding (#14006)
* Fix Kohya UNet LoRA key conversion for conv_in/conv_out/time_embedding

_convert_unet_lora_key() had no mapping for these three top-level UNet
submodules, so Kohya-format keys touching them (e.g. lora_unet_conv_in,
lora_unet_time_embed_0/2) came out as conv.in/conv.out/time.embed.0/2
instead of conv_in/conv_out/time_embedding.linear_1/2, and were
reported as unexpected keys instead of being applied.

* Handle both sgm and diffusers spellings for conv/time_embedding keys

The initial fix mapped conv_in/conv_out in the diffusers spelling (conv.in/
conv.out) and time_embedding in the sgm spelling (time_embed.0/.2), so neither
SD1.x nor SDXL was fully covered. Add the missing spellings:

- sgm conv_in/conv_out: input_blocks.0.0 / out.2 (kohya-ss SDXL sgm UNet),
  mapped before the block renames so input_blocks.0.0 does not become
  down_blocks.0.0.
- diffusers time_embedding: time_embedding.linear_1/2 (kohya-ss trains SD1.x on
  the diffusers UNet).

Verified against kohya-ss source (sdxl_original_unet.py, networks/lora.py) and
the diffusers UNet module names; regression set unchanged.

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

* Map SDXL sgm label_emb LoRA keys and pass UNet top-level modules through

The conv_in/conv_out/time_embedding fix only reached _convert_unet_lora_key;
for the SDXL sgm UNet those keys never got there, because
_maybe_map_sgm_blocks_to_diffusers treats every non-text key as a down/mid/up
block. The top-level modules that live outside that block structure
(time_embed, label_emb, out = conv_out, and input_blocks.0.0 = conv_in) hit the
"layer not supported" raise, or crashed the inner block-index int() parse.

- Pass those top-level modules through unchanged so _convert_unet_lora_key maps
  them, instead of block-remapping or raising.
- Map the sgm label_emb (SDXL added-conditioning MLP) to diffusers add_embedding:
  label_emb.0.0/0.2 -> add_embedding.linear_1/2, before the SDXL index-strip
  heuristic that would otherwise collapse the layer index.

All additions follow the kohya/sgm naming pattern and are no-ops on real
kohya-ss files (which contain none of these top-level UNet LoRA keys); verified
end-to-end loading a full SDXL sgm UNet LoRA into the diffusers pipeline with no
unexpected/missing adapter keys.

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

---------

Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
Co-authored-by: Sayak Paul <spsayakpaul@gmail.com>
2026-06-28 08:54:42 -07:00
ElectricGoal
29a59fd960 Fix DreamLite legacy block type aliases (#14066)
* Fix DreamLite legacy block type aliases

* Cover DreamLite non-V1 up block alias

---------

Co-authored-by: dg845 <58458699+dg845@users.noreply.github.com>
2026-06-26 16:42:19 -07:00
Oleksandr Porunov
1ec68b68e1 feat: bump safetensors to 0.8.0 (#13971)
Signed-off-by: Oleksandr Porunov <alexandr.porunov@gmail.com>
Co-authored-by: Sayak Paul <spsayakpaul@gmail.com>
2026-06-26 15:50:54 -07:00
Ramkumar R
f24667dc96 docs: fix repeated word typo in set_timesteps docstring (#13876)
* docs: fix repeated word typo in set_timesteps docstring

Removed the duplicate word "schedule" from the docstring for the sigmas argument in EulerDiscreteScheduler.set_timesteps.

* Update scheduling_euler_discrete.py

* Apply style fixes

---------

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2026-06-26 09:45:46 -07:00
Atharva Joshi
bd2c919588 multi-GPU VAE Fix for Cosmos 3 (#13924)
fix(cosmos3): pin VAE latent norm buffers to encode output device

Under sharded placement (device_map="balanced"), vae.encode() runs on the
VAE's own device while the mean/inv_std buffers were pinned to x.device,
causing a cross-device RuntimeError. Compute raw_mu first, then pin the
normalization buffers to its device so all tensors share one device.

Co-authored-by: Atharva Joshi <atjoshi@smc521ge-0036.ipp2a2.colossus.nvidia.com>
Co-authored-by: Sayak Paul <spsayakpaul@gmail.com>
2026-06-25 09:03:58 -10:00
Hz_Zhang
577b28f8f5 Add from_single_file support for SkyReelsV2 and ChronoEdit transformers (#13946)
SkyReels-V2 and ChronoEdit are both built on Wan, and their transformers have
the same keys as WanTransformer3DModel, so they reuse
convert_wan_transformer_to_diffusers (like WanVACE / WanAnimate). This lets the
community GGUF builds load directly.

Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-25 19:45:25 +05:30
Kashif Rasul
21ba39457d [discrete diffusion] Add DiffusionGemma pipeline and schedulers (#13986)
* Add discrete DDIM and entropy bound schedulers and a uniform mode for block refinement

* Add DiffusionGemma block-diffusion pipeline

* Add DiffusionGemma pipeline tests and docs

* Put DiffusionGemma docs under the Text pipelines section

* Add static cache and fullgraph-compiled decoder path to DiffusionGemma pipeline

* Compile decoder externally for the static cache path instead of a pipeline flag

* Prefill the encoder once into a reusable cache and sync default denoising steps

* Support image prompts by forwarding pixel_values to the encoder prefill

* Restyle docstrings to satisfy doc-builder

* Sort the new scheduler and pipeline exports

* Let any of the three schedulers drive the pipeline

* Document the schedulers and updated defaults in the pipeline docs

* Sort the scheduler dummy objects

* Set scheduler sampling knobs on the scheduler config, not the pipeline call

* Accept raw prompt/image/messages instead of pre-tokenized model inputs

* Add leave-one-out predictor-corrector to DiscreteDDIM scheduler

Adds optional Gibbs corrector sweeps after each predictor step for
uniform diffusion, recovering the LOO denoiser in closed form so it
works on the released checkpoint with no retraining.

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

* Forward PEFT adapter API on the DiffusionGemma pipeline

The denoiser is a Transformers model, so adapters (LoRA, DoRA, ...) load
through its native PEFT integration rather than the diffusers LoRA loader.
Also dispatch the predictor-corrector by scheduler capability instead of class.

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

* Fix callback kwargs gathering on Python < 3.12

Build callback_kwargs with a loop instead of a dict comprehension, whose
own scope hides locals() on pre-3.12 (PEP 709), causing KeyError: 'canvas'.

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

* Speed up diffusion gemma sampling to match transformers

Add adaptive stopping (stop a block once its prediction is stable and
confident) and make the decoder compile cudagraph-safe via
cudagraph_mark_step_begin + logits clone. ~175 -> ~372 tok/s. Also align
the decoder mask with the new transformers#46654 layout.

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

* Enable adaptive stopping by default

Default confidence_threshold to 0.005 to match the released checkpoint
and transformers, so the speedup is on out of the box.

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

* Fold corrector sweeps into the step budget

Run fewer predictor steps and spend the freed forwards on the corrector,
so predictor-corrector sampling costs the same total forwards as plain
ancestral (~2x faster), matching the paper.

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

* Commit the converged prediction on adaptive stop

Ancestral schedulers like DiscreteDDIM only clean the canvas on the final
step, so stopping early left noise tokens. Use the denoiser argmax instead,
which is the converged answer and matches the canvas for commit schedulers.

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

* anneal sampling temperature and fix static cache decoder mask

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

* Update src/diffusers/pipelines/diffusion_gemma/pipeline_diffusion_gemma.py

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

* Update src/diffusers/schedulers/scheduling_entropy_bound.py

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

* Update src/diffusers/pipelines/diffusion_gemma/pipeline_diffusion_gemma.py

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

* address dg845 review comments

* fix entropy scheduler temperature scaling

* update decoder mask for new transformers

* self-condition on the temperature-shaped logits

* move temperature annealing into EntropyBoundScheduler

* self-condition on the entropy scheduler's shaped logits

* show torch.compile + static cache in the usage example

* removed wrong commit

* Update src/diffusers/pipelines/diffusion_gemma/pipeline_diffusion_gemma.py

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

* address review comments

* expose pred_logits on all schedulers

---------

Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
Co-authored-by: dg845 <58458699+dg845@users.noreply.github.com>
Co-authored-by: Sayak Paul <spsayakpaul@gmail.com>
2026-06-25 08:22:16 +02:00
Sayak Paul
9d52996c4d [tests] implement base model output caching in model-level tests (#14059)
* implement base model output caching in model-level tests

* single quotes

* memory

---------

Co-authored-by: dg845 <58458699+dg845@users.noreply.github.com>
2026-06-24 22:01:19 -07:00
Akshan Krithick
d8d3f906e0 fix(bria_fibo): fix guidance_embeds, prompt_embeds, tensor-image and multi-image crashes (#13981)
* fix(bria_fibo): fix guidance_embeds, prompt_embeds, tensor-image and multi-image crashes

* remove unusable precomputed-embeds args and batch-decode output
2026-06-24 14:19:07 -10:00
Sayak Paul
eb0a900caa fix claude code review fix in PRs. (#14058) 2026-06-24 12:02:38 -07:00
YiYi Xu
03040e5152 [.ai] document single-file model layout and "don't reimplement Diffus… (#14048)
* [.ai] document single-file model layout and "don't reimplement DiffusionPipeline"

Two conventions that weren't written down, surfaced while reviewing a new
model/pipeline port:

- models.md: add a "Single-file model layout" section. A model lives in one
  self-contained `transformer_<name>.py`; reuse shared blocks from
  normalization.py/attention.py/embeddings.py and inline model-specific
  variants with `# Copied from` rather than creating per-model
  `attention_processor_<name>.py` / `block_<name>.py` / `rope_<name>.py`
  companion files (no precedent for these in the repo).

- pipelines.md: add gotcha #7, "Don't reimplement DiffusionPipeline." A
  subclass adds only pipeline-specific steps; device placement, offloading,
  execution-device resolution, and module registration already exist on the
  base class. No custom device/offload manager, no `device=` arg on
  `__call__`, no `set_<component>` setters.

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

* [.ai] generalize single-file model layout section

Drop the implementation-specific examples (Lumina class names, per-model
transformer_*.py citations) and state the single-file policy generally:
everything (attention, blocks, RoPE, model-specific layers) in one model
file, with shared blocks either imported from the common modules or brought
in via `# Copied from ... with Old->New`.

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

* [.ai] trim redundant don't-split sentence from single-file section

The positive statement (everything in one model file) already conveys it;
drop the companion-module filename list and the editorializing.

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

* [.ai] generalize the "don't reimplement DiffusionPipeline" gotcha

State the principle and the canonical base APIs; drop the implementation-
specific anti-pattern callouts (enable_*_flag booleans, set_<component>
setters, the device= arg, a shadow self.execution_device).

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

* [.ai] pare gotcha #7 down to the principle

Drop the per-category API bullets; one sentence — don't add device
placement, offloading, or component loading/registration logic on a
subclass, it's on the base class. Can expand later if needed.

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

* [.ai] renumber gotchas after merge: component-mutation #7, reimplement #8

main's newly merged "don't modify registered component on the fly" keeps #7;
our "don't reimplement DiffusionPipeline" becomes #8 (appended after it).

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

* [.ai] add blank line between gotchas 7 and 8

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

* Update .ai/models.md

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

---------

Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
Co-authored-by: dg845 <58458699+dg845@users.noreply.github.com>
2026-06-24 08:23:59 -10:00
Sayak Paul
6a71b6e332 Fix model cuda tests (#13975)
* port final set of model tests and others

* fix extracter.

* fix cuda tests for models.

* Revert "fix extracter."

This reverts commit 178c4cb99b.

* Revert "port final set of model tests and others"

This reverts commit a92c70c081.

* fix more

* address reviewer feedback

---------

Co-authored-by: dg845 <58458699+dg845@users.noreply.github.com>
2026-06-23 17:42:36 +05:30
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
Akshan Krithick
afd7765470 fix(flux): tighten check_inputs validation (#13955)
* fix(flux): tighten check_inputs validation for negative embeds, controlnet img2img dims, redux scales

* fix(flux): gate negative prompt embeds shape check on do_true_cfg

* fix(flux): assert error message in negative-embed shape check test

---------

Co-authored-by: Sayak Paul <spsayakpaul@gmail.com>
2026-06-22 22:51:21 -07:00
Lucas Ste
e97a1ad2a2 Enable BitsAndBytes quantization in MPS (#13915)
Fix BitsAndBytes quantization in MPS

Co-authored-by: Sayak Paul <spsayakpaul@gmail.com>
2026-06-22 22:20:14 -07:00
YiYi Xu
aed5c64154 [.ai doc] Refine .ai attention-mask and component-mutation guidance (#13982)
Refine .ai attention-mask and component-mutation guidance from a PR review

- models.md: clarify padding-mask bullet — pass None when padding is
  uniform (mask.all()) or when the model is trained to tolerate padding
  without a mask
- pipelines.md: add gotcha #7 — don't mutate registered component state
  per call; prefer an already-prepared component, otherwise snapshot and
  restore (PAG pattern)

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-authored-by: dg845 <58458699+dg845@users.noreply.github.com>
2026-06-22 16:12:17 -10:00
YiYi Xu
7104cb43c3 Add Krea 2 (K2) text-to-image pipeline and transformer (#14045)
Adds Krea2Transformer2DModel and Krea2Pipeline: a flow-matching
text-to-image MMDiT with grouped-query attention, Qwen3-VL text
conditioning, and the Qwen-Image VAE.

Co-authored-by: Elea Zhong <elea@krea.ai>
Co-authored-by: Naga Sai Abhinay Devarinti <devarintinagasaiabhinay@gmail.com>
2026-06-22 16:59:24 -04:00
lcheng
2d0110f818 [Fix] Fix three final_layer LoRA conversion bugs in _convert_sd_scripts_to_ai_toolkit (#14001)
Signed-off-by: lcheng <lcheng321@gatech.edu>
Co-authored-by: christopher5106 <christopher5106@users.noreply.github.com>
2026-06-20 14:17:11 +05:30
Hz_Zhang
6e8c8c4cac Fix Ideogram4MRoPE collapsing under torch.autocast (compute rotary in float32) (#13922)
* Fix `Ideogram4MRoPE` collapsing under `torch.autocast` (compute rotary in float32)

Ideogram4 builds image-token positions as IMAGE_POSITION_OFFSET (65536) + (t, h, w).
`Ideogram4MRoPE.forward` casts its operands to float32, but the rotary matmul (and
cos/sin) is on autocast's downcast list, so under torch.autocast("cuda", bfloat16) —
common in training and pipeline code — it runs in bfloat16 anyway. bfloat16's step at
65536 is 512, so every image position in a <=512 grid rounds to the same value: all
image tokens get identical rotary embeddings, spatial information is lost, and the
decoded image degenerates to a flat color.

Wrap the frequency computation in torch.autocast(enabled=False) so the rotary
embeddings are always computed in float32, matching how transformers guards its RoPE
modules. Added a regression test that fails on main and passes with the fix.

Fixes #13920

* Compute the rotary frequencies in float64 instead of disabling autocast

Per review: replace the torch.autocast(enabled=False) guard with a float64 computation,
which autocast does not downcast — matching the float64 rope path used elsewhere (Flux).
The autocast and float32 paths stay bit-identical (max|delta|=0).

* Disable autocast for Ideogram4 rope matmul instead of using float64

Per review, use torch.autocast(enabled=False) around the rotary matmul (as
the original implementation did) rather than computing in float64, and adopt
the clearer comment describing the bfloat16 collapse at the 65536 offset.

* Disable autocast for ernie_image and helios rope einsum

Extend the Ideogram4 fix: ernie_image's `rope` and helios's
`get_frequency_batched` build rotary freqs with an unguarded float32
einsum over raw position ids. Under an ambient autocast the einsum runs in
bfloat16 on CUDA, which cannot represent consecutive integers past 256, so
positions degrade — the same bug, matching the guards mochi/omnigen already
have. Wrap each in torch.autocast(enabled=False).

* Disable autocast for Cosmos3 VL-text rope matmul

Cosmos3VLTextRotaryEmbedding builds its interleaved-mrope freqs with an
unguarded position-id matmul (same shape as Ideogram4), so an ambient autocast
downcasts it to bfloat16 and collapses positions past 256. Wrap in
torch.autocast(enabled=False).

* Tighten autocast(enabled=False) to just the rope matmul

Per review, scope the guard to the precision-sensitive position-id matmul
in Ideogram4 and Cosmos3 rather than the whole freqs block (ernie_image and
helios already wrap only the einsum).

---------

Co-authored-by: dg845 <58458699+dg845@users.noreply.github.com>
2026-06-19 15:02:31 -07:00
Boffee
7bf00006aa Fix LTX2 connector token/register layout (regression from #13564) (#13931)
* Fix LTX2 connector register layout to match the original LTX implementation

The connector replaced left-padding positions with the tiled registers and
then flipped the whole sequence, which put the prompt tokens at the front in
reversed order and the register tile reversed within each block. The original
LTX implementation (ltx-core _replace_padded_with_learnable_registers, also
matched by ComfyUI) front-aligns the valid tokens in their original order and
fills the tail with registers indexed by absolute position.

Since the connector blocks apply RoPE, the reversed layout produces
off-distribution embeddings; short prompts (e.g. negative prompts, whose
context is mostly registers) are hit hardest, which manifests as overblown
CFG: at cfg > 1 (or CFG++ samplers at cfg 1) the unconditional branch is
computed from a mostly-register context with scrambled positions.

Replace the fill+flip with a stable-argsort gather (valid tokens to the
front, order preserved, per batch row) and fill the tail with the
absolute-position register tile.

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

* Add register-layout regression tests for the LTX2 text connectors

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

---------

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
Co-authored-by: dg845 <58458699+dg845@users.noreply.github.com>
2026-06-18 19:56:25 -07:00
Tarek Ziade
b596c83aef ci: use hosted runners (#13987)
hosted runners can now reach Serge directly without creating a tailscale session
2026-06-18 17:38:04 +02:00
Sayak Paul
9a72cd3ee9 ci: don't remind on prs from admins, etc. (#13965)
* ci: don't remind on prs from admins, etc.

* don't remind model authors about linking issues/.
2026-06-18 13:53:10 +05:30
Jingya HUANG
236e5dd9f3 [Neuron] Enable torch.compile compatibility with Neuron device (#13485)
* draft:add neuron as a legit backend

* feat: neuron-specific changes in the pipeline

* tests: eager tests

* fix: style

* fix:apr_02 beta

* fix:pixart

* fix: rewrite flux swiglu activation to avoid gather op in neuron IR

* test: pixart compile mode on neuron

* cleanup & fix style

* test: flux2 klein and sdxl-turbo

* review: address some comments

* revert:put back expected slices

* cleanup:move the ts index ahead of denoising + cleanup tests

* fix: style

* fix style

* review:remove the hook

---------

Co-authored-by: Sayak Paul <spsayakpaul@gmail.com>
2026-06-17 17:27:38 -10:00
Samuel Tallet
6d9331ea60 Enable LoRA loading on Ideogram4ModularPipeline (#13980) 2026-06-17 12:37:11 -10:00
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
5e7540fc5c [tests] port final set of model tests and others (#13974)
* port final set of model tests and others

* fix extracter.
2026-06-17 15:27:03 +05:30
David Bertoin
a487e2f131 Add PRXPixelPipeline: pixel-space PRX text-to-image pipeline (#13928)
Adds a pixel-space variant of PRX that denoises raw RGB directly
(no VAE), conditioned on a Qwen3-VL text encoder:

- PRXTransformer2DModel: new optional config args `bottleneck_size`
  (two-layer img_in projection for large patch dims) and
  `resolution_embeds` (PRXResolutionEmbedder conditions the timestep
  modulation on the latent resolution)
- PRXPipeline: support for subclass-tuned tokenizer max length, light
  text cleaning, x-prediction flow matching (x0 -> velocity conversion),
  and non-unit initial noise scale
- PRXPixelPipeline: thin subclass wiring the above together
  (vae optional/None, vae_scale_factor=1, 1024px default)
- conversion script support for the pixel checkpoint format
- registration in __init__ files + dummy objects, docs autodoc entry,
  fast pipeline tests

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
2026-06-16 21:14:54 -07:00
MaciejBalaNV
212a98d4f2 Add Sound Encoder to Cosmos3 (#13911)
* Initial version of sound encoder

Signed-off-by: Maciej Bala <mbala@nvidia.com>

* Answered review comments

Signed-off-by: Maciej Bala <mbala@nvidia.com>

* Reshaped encoder Snake1d

Signed-off-by: Maciej Bala <mbala@nvidia.com>

* Updated test

Signed-off-by: Maciej Bala <mbala@nvidia.com>

* Fixed test

Signed-off-by: Maciej Bala <mbala@nvidia.com>

* Apply style fixes

* Added docstring

Signed-off-by: Maciej Bala <mbala@nvidia.com>

---------

Signed-off-by: Maciej Bala <mbala@nvidia.com>
Co-authored-by: dg845 <58458699+dg845@users.noreply.github.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2026-06-16 18:44:46 -07:00
Sayak Paul
4d85a3ae7f Revert "start"
This reverts commit 26ae69b11c.
2026-06-16 13:10:11 +00:00
Sayak Paul
26ae69b11c start 2026-06-16 13:09:53 +00:00
Sayak Paul
fd823e825c fix untrusted fork secret mixing (#13970) 2026-06-16 13:27:23 +05:30
Dhruv Nair
3d3eedf720 [CI] Refactor Z Image Transformer Tests (#13253)
* 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 46d44b73d8.

* 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 41b036b989.

---------

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>
2026-06-16 11:30:54 +05:30
yzhautouskay
bcbfcd43da Add Cosmos3 video2video generation support (#13896)
* Init v2v cosmos3 commit

* Add user quide; prompt upsampling is TBD

* 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>
2026-06-15 21:08:36 -07:00
Sayak Paul
21e33389cd [CI] allow running tests as PR comments through a bot (#13873)
* start

* fix

* remove planning
2026-06-16 08:32:45 +05:30