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

6455 Commits

Author SHA1 Message Date
sayakpaul
275869dcae Release: v0.38.0-release v0.38.0 2026-05-01 10:53:59 +05:30
Aditya Borate
42a46e48c3 Fix missing latents_bn_std dtype cast in VAE normalization (#13299)
* Corrected casting of latents_bn_std

* Propagated the fix to the klein inpaint pipeline

---------

Co-authored-by: YiYi Xu <yixu310@gmail.com>
Co-authored-by: Dhruv Nair <dhruv.nair@gmail.com>
2026-05-01 10:49:06 +05:30
Gong Junmin
1a8a17b71b Add ACE-Step pipeline for text-to-music generation (#13095)
* Add ACE-Step pipeline for text-to-music generation

Rebased on origin/main from the original pr-13095 branch (3 commits squashed).

- AceStepDiTModel: Diffusion Transformer with RoPE, GQA, sliding window,
  AdaLN timestep conditioning, and cross-attention.
- AceStepConditionEncoder: fuses text / lyric / timbre into a single
  cross-attention sequence.
- AceStepPipeline: text2music / cover / repaint / extract / lego / complete.
- Conversion script for the original checkpoint layout.
- Docs + tests.

* Fix ACE-Step pipeline audio quality and auto-detect turbo/base/sft variants

The PR's original inference produced low-quality audio on turbo because the
pipeline (a) mangled the SFT prompt format, (b) applied classifier-free guidance
with the wrong unconditional embedding (empty-string encoded vs. the learned
`null_condition_emb`), and (c) hardcoded turbo defaults even when loading a
base/SFT checkpoint.

Changes:

* Converter preserves `null_condition_emb` (stored under the condition encoder)
  and propagates `is_turbo`/`model_version` into the transformer config so the
  pipeline can route per-variant defaults.
* `AceStepConditionEncoder` registers `null_condition_emb` as a learned
  parameter matching the original module.
* Pipeline auto-detects variant via `is_turbo`/`model_version` and picks
  defaults that match `acestep/inference.py`:
    * turbo:  steps=8,  shift=3.0, guidance_scale=1.0 (no CFG)
    * base/SFT: steps=27, shift=1.0, guidance_scale=7.0
* Base/SFT timestep schedule uses the linear+shift transform from
  `acestep/models/base/modeling_acestep_v15_base.py`; turbo still uses the
  hardcoded 8-step `SHIFT_TIMESTEPS` table.
* CFG reuses the learned `null_condition_emb` and batches the
  conditional+unconditional forwards into a single transformer call.
* `SFT_GEN_PROMPT` matches the newline layout in `acestep/constants.py` so the
  text encoder sees the same prompt distribution it was trained on.

DiT parity vs. the original ACE-Step 1.5 turbo DiT is bit-identical
(max_abs=0.0 in fp32 eager/SDPA across 4 seed/shape cases) — see
scripts/dit_parity_test.py.

* Add ACE-Step parity test scripts

Two developer-facing parity harnesses live under scripts/:

* dit_parity_test.py — loads the same converted turbo weights into the
  original AceStepDiTModel and the diffusers AceStepDiTModel, drives
  identical (hidden_states, timestep, timestep_r, encoder_hidden_states,
  context_latents) inputs, and asserts max-abs-diff ≤ 1e-5 in fp32
  eager/SDPA. Currently passes bit-identical (max_abs=0) across four
  shape/seed cases including batched + odd-length paths.

* audio_parity_jieyue.py — full end-to-end audio parity. Given the same
  JSON example, runs both the original ACE-Step 1.5 pipeline and the
  diffusers AceStepPipeline at matched seed/precision (bf16 + FA2 by
  default) and saves side-by-side .wav files for listening verification.
  Supports text2music / cover / repaint × turbo / base / sft via a
  --matrix mode that writes 18 wavs named
  {variant}_{task}_{official,diffusers}.wav.

* Route SFT parity to acestep-v15-sft checkpoint

On jieyue the release tree has a dedicated SFT checkpoint at
checkpoints/acestep-v15-sft with its own modeling_acestep_v15_base.py
shipped under acestep/models/sft/. Point the SFT row of the parity matrix
at that checkpoint / module so we're testing the actual SFT weights, not
the plain base ones.

* audio_parity_jieyue: fix doubled 'acestep-' in cache path; --converted-root flag

Previously the converted-pipeline cache dir was
`/tmp/acestep-<variant>-diffusers` but <variant> already starts with
"acestep-", giving `/tmp/acestep-acestep-v15-turbo-diffusers`. Drop the
prefix.

On jieyue the overlay rootfs (including /tmp) only has a few GB free; a
full turbo conversion needs ~5 GB per variant. Add --converted-root (env
ACESTEP_CONVERTED_ROOT) so the cache can live on vepfs.

* audio_parity_jieyue: two-phase matrix bootstraps cover/repaint from text2music

The ACE-Step release bundle on jieyue doesn't ship sample .wav/.mp3
files, so matrix mode had no default --src-audio and would skip
cover/repaint entirely. Run text2music first for every variant, then
reuse the TURBO official text2music output as the shared source for the
cover/repaint rows. Users can still override with --src-audio.

* audio_parity_jieyue: seed the diffusers generator on the pipeline device

The ORIGINAL ACE-Step pipeline seeds on the execution device
(`torch.Generator(device=device).manual_seed(seed)`), i.e. the CUDA RNG
stream when running on GPU. Previously the parity harness seeded the
diffusers side with a CPU generator, so even though the seed integer
matched, the two sides drew different noise from the outset and the
final outputs were essentially uncorrelated. Use the execution-device
generator on both sides for a fair comparison.

* Fix ACE-Step pipeline: switch to APG guidance + peak normalization

Two issues found after the first jieyue audio parity run:

1. The original base/SFT pipeline uses APG (Adaptive Projected Guidance,
   acestep/models/common/apg_guidance.py) with a stateful momentum
   buffer and norm/projection steps — NOT vanilla CFG. Using vanilla CFG
   produced uncorrelated outputs vs. the reference (pearson ~0.0 on
   20 s samples); this PR ports `_apg_forward` + `_APGMomentumBuffer`
   and plugs them into the denoising loop when `guidance_scale > 1`.
   Momentum is instantiated once per pipeline call (persists across
   denoising steps) to match the reference semantics.

2. The post-VAE "anti-clipping normalization" in this pipeline was
   `audio /= std * 5` with a `std<1 -> std=1` guard. The original
   post-processing in
   acestep/core/generation/handler/generate_music_decode.py is simple
   peak normalization: `if audio.abs().max() > 1: audio /= peak`. The
   std-based proxy both (a) let clips with peak < 1 leak through
   unchanged (over-quiet) and (b) failed to bring clipping peaks to
   exactly 1 in a bunch of base/SFT cases (observed max=1.000, std=0.200
   repeatedly in the first parity run). Switch to peak normalization on
   both sides.

Tested via scripts/audio_parity_jieyue.py on A800; re-run pending to
confirm the base/SFT correlation improvements.

* Fix ACE-Step chunk mask values to match the original pipeline

The DiT receives `context_latents = concat(src_latents, chunk_mask)` on the
channel dim, and was trained with chunk_mask values drawn from the three
sentinels documented in acestep/inference.py:

  2.0 -> model-decided (default for text2music / cover / full-generation)
  1.0 -> keep this latent frame from src_latents (repaint preserved region)
  0.0 -> explicitly repaint this frame (only inside the repaint window)

Previously _build_chunk_mask returned all-1.0 for text2music (and cover /
lego), and an inverted 0/1 mask for repaint (1 inside the window, 0 outside).
Either case puts context_latents out of distribution. Switch text2music /
cover to the 2.0 sentinel and flip the repaint mask so it's 1.0 outside /
0.0 inside. Update the repaint src_latents zero-out to multiply by the new
mask (was `1 - chunk_mask`) so the zero region still lines up with the
repaint window.

* Add direct invoker for ACE-Step generate_music (ground truth)

Our earlier audio_parity_jieyue.py reconstructs the original pipeline by
calling AceStepConditionGenerationModel.generate_audio() directly, which
silently skips a lot of the real handler plumbing (conditioning masks,
silence-latent tiling, cover/repaint pre-processing, etc.). That made the
'official' wavs we saved sound wrong — flat, drone-like, not music.

This new script calls acestep.inference.generate_music end-to-end through
the real AceStepHandler, with LM + CoT explicitly disabled so we still have
a deterministic comparison. Use it to generate the ground-truth 'official'
wav for a given JSON example, then separately run the diffusers pipeline
with the same inputs and diff the two.

* run_official_generate_music: call initialize_service to bind a DiT variant

AceStepHandler() is a shell — you have to call handler.initialize_service(
project_root=..., config_path=..., device=..., use_flash_attention=..., ...)
before generate_music will work. Mirror what cli.py does at the equivalent
spot (around cli.py:1400).

* Fix silence-reference for ACE-Step timbre encoder

The root cause for the flat / drone-like outputs I was seeing (including
in my 'official' reconstruction): when no reference_audio is provided the
pipeline was feeding literal zeros to the timbre encoder. The real
handler feeds a slice of the learned `silence_latent` tensor.

The handler also transposes silence_latent on load (see
acestep/core/generation/handler/init_service_loader.py:214:
  self.silence_latent = torch.load(...).transpose(1, 2)
) converting [1, 64, 15000] -> [1, 15000, 64] so that
`silence_latent[:, :750, :]` yields the expected [1, 750, 64] shape.

Changes:

* Converter: load silence_latent.pt, transpose to [1, T, C], bake into
  the condition_encoder safetensors under key `silence_latent`.
  (Also keeps the raw .pt file at the pipeline root for debugging.)
* AceStepConditionEncoder: register `silence_latent` as a persistent
  buffer so from_pretrained loads it alongside the trained weights.
* Pipeline: when reference_audio is None, slice
  `condition_encoder.silence_latent[:, :timbre_fix_frame, :]` and
  broadcast across the batch instead of zeros. Emits a loud warning
  (and falls back to zeros) if the buffer is all-zero — that means the
  checkpoint was produced by an older converter and should be rebuilt.
* audio_parity_jieyue.py: the reference path now matches the handler's
  silence-latent slicing.

Without this fix, every variant/task combo produced drone-like audio
even when my numeric DiT-forward parity claimed they were identical.

* Fix three more ACE-Step pipeline bugs I found by dumping real inputs

Instrumented the live generate_audio call in the real ACE-Step handler and
observed the exact tensors it sees — my diffusers pipeline was wrong in
three independent ways:

1. src_latents for text2music should be silence_latent tiled to
   latent_length, NOT zeros. The handler fills no-target cases from
   silence_latent_tiled (observed std=0.96). Zeros are OOD for the DiT
   context_latents concat and produce drone-like outputs.

2. chunk_mask values cap at 1.0 (not 2.0). The handler starts with a
   bool tensor (True inside the generate span, False outside); the
   chunk_mask_modes=auto -> 2.0 override does NOT take effect because
   the underlying tensor is bool, so setting entry = 2.0 casts to True.
   After the later .to(dtype) float cast, the DiT sees 1.0/0.0 — exactly
   what I observed in the captured tensor (unique values = [True]).

3. Default shift is 1.0 for ALL variants, including turbo. I was
   defaulting turbo to shift=3.0 which picks a different SHIFT_TIMESTEPS
   table (the 8-step schedule is keyed by shift, not variant).

Also:
* Added _silence_latent_tiled() helper that slices / tiles the learned
  silence_latent (now loaded as a buffer on the condition encoder) to
  the requested latent length.
* Repaint path now substitutes silence_latent (not raw zeros) inside
  the repaint window — matches conditioning_masks.py.
* audio_parity_jieyue.py mirrors the same src/chunk/shift choices on
  its 'original' leg for apples-to-apples parity once the buggy
  reconstruction is removed from the picture.

* Add peak+loudness post-normalization to AceStepPipeline

The real pipeline normalizes audio in two stages (see
acestep/audio_utils.py:72 normalize_audio + generate_music_decode.py):
  1. if peak > 1: audio /= peak  (anti-clip)
  2. audio *= target_amp / peak   (target_amp = 10 ** (-1/20) ~ 0.891)

Step 2 is loudness normalization to -1 dBFS. Without it diffusers outputs
had peak=1.0 vs the real 0.891 — same music content (pearson was ~0.86
already), just 1.12x louder. Add step 2 after the existing anti-clip step.

* Match acestep/inference.py inference_steps=8 for ALL variants

GenerationParams.inference_steps default is 8 — turbo AND base/SFT. I had
base/SFT defaulting to 27 here, so every base/SFT parity run was comparing
a 27-step diffusers trajectory against an 8-step real trajectory. Different
number of denoising steps means different audio even at fixed seed.

This likely explains the lower base/SFT correlation in my earlier jieyue
runs (turbo was 0.86, base/SFT were 0.32-0.34). Aligning step counts
should bring base/SFT closer to turbo parity.

* Address PR #13095 review: rename classes + reuse diffusers primitives

Response to dg845's PR comments batch 1+2. DiT parity harness still bit-identical
(max_abs=0 on fp32 / SDPA across 4 shape cases).

Transformer file:
* Rename AceStepDiTModel -> AceStepTransformer1DModel (alias kept).
* Rename AceStepDiTLayer -> AceStepTransformerBlock (alias kept).
* Inherit AttentionMixin + CacheMixin on the DiT model.
* Swap in diffusers.models.normalization.RMSNorm for the hand-rolled
  AceStepRMSNorm (weight-key-compatible).
* Swap the hand-rolled rotary embedding + apply_rotary for diffusers'
  get_1d_rotary_pos_embed + apply_rotary_emb (use_real_unbind_dim=-2 to
  match the cat-half convention ACE-Step inherits from Qwen3).
* Use get_timestep_embedding with flip_sin_to_cos=True — keeps the
  (cos, sin) ordering of the original sinusoidal. State-dict-compatible.
* Drop max_position_embeddings arg from DiT config (RoPE computes freqs
  per call based on seq_len); converter drops it.
* Gradient-checkpoint call now takes just the layer module (matches the
  Flux2 idiom).

Pipeline modeling file (pipelines/ace_step/modeling_ace_step.py):
* Moved _pack_sequences + AceStepEncoderLayer here — they aren't used
  by the DiT, so they shouldn't live in the transformer file.
* AceStepLyricEncoder + AceStepTimbreEncoder set
  _supports_gradient_checkpointing = True and wrap encoder-layer calls
  through the checkpointing func when enabled.
* Use diffusers RMSNorm + the RoPE helper from the transformer file
  (shared single implementation).

Converter (scripts/convert_ace_step_to_diffusers.py):
* model_index.json now carries AceStepTransformer1DModel.
* Drop max_position_embeddings / use_sliding_window from the emitted
  configs.

No numerical regressions: scripts/dit_parity_test.py PASSES with
max_abs=0.0 on fp32/SDPA across short, long, batched, and
padding-path shape variants.

* Address PR #13095 review: pipeline polish + converter HF-hub support

Response to dg845 review comments on the pipeline side. DiT parity still
bit-identical (max_abs=0 across 4 shape cases).

Pipeline (pipelines/ace_step/pipeline_ace_step.py):
* Add `sample_rate` + `latents_per_second` properties sourced from the
  VAE config so the pipeline no longer hardcodes 48000 / 25 / 1920.
  Propagates through prepare_latents, chunk_mask window math, and the
  audio-duration round-trip.
* Add `do_classifier_free_guidance` property (matches LTX2 et al.).
* Add `check_inputs(...)` called from `__call__` before allocating noise.
  Validates prompt type, lyrics type, task_type, step count, guidance
  scale, shift, cfg interval bounds and repaint window ordering.
* Add `callback_on_step_end` + `callback_on_step_end_tensor_inputs` —
  the modern callback form. The legacy `callback` / `callback_steps`
  pair is kept for back-compat. Setting `pipe._interrupt = True` inside
  the callback stops the loop early.
* Expose `encode_audio(audio)` as a public helper that wraps the tiled
  VAE encode + (B, T, D) transpose the pipeline performs internally.

Converter (scripts/convert_ace_step_to_diffusers.py):
* Accept a Hugging Face Hub repo id for `--checkpoint_dir`; resolves it
  via `huggingface_hub.snapshot_download` when the argument isn't a
  local path.

Exports:
* Register `AceStepTransformer1DModel` in the top-level __init__,
  models/__init__, models/transformers/__init__, and dummy_pt_objects so
  `from diffusers import AceStepTransformer1DModel` works and the
  pipeline loader resolves the new class name from model_index.json.

Deferred for a follow-up (commented inline in the PR): full
`Attention + AttnProcessor + dispatch_attention_fn` refactor and
`FlowMatchEulerDiscreteScheduler` migration — both would benefit from a
dedicated parity re-run and review.

* Fix stale ACE-Step 1.0-era docs / class names in the 1.5 integration

Docs and docstrings still carried a mix of 1.0 paper title, non-existent
`ACE-Step/ACE-Step-v1-5-turbo` hub id, `shift=3.0` turbo default, and
the old `AceStepDiTModel` class name. Cleaned up to match the actual
1.5 release:

* pipelines/ace_step.md: correct citation title ("ACE-Step 1.5: Pushing
  the Boundaries of Open-Source Music Generation"), correct repo
  (`ace-step/ACE-Step-1.5`), new variants table with real HF ids
  (`Ace-Step1.5` / `acestep-v15-base` / `acestep-v15-sft`) and their
  per-variant step/CFG defaults, drop the wrong `shift=3.0` tip.
* models/ace_step_transformer.md: page renamed to
  `AceStepTransformer1DModel` with a short 1.5-specific description;
  `AceStepDiTModel` noted as a backwards-compat alias.
* pipeline_ace_step.py: import, docstring, `Args`, and `__init__`
  annotation reference `AceStepTransformer1DModel`; example model id
  now `ACE-Step/Ace-Step1.5`; `_variant_defaults` docstring and the
  `__call__` variant-fallback comment no longer claim `shift=3.0` /
  `27 steps` — real defaults are 8 steps / shift=1.0 across all
  variants, guidance=1.0 (turbo) vs 7.0 (base+sft).

* Address PR #13095 review: VAE tiling on AutoencoderOobleck + Timesteps class

Two more deferred review threads from dg845 addressed:

* Move tiled encode/decode onto AutoencoderOobleck
  (https://github.com/huggingface/diffusers/pull/13095#discussion_r2785513647).
  AutoencoderOobleck now carries `use_tiling` + `tile_sample_min_length` /
  `tile_sample_overlap` / `tile_latent_min_length` / `tile_latent_overlap`
  attributes and private `_tiled_encode` / `_tiled_decode` methods; the
  existing `encode` / `_decode` dispatch to them when tiling is enabled and
  the input exceeds the threshold. `AutoencoderMixin.enable_tiling()` is
  already inherited.

  AceStepPipeline's private `_tiled_encode` / `_tiled_decode` and the
  `use_tiled_decode` `__call__` arg are gone; `__init__` now calls
  `self.vae.enable_tiling()` so the long-audio memory behaviour is preserved
  by default. Users can opt out with `pipe.vae.disable_tiling()`.

  Note: the VAE-side tiling concatenates encoder features (h) and samples
  the posterior once, instead of the old per-tile `.sample()` calls. This
  is the standard diffusers pattern; numerically differs only in the
  structure of the noise across tile boundaries.

* Use the Timesteps nn.Module for the sinusoid
  (https://github.com/huggingface/diffusers/pull/13095#discussion_r2785420234).
  `AceStepTimestepEmbedding` wraps `Timesteps(in_channels, flip_sin_to_cos=
  True, downscale_freq_shift=0)` instead of calling `get_timestep_embedding`
  directly — reviewer asked for the Module form.

* Address PR #13095 review: refactor AceStepAttention to Attention + AttnProcessor

Splits the monolithic AceStepAttention into the diffusers standard
Attention + AttnProcessor layout:
  - AceStepAttention (torch.nn.Module, AttentionModuleMixin) holds the
    to_q/to_k/to_v/to_out projections and norm_q/norm_k RMSNorms.
  - AceStepAttnProcessor2_0 runs the attention dispatch through
    dispatch_attention_fn so users can pick flash / sage / native backends
    via model.set_attention_backend(...) or the attention_backend context
    manager.

GQA (Q has 16 heads / K,V have 8) is preserved by passing enable_gqa=True
to dispatch_attention_fn instead of repeat_interleave; fusion is disabled
(_supports_qkv_fusion = False) because Q and K,V have different output
sizes.

The converter is updated to rename the six attention sub-keys
(q_proj -> to_q, k_proj -> to_k, v_proj -> to_v, o_proj -> to_out.0,
q_norm -> norm_q, k_norm -> norm_k) on both the DiT decoder path and the
condition encoder path, since AceStepLyricEncoder / AceStepTimbreEncoder
share the same AceStepAttention class.

Addresses review comments r2785433213 and r2785450463.

* Address PR #13095 review: migrate to FlowMatchEulerDiscreteScheduler

Replace the hand-rolled flow-matching Euler loop with
`FlowMatchEulerDiscreteScheduler`. ACE-Step still computes its own shifted /
turbo sigma schedule via `_get_timestep_schedule`, but now passes it to
`scheduler.set_timesteps(sigmas=...)` and delegates the ODE step to
`scheduler.step()`. The scheduler is configured with `num_train_timesteps=1`
and `shift=1.0` so `scheduler.timesteps` stays in `[0, 1]` (the convention the
DiT was trained on) and the scheduler doesn't re-shift already-shifted sigmas.

The scheduler's appended terminal `sigma=0` reproduces the old loop's
final-step "project to x0" case exactly: `prev = x + (0 - t_curr) * v`.

Parity on jieyue (seed=42, bf16 + flash-attn, turbo text2music, 8 steps):
  waveform Pearson = 0.999999
  spectral Pearson = 1.000000
  max |diff|       = 2.5e-3  (fp32 step-math vs previous bf16 step-math)

fp32 Euler-loop A/B against the hand-rolled path: max |diff| = 3.6e-7.

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

* Address PR #13095 review: move DiT tests + drop stale test kwargs

- Move the DiT transformer tests out of the pipeline test file into a new
  tests/models/transformers/test_models_transformer_ace_step.py that follows
  the standard BaseModelTesterConfig + ModelTesterMixin scaffold (matches
  test_models_transformer_longcat_audio_dit.py).
- Drop `max_position_embeddings` from the remaining AceStepDiTModel and
  AceStepConditionEncoder test fixtures — neither constructor accepts that
  argument anymore.
- Drop `use_sliding_window` from the same fixtures — also no longer a
  constructor argument (the actual `sliding_window` int kwarg is kept).
- Wire `FlowMatchEulerDiscreteScheduler(num_train_timesteps=1, shift=1.0)`
  into `get_dummy_components()` now that the pipeline requires it.

Resolves https://github.com/huggingface/diffusers/pull/13095#discussion_r3115653554,
r3115664850, r3115673059, r3115676580, r3115680700.

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

* Address PR #13095 review from dg845 (2026-04-23)

Fixes 5 review threads + style:

1. Converter now builds `AceStepPipeline` in memory and calls
   `save_pretrained`. Previously the hand-written `model_index.json` was
   missing the `scheduler` entry — fresh converter output couldn't be loaded
   by `AceStepPipeline.from_pretrained` (r3127767785). This also makes the
   converter robust to future `__init__` signature changes.

2. `latent_length` uses `math.ceil(...)` instead of `int(...)` so non-integer
   products (e.g. `latents_per_second=2.0, audio_duration=0.4 → 0.8`) round up
   to `1` instead of truncating to `0` and crashing shape checks (r3127790939).

3. Add `_callback_tensor_inputs = ["latents"]` on `AceStepPipeline` so the
   standard diffusers callback tests pick up the right tensor (r3127795954).

4. `AceStepConditionEncoder.silence_latent` no longer hard-codes the channel
   dim to 64. The placeholder buffer now uses the `timbre_hidden_dim`
   constructor argument, so smaller test configs with `timbre_hidden_dim != 64`
   load without shape errors (r3127812932).

5. Revert `self.vae.enable_tiling()` from `AceStepPipeline.__init__`. Users can
   call `pipe.vae.enable_tiling()` themselves for long-form generation; that
   matches the opt-in convention used by the rest of diffusers (r3127777296).

6. `ruff check --fix` + `ruff format` over all ACE-Step sources (the style fix
   dg845 asked for via `@bot /style`).

Also: converter now accepts sharded `model.safetensors.index.json` layouts
alongside the single-file `model.safetensors`, so the 5B XL turbo variant
converts without a pre-processing step.

Parity on jieyue (seed=42, bf16 + flash-attn, turbo text2music 160s, fresh
converter output loaded via `from_pretrained`):
  waveform Pearson  = 0.999954
  spectral Pearson  = 0.999977
  max |a-b| bf16    = 4.3e-02  (dominated by the VAE tiling default flip)

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

* Address PR #13095 review from yiyixuxu (2026-04-23)

Code-level (22 threads):

1. Delete 3 dev/parity scripts (`scripts/audio_parity_jieyue.py`,
   `scripts/dit_parity_test.py`, `scripts/run_official_generate_music.py`)
   that shouldn't have been committed.
2. Rename `AutoencoderOobleck._encode_one` → `_encode` to match the convention
   used by other diffusers VAEs.
3. Delete the hard-coded `SHIFT_TIMESTEPS` / `VALID_SHIFTS` table in
   `pipeline_ace_step.py`: the per-shift turbo schedules are recovered
   exactly by `linspace(1, 0, N+1)[:-1]` plus the flow-match shift formula
   that the non-turbo branch already uses, so a single code path covers both.
4. Drop the backwards-compat `AceStepDiTModel` / `AceStepDiTLayer` aliases
   and every reference (top-level `__init__`, `models/__init__`,
   `transformers/__init__`, dummy objects, tests, docs toctree, model card).
   `AceStepTransformer1DModel` is the only exported name now.
5. Remove the unused `attention_mask` / `encoder_attention_mask` args from
   `AceStepTransformer1DModel.forward`; the model rebuilds its masks from
   the sequence shape and never consumed them.
6. In the DiT forward and both encoders, pass `None` instead of an all-zero
   `full_attn_mask` / `encoder_4d_mask` to non-sliding attention layers — SDPA
   dispatches to a faster kernel when the mask is None.
7. Inline the shared `_run_encoder_layers` helper directly into
   `AceStepLyricEncoder.forward` / `AceStepTimbreEncoder.forward` so layer
   calls are visible at the forward boundary (diffusers style).
8. Move `is_turbo` / `sample_rate` / `latents_per_second` from `@property`s
   that re-read module configs each call to cached attributes populated in
   `__init__` (Flux2-style), with a default-ACE-Step fallback when
   `self.vae` is offloaded. Drop the now-unused `SAMPLE_RATE = 48000`
   module-level constant and the three property definitions.
9. Warn + coerce `guidance_scale` to 1.0 on turbo (guidance-distilled)
   checkpoints, following `pipeline_flux2_klein`. Prevents over-guided
   audio when users forward their base/sft CFG settings to a turbo pipe.
10. Remove the `logger.warning(...)` paths that triggered on
    `silence_latent` missing/zero — those only fired for author-side
    unconverted checkpoints and tests; end users always load converted
    weights where the buffer is baked in.
11. Drop the redundant `with torch.no_grad():` wrappers inside
    `encode_prompt` — the pipeline's `__call__` runs under `torch.no_grad`
    already.
12. Strip "reviewer comment on PR #13095" attribution comments from three
    docstrings (here and everywhere).

Parity on jieyue (seed=42, bf16 + flash-attn, XL turbo 160s text2music):
  waveform Pearson = 0.9747
  spectral Pearson = 0.9895

The shift comes from full-attention layers switching `attn_mask=0_tensor` →
`attn_mask=None`, which dispatches to a different SDPA kernel on bf16. The
two outputs are algebraically equivalent for fp32 eager; on bf16+FA the
delta is dominated by kernel-level ULPs, well within the sampler-noise
band (ear-check on the 160s example confirms no audible regression).

Still open — AudioTokenizer/Detokenizer (deferred) + APG guider follow-up
(dims differ from `diffusers.guiders.adaptive_projected_guidance`, not a
drop-in; worth a separate PR).

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

* Address ACE-Step audio token and APG review

* Fix ACE-Step docs CI

* Address ACE-Step pipeline cleanup review

* Fix ACE-Step flash attention sliding windows

* Add ACE-Step callback properties

* Address ACE-Step final review comments

---------

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-authored-by: YiYi Xu <yixu310@gmail.com>
Co-authored-by: dg845 <58458699+dg845@users.noreply.github.com>
2026-04-30 18:30:44 -10:00
Álvaro Somoza
303c1d8b04 [Ernie-Image] Add lora support (#13575)
add lora support

Co-authored-by: Sayak Paul <spsayakpaul@gmail.com>
Co-authored-by: Dhruv Nair <dhruv.nair@gmail.com>
2026-04-30 22:02:09 +05:30
Param
716f246031 Fix UniPC scheduler device mismatch when using offloading (#13489)
When model/CPU offloading is enabled, self.sigmas may reside on CPU
while the sample tensor is on GPU. The multistep_uni_p_bh_update and
multistep_uni_c_bh_update methods index self.sigmas without moving
the result to the sample device, causing torch.stack(rks) to fail
with "Expected all tensors to be on the same device".

Move sigma values to the sample device immediately after indexing,
ensuring all derived tensors (lambda, h, rk) stay on the correct
device throughout the computation.

Fixes #13488

Co-authored-by: Dhruv Nair <dhruv.nair@gmail.com>
2026-04-30 05:16:20 -10:00
Sayak Paul
a5bc04696b NucleusMoE docs (#13661)
up
2026-04-30 15:17:04 +05:30
Sayak Paul
4744648a8d [ci] use tokenizers stable installtion in CI. (#13562)
* use tokenizers stable installtion in CI.

* up1

* up2

* up3
2026-04-30 14:34:50 +05:30
songh11
50cb2db4ad feat: support ring attention with arbitrary KV sequence lengths (#13545)
* feat: support ring attention with arbitrary KV sequence lengths

* fix: align ring_anything with ulysses_anything (size gather + unshard)

* docs: document ring_anything mode

* fix: merge hook branches, add ring_anything comment + guard

* docs: address ring_anything review comments

* docs: update ring_anything guidance

* docs: refine ring_anything guidance per review

* fix: address ring_anything style check

---------

Co-authored-by: Sayak Paul <spsayakpaul@gmail.com>
2026-04-30 14:12:28 +05:30
Ricardo-M-L
0fff459d1f Fix ErnieImagePipeline pre-computed prompt_embeds + num_images_per_prompt shape mismatch (#13532)
Fix ErnieImagePipeline pre-computed prompt_embeds + num_images_per_prompt

When a user passes pre-computed `prompt_embeds` (or `negative_prompt_embeds`)
alongside `num_images_per_prompt > 1`, `ErnieImagePipeline.__call__` did
not replicate the provided embeddings — the embeds list kept its original
length (one per prompt) while the latents were allocated with
`total_batch_size = batch_size * num_images_per_prompt`:

    text_hiddens = prompt_embeds            # length = batch_size (NOT replicated)
    ...
    latents = randn_tensor((total_batch_size, ...))   # batch * N in shape

In the denoise loop `text_bth.shape[0]` then mismatches
`latent_model_input.shape[0]`, so the transformer call:

    pred = self.transformer(
        hidden_states=latent_model_input,   # (batch*N*2, ...) under CFG
        text_bth=text_bth,                  # (batch*2, ...)
        ...
    )

fails with a shape mismatch inside the attention block. The standard
"pre-compute embeds once, generate N variants" usage pattern is broken.

`encode_prompt` already performs this replication internally
(`for _ in range(num_images_per_prompt): text_hiddens.append(hidden)`
at lines 158-160), so the non-embed path is unaffected — this only
impacts callers of the documented `prompt_embeds` / `negative_prompt_embeds`
arguments.

Mirror the replication logic in the pre-embed branches so both paths
yield a `text_hiddens` list of length `batch_size * num_images_per_prompt`.
2026-04-29 18:52:48 -10:00
Alexander Ivanov
2173c554ea [docs] fix typo in AutoencoderOobleck docs (#13642) (#13645) 2026-04-29 09:51:15 -07:00
YiYi Xu
0f1abc4ae8 [agents docs] update modular.md (#13568)
[agents docs] restructure modular.md: standalone reusability + IO-respect patterns

Distilled from the ErnieImage modular pipeline review (PR #13498):

- New "Common modular conventions" section: skim qwenimage / flux2 / wan /
  helios first, mirroring the references-driven shape of models.md / pipelines.md.
- Promoted "Standalone block reusability" to a Key pattern. Each block (text
  encoder, VAE encoder, prepare-latents, denoise, decoder) must run on its
  own; encoders take raw inputs only, per-prompt expansion happens in a
  dedicated input step inside the core denoise sequence. Replaces old
  gotchas #4 (pre-computed encoder outputs) and #5 (VAE encode in
  prepare-latents).
- Promoted "Flat block assembly" to a Key pattern (was gotcha #7).
- New gotcha "Respect the declared IO system": one rule covering three
  bypass directions — defensive `getattr` reads of declared
  components/state, undeclared `block_state` writes, and direct
  `state.set()` calls that skip `set_block_state` entirely.
- Reworked InputParam/OutputParam section to link to INPUT_PARAM_TEMPLATES /
  OUTPUT_PARAM_TEMPLATES in modular_pipeline_utils.py (the registry is
  dynamic) and added a non-template example.
- Added a distilled-checkpoint exception to the `guidance_scale`-as-input
  gotcha — distilled flux-style models legitimately accept it.
- Dropped the "inputs duplicating derivable state" gotcha (uncommon).

Co-authored-by: yiyi@huggingface.co <yiyi@ip-26-0-160-103.ec2.internal>
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-27 09:56:12 -10:00
Akshan Krithick
b231a6a896 Add Ernie-Image modular pipeline (#13498)
* Add Ernie-Image modular pipeline

* Address review

* Fix alphabetical ordering and generator type_hint

* Address review

* Add height,width as outputs of prompt enhancer

---------

Co-authored-by: YiYi Xu <yixu310@gmail.com>
2026-04-27 09:25:19 -10:00
YiYi Xu
7bd5680d13 [agents docs] add pipelines.md etc (#13567)
* [agents docs] add pipelines.md and restructure review rules

- Add .ai/pipelines.md: pipeline conventions and gotchas (config-derived
  values, no_grad discipline, reinventing scheduler logic, subclassing
  variants, # Copied from annotations).
- models.md: add Attention masks subsection inside Attention pattern;
  fold reference-implementations skim into conventions; consolidate
  __init__.py / _import_structure gotchas; trim gotchas covered by
  AGENTS.md (silent fallbacks, config serialization gap) or pipelines.md
  (no_grad, guider/scheduler reuse).
- review-rules.md: collapse to a short reviewer checklist that points
  into AGENTS / models / pipelines / modular gotchas; only LLM-specific
  pattern (ephemeral context) lives here directly.
- AGENTS.md: collapse defensive-code / unused-params / backwards-compat
  / deprecation rules into one umbrella bullet; replace inline pipeline
  bullet list with a pointer to pipelines.md.
- SKILL.md (model-integration): trim pre-PR self-review to a one-line
  pointer.

Sourced from the ACE-Step PR (#13095) review.

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

* Apply suggestions from code review

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

* Apply suggestion from @yiyixuxu

* Apply suggestions from code review

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

* fix capability-flags gotcha: drop fake attrs, tighten to real failure modes

`_supports_quantization` and `_supports_cache_class` don't exist in diffusers
(sayak flagged the first; the second was also fabricated). Replaced with the
two flags where the "advertised but unbacked" pattern is a real mistake:
`_supports_gradient_checkpointing` (needs `if self.gradient_checkpointing:`
branches in forward) and `_no_split_modules` (needs correct block class names
for `device_map`). Dropped `_supports_group_offloading` — its realistic
failure mode is forgetting to opt out, not opt in.

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

---------

Co-authored-by: yiyi@huggingface.co <yiyi@ip-26-0-160-103.ec2.internal>
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-authored-by: Sayak Paul <spsayakpaul@gmail.com>
Co-authored-by: Steven Liu <59462357+stevhliu@users.noreply.github.com>
2026-04-27 08:07:08 -10:00
Sayak Paul
f7fd76adcd [attention backends] fix ring CP for flash and flash 3 (#13182)
* tests: add cp backend and attention backend tests.

* up

* up

* up

* fix ring for flash and flash_3

* generate.

* Apply suggestions from code review

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

* up

* up

---------

Co-authored-by: Dhruv Nair <dhruv.nair@gmail.com>
2026-04-24 20:35:08 -03:00
Sayak Paul
dad80d728d [ci] simplify release workflow. (#13329)
* simplify release workflow.

* up

* trigger on branches too.

* restrict permissions to read.

* use sha

* remove determination step of latest branch

* resolve rest
2026-04-24 19:56:20 -03:00
Remy
d0c9cbad28 chore: bump doc-builder SHA for main doc build workflow (#13555) 2026-04-24 14:42:48 +02:00
hlky
a37f6f8394 Improve trust_remote_code (#13448)
* Robust trust check for custom_pipeline parameter of DiffusionPipeline.from_pretrained method

* test_custom_components_from_local_dir

* Apply style fixes

* fix

* Update src/diffusers/utils/dynamic_modules_utils.py

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

* Adjust tests and allow community pipeline

* DIFFUSERS_DISABLE_REMOTE_CODE

---------

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: Dhruv Nair <dhruv.nair@gmail.com>
2026-04-23 11:07:43 +05:30
Sayak Paul
267b7a0e4e [ci] feat: have pr labeler label for closing issues. (#13548)
feat: have pr labeler label for closing issues.
2026-04-22 17:53:14 -03:00
Sayak Paul
7c88e5fe21 [tests] fix group offloading with disk tests (#13491)
fix group offloading with disk tests
2026-04-22 11:41:37 -03:00
Dhruv Nair
50987b1290 [CI] Fix BnB tests (#13481)
* update

* update

* update
2026-04-22 13:19:32 +05:30
kaixuanliu
b8aebf4c12 add _repeated_blocks for ErnieImageTransformer2DModel (#13496)
Signed-off-by: Liu, Kaixuan <kaixuan.liu@intel.com>
Co-authored-by: dg845 <58458699+dg845@users.noreply.github.com>
2026-04-21 17:17:22 -07:00
Ricardo-M-L
b9d6420447 Fix AuraFlow attn processors applying norm_added_q to key projection (#13533)
Both AuraFlowAttnProcessor2_0 and FusedAuraFlowAttnProcessor2_0 were
calling attn.norm_added_q on encoder_hidden_states_key_proj while
guarded by a check on attn.norm_added_k. This applies the query
normalization layer to the key, which is a copy-paste error.

Consistent with every other attention processor in this file that
defines both norm_added_q and norm_added_k (e.g. FluxAttnProcessor,
CogVideoXAttnProcessor, HunyuanAttnProcessor), where norm_added_k is
applied to the added key projection.
2026-04-21 09:20:54 -10:00
kaixuanliu
3d30b7d9d2 Fix non-deterministic T5 outputs in HiDream pipeline tests (#13534)
avoid dropout of t5 model in hidream-image tests

Signed-off-by: Liu, Kaixuan <kaixuan.liu@intel.com>
Co-authored-by: Sayak Paul <spsayakpaul@gmail.com>
2026-04-21 21:58:40 +05:30
Ricardo-M-L
62bfa5a23e fix(freeu): run FFT in float32 for float16 inputs to avoid ComplexHalf (#13503)
* fix(freeu): run FFT in float32 for float16 inputs to avoid ComplexHalf

`fourier_filter` already upcasts `bfloat16` inputs to `float32` before
calling `torch.fft.fftn`, because PyTorch's FFT does not support bf16.
The same is true for `float16`: depending on the PyTorch version,
`fftn` either

- produces the experimental `torch.complex32` (ComplexHalf) dtype and
  emits a `UserWarning: ComplexHalf support is experimental`, or
- raises `RuntimeError: Unsupported dtype Half` outright.

Both paths were reachable from FreeU with half-precision models
(e.g. `sd-turbo` + `fp16` + `enable_freeu`) as reported in #12504.

Extend the existing upcast branch to cover `float16` too. The function
already downcasts the result back to `x_in.dtype` at the end, so the
externally observable dtype is unchanged.

Closes #12504.

* Address review: generalize upcast to non-float32 + fix ruff F821

- Apply @sayakpaul's suggestion: use `elif x.dtype != torch.float32:`
  so any non-float32 dtype (bf16, fp16, and future half-precision
  dtypes) is upcast to float32 before the FFT.
- Drop the `"torch.Tensor"` return annotation on the test helper
  that triggered ruff F821 in CI (torch is imported inside the
  method body, not at module scope).
2026-04-21 08:45:10 -03:00
chang-zhijie
c8c84018e0 add _native_npu_attention support mask shape like [B,1,1,S] (#13490)
* add _native_npu_attention support mask shape like [B,1,1,S]

* add _native_npu_attention support mask shape like [B,1,1,S]

* fix style

---------

Co-authored-by: YiYi Xu <yixu310@gmail.com>
2026-04-18 12:04:14 -10:00
Yad Fatah
77f8cf8bf5 Fix Flux2 non-diffusers guidance LoRA conversion (#13486)
* Fix Flux2 LoRA guidance conversion

* Handle expanded Flux2 LoRA block names

* Address Flux2 PR review feedback

---------

Co-authored-by: Sayak Paul <spsayakpaul@gmail.com>
2026-04-18 09:50:15 +05:30
Sayak Paul
656da843e8 [docs] add a mention of torchao and other backends in speed memory docs. (#13499)
add a mention of torchao and other backends in speed memory docs.
2026-04-18 09:22:22 +05:30
Aditya Borate
7448258505 Add FLUX.2 Klein Inpaint Pipeline (#13050)
* Add Flux2KleinInpaintPipeline

* Fixed mask channel mismatch and a bit of cleaning

* Added tests and minor refactors

* Added support for reference images for inpainting

* Style fixes

* Fixed the example docstring

* Corrected mask latent preparation for correct dimensional alignment

* replace masked_image_latents context with clean_source_latents, fix mask spatial alignment and remove unused VAE encoding

* Fix T-coordinate collision for conditioning

* Changed the default strength from 0.6 to 0.8

* Added reference image test and updated the frozenset

* Validated ref image, latent passing support and fixed ref image preprocessing

* Refined preprocessing with 1MP resolution cap and timestep tracking

* Updated typing, improved validation and changed the example docstring

* Style fixes

* Fixed batch inference discrepancy and addressed review comments

* Fixed a typo

Co-authored-by: Álvaro Somoza <asomoza@users.noreply.github.com>

* Apply suggestion from @asomoza

Co-authored-by: Álvaro Somoza <asomoza@users.noreply.github.com>

* Reused encoded latents and fix channel check consistency

* fixed pre-encoded latent preprocessing for source and ref images

* Apply style fixes

* Updated the docstring with the shape requirements

* Apply style fixes

* Fixed copies
2026-04-17 17:34:36 -04:00
Sayak Paul
160852de68 add an example of spmd for flux on v5e-8 (#13474)
* add an example of spmd for flux on v5e-8

* Apply suggestions from code review

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

* add check
2026-04-17 14:41:37 +05:30
Baihao You
8d30d05de1 fix(qwen): fix CFG failing when passing neg prompt embeds with none mask (#13379)
* fix(qwen): fix CFG failing when passing neg prompt embeds with none mask

* fix(qwen): safely handle missing embeds masks in edit and inpaint pipelines

* test(qwen): add tests for true cfg scale without neg prompt mask

* fix(qwen): correct comments for copied functions in controlnet and inpaint pipelines

* fix(qwen): add warnings for missing prompt and negative prompt masks in pipelines

* test(qwen): use torch_device and clarify dummy inputs in cfg mask tests

* fix(qwen): address Claude PR review feedback

* fix(qwen): fix warning message based on reviewer suggestion

---------

Co-authored-by: Sayak Paul <spsayakpaul@gmail.com>
2026-04-17 13:33:58 +05:30
Luc Georges
3a4421c89b feat: bump safetensors to 0.8.0-rc.0 (#13470)
* feat: bump safetensors to `0.8.0-rc.0`

* feat: run `make deps_table_update`

---------

Co-authored-by: Sayak Paul <spsayakpaul@gmail.com>
2026-04-17 07:42:38 +05:30
Lancer
c507097764 [Bugfix] Fix shape mismatch in LongCatAudioDiTTransformer conversion (#13494)
Signed-off-by: Lancer <maruixiang6688@gmail.com>
2026-04-16 16:49:58 -07:00
songh11
a50340147c fix(ernie-image): avoid locals() comprehension scope issue in callback kwargs (#13478) 2026-04-16 13:42:43 -10:00
YiYi Xu
3a7ecb19fc [agents docs] add float64 gotcha (#13472)
* [docs] add float64 + runtime weight-dtype gotchas to models.md

Document two dtype pitfalls surfaced by Ernie-Image follow-up #13464:
unconditional torch.float64 in RoPE/precompute (breaks MPS/NPU) and
reading a child module's weight dtype at runtime (breaks gguf/quant).

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

* update claude config to allow .ai folder

* [ci] fetch default branch before .ai/ checkout in claude_review

When triggered by pull_request_review_comment, actions/checkout lands
on the PR head and fetch-depth=1 means origin/main isn't tracked, so
the follow-up `git checkout origin/main -- .ai/` fails with exit 128.
Fetch the default branch explicitly first.

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

* combine #10 into #8

* Apply suggestions from code review

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

---------

Co-authored-by: yiyi@huggingface.co <yiyi@ip-26-0-160-103.ec2.internal>
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-16 13:41:48 -10:00
Akshan Krithick
b3889ea478 Add modular pipeline for HunyuanVideo 1.5 (#13389)
* Add modular pipeline support for HunyuanVideo 1.5

* Fix I2V latent/cond spatial dimension mismatch

* Fix guidance_scale default to 7.5 matching ClassifierFreeGuidance

* Fix tokenizer type: use Qwen2TokenizerFast to match model

* Fix system message string formatting to match standard pipeline

* Rewrite HunyuanVideo 1.5 modular: use standard pipeline methods directly

* Remove I2V exports (T2V only for now)

* Fix encoder: use static methods directly instead of encode_prompt

* Inline all standard pipeline methods, remove runtime dependency

* Add HunyuanVideo 1.5 image-to-video modular blocks

* Fix missing FrozenDict import in before_denoise.py

* auto-generated docstrings via #auto_docstring

* Fix ruff lint and format issues

* use InputParam/OutputParam templates and fix ruff

* Address LTX review feedback here like add AutoBlocks, refactor I2V latents, lift encoders

* Add workflow map, workflow tests, auto docstrings, export only AutoBlocks

* Address Claude CI review

* Address claude CI review 2

---------

Co-authored-by: YiYi Xu <yixu310@gmail.com>
2026-04-16 10:47:51 -10:00
Pauline Bailly-Masson
e0c1ec462f add PR fork workable (#13438)
* add PR fork workable

* Apply suggestion from @paulinebm

* Apply suggestion from @paulinebm

* Apply suggestion from @yiyixuxu

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

* Apply suggestions from code review

Co-authored-by: Pauline Bailly-Masson <155966238+paulinebm@users.noreply.github.com>

---------

Co-authored-by: Sayak Paul <spsayakpaul@gmail.com>
Co-authored-by: YiYi Xu <yixu310@gmail.com>
2026-04-16 15:19:10 +05:30
Sayak Paul
33a13172ff [core] fix autoencoderkl qwenimage for xla (#13480)
fix autoencoderkl qwenimage for xla
2026-04-16 11:29:22 +05:30
Lancer
947bc23ba4 [chore] Add diffusers-format example to LongCatAudioDiTPipeline (#13483)
* [chore] Add diffusers-format example and seed parameter to LongCatAudioDiTPipeline

Signed-off-by: Lancer <maruixiang6688@gmail.com>

* Apply style fixes

* Apply suggestions from code review

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

* upd

Signed-off-by: Lancer <maruixiang6688@gmail.com>

* Apply style fixes

---------

Signed-off-by: Lancer <maruixiang6688@gmail.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: dg845 <58458699+dg845@users.noreply.github.com>
2026-04-15 21:52:15 -07:00
Sukesh Perla
71a6fd9f0d Remove compile bottlenecks from ZImage pipeline (#13461)
* [core] Remove DtoH syncs from ZImage pipeline denoising loop

* [core] Replace boolean mask indexing with torch.where in ZImage transformer

Boolean mask indexing (tensor[mask] = val) implicitly calls nonzero(),
which triggers a DtoH sync that stalls the CPU while the GPU queue drains.
Replacing it with torch.where eliminates these syncs from the transformer's
pad-token assignment.

Profiling (4-step turbo, fix_2 vs fix_1):
- Eager: nonzero CPU time drops from ~2091 ms to <1 ms; index_put eliminated
- Compile: nonzero CPU time drops from ~3057 ms to <1 ms; index_put eliminated

---------

Co-authored-by: Sayak Paul <spsayakpaul@gmail.com>
2026-04-15 16:25:39 +05:30
Remy
a68f3677b7 chore: bump doc-builder SHA for PR upload workflow (#13476) 2026-04-15 12:16:24 +02:00
Alexey Zolotenkov
d30831683c Fix Flux2 DreamBooth prior preservation prompt repeats (#13415)
Co-authored-by: Sayak Paul <spsayakpaul@gmail.com>
2026-04-15 14:50:45 +05:30
Lancer
c41a3c3ed8 [Feat] Adds LongCat-AudioDiT pipeline (#13390)
* Add LongCat-AudioDiT pipeline

Signed-off-by: Lancer <maruixiang6688@gmail.com>

* upd

Signed-off-by: Lancer <maruixiang6688@gmail.com>

* upd

* Apply suggestions from code review

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

* upd

Signed-off-by: Lancer <maruixiang6688@gmail.com>

* upd

Signed-off-by: Lancer <maruixiang6688@gmail.com>

* upd

Signed-off-by: Lancer <maruixiang6688@gmail.com>

* upd

Signed-off-by: Lancer <maruixiang6688@gmail.com>

* Apply style fixes

* upd

Signed-off-by: Lancer <maruixiang6688@gmail.com>

* upd

Signed-off-by: Lancer <maruixiang6688@gmail.com>

* Apply style fixes

* upd

Signed-off-by: Lancer <maruixiang6688@gmail.com>

* Apply style fixes

* upd

Signed-off-by: Lancer <maruixiang6688@gmail.com>

---------

Signed-off-by: Lancer <maruixiang6688@gmail.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-04-15 00:47:38 -07:00
Akash Santra
0d79fc2e60 fix(profiling): preserve instance isolation when decorating methods (#13471)
* fix(profiling): preserve instance isolation when decorating methods

* fix(profiling): scope instance isolation fix to LTX2 pipelines
2026-04-15 07:46:20 +05:30
Sayak Paul
e4d219b366 [tests] fix training tests (#13442)
* fix textual inversion

* fix rest
2026-04-15 06:56:29 +05:30
YiYi Xu
e9c092d886 [agent] add modular doc (#13410)
* merge

* update based on feedback

---------

Co-authored-by: yiyi@huggingface.co <yiyi@ip-26-0-160-103.ec2.internal>
2026-04-14 07:43:26 -10:00
Sayak Paul
f65f135f64 [tests] xfail clip related issues. (#13454)
xfail clip related issues./
2026-04-14 22:33:25 +05:30
Sayak Paul
273b445426 [tests] fix deprecated attention processor testing. (#13469)
fix deprecated attention processor testing.
2026-04-14 22:05:39 +05:30
Alexey Zolotenkov
526498d219 Fix Qwen Image DreamBooth prior-preservation batch ordering (#13441)
Fix Qwen Image DreamBooth prior-preservation batching

Co-authored-by: Sayak Paul <spsayakpaul@gmail.com>
2026-04-14 18:00:37 +05:30
HsiaWinter
6a339ce637 fix some dtype issue for gguf / some gpu backends (#13464) 2026-04-13 18:41:01 -10:00
Juan Acevedo
26bb7fa0cb [ptxla] fix pytorch xla inference on TPUs. (#13463)
Co-authored-by: Juan Acevedo <jfacevedo@google.com>
2026-04-14 09:21:26 +05:30