Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 44 additions & 2 deletions docs/source/en/_toctree.yml
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,8 @@
title: bitsandbytes
- local: quantization/gguf
title: gguf
- local: quantization/nunchaku
title: Nunchaku Lite
- local: quantization/torchao
title: torchao
- local: quantization/quanto
Expand All @@ -182,6 +184,8 @@
title: NVIDIA ModelOpt
- local: quantization/autoround
title: AutoRound
- local: quantization/sdnq
title: SDNQ
title: Quantization
- isExpanded: false
sections:
Expand Down Expand Up @@ -218,6 +222,8 @@
title: Task recipes
- local: using-diffusers/write_own_pipeline
title: Understanding pipelines, models and schedulers
- local: using-diffusers/cli
title: Command line interface
- local: community_projects
title: Projects built with Diffusers
- local: conceptual/philosophy
Expand All @@ -228,8 +234,6 @@
title: How to contribute?
- local: conceptual/ethical_guidelines
title: Diffusers' Ethical Guidelines
- local: conceptual/evaluation
title: Evaluating Diffusion Models
title: Resources
- isExpanded: false
sections:
Expand Down Expand Up @@ -353,8 +357,12 @@
title: HunyuanVideoTransformer3DModel
- local: api/models/ideogram4_transformer2d
title: Ideogram4Transformer2DModel
- local: api/models/transformer_joyimage_edit_plus
title: JoyImageEditPlusTransformer3DModel
- local: api/models/transformer_joyimage
title: JoyImageEditTransformer3DModel
- local: api/models/krea2_transformer2d
title: Krea2Transformer2DModel
- local: api/models/latte_transformer3d
title: LatteTransformer3DModel
- local: api/models/longcat_image_transformer2d
Expand All @@ -367,6 +375,10 @@
title: Lumina2Transformer2DModel
- local: api/models/lumina_nextdit2d
title: LuminaNextDiT2DModel
- local: api/models/minimax_h3_transformer3d
title: MiniMaxH3Transformer3DModel
- local: api/models/minimax_music3_transformer
title: MiniMaxMusic3Transformer1DModel
- local: api/models/mochi_transformer3d
title: MochiTransformer3DModel
- local: api/models/motif_video_transformer_3d
Expand Down Expand Up @@ -395,6 +407,8 @@
title: Transformer2DModel
- local: api/models/transformer_temporal
title: TransformerTemporalModel
- local: api/models/wan_animate_2_transformer_3d
title: WanAnimate2Transformer3DModel
- local: api/models/wan_animate_transformer_3d
title: WanAnimateTransformer3DModel
- local: api/models/wan_transformer_3d
Expand Down Expand Up @@ -451,6 +465,10 @@
title: AutoencoderKLLTXVideo
- local: api/models/autoencoderkl_magvit
title: AutoencoderKLMagvit
- local: api/models/autoencoderkl_minimax_h3
title: AutoencoderKLMiniMaxH3
- local: api/models/autoencoderkl_minimax_h3_audio
title: AutoencoderKLMiniMaxH3Audio
- local: api/models/autoencoderkl_mochi
title: AutoencoderKLMochi
- local: api/models/autoencoderkl_qwenimage
Expand All @@ -461,6 +479,8 @@
title: AutoencoderRAE
- local: api/models/consistency_decoder_vae
title: ConsistencyDecoderVAE
- local: api/models/ltx2_diffusion_decoder
title: LTX2VideoDiffusionDecoderModel
- local: api/models/autoencoder_oobleck
title: Oobleck AutoEncoder
- local: api/models/autoencoder_tiny
Expand Down Expand Up @@ -553,6 +573,8 @@
title: InstructPix2Pix
- local: api/pipelines/joyimage_edit
title: JoyImage Edit
- local: api/pipelines/joyimage_edit_plus
title: JoyImage Edit Plus
- local: api/pipelines/kandinsky
title: Kandinsky 2.1
- local: api/pipelines/kandinsky_v22
Expand All @@ -563,6 +585,8 @@
title: Kandinsky 5.0 Image
- local: api/pipelines/kolors
title: Kolors
- local: api/pipelines/krea2
title: Krea 2
- local: api/pipelines/latent_consistency_models
title: Latent Consistency Models
- local: api/pipelines/latent_diffusion
Expand Down Expand Up @@ -591,6 +615,8 @@
title: PixArt-Σ
- local: api/pipelines/prx
title: PRX
- local: api/pipelines/prx_pixel
title: PRX Pixel
- local: api/pipelines/qwenimage
title: QwenImage
- local: api/pipelines/sana
Expand Down Expand Up @@ -641,6 +667,8 @@
title: Z-Image
title: Image
- sections:
- local: api/pipelines/diffusion_gemma
title: DiffusionGemma
- local: api/pipelines/llada2
title: LLaDA2
title: Text
Expand Down Expand Up @@ -675,6 +703,10 @@
title: LTX-2
- local: api/pipelines/ltx_video
title: LTXVideo
- local: api/pipelines/minimax_music3
title: MiniMax Music 3
- local: api/pipelines/minimax_h3
title: MiniMax-H3
- local: api/pipelines/mochi
title: Mochi
- local: api/pipelines/motif_video
Expand All @@ -685,6 +717,8 @@
title: Stable Video Diffusion
- local: api/pipelines/wan
title: Wan
- local: api/pipelines/wan_animate_2
title: Wan-Animate-2
title: Video
title: Pipelines
- sections:
Expand All @@ -710,6 +744,8 @@
title: DDPMScheduler
- local: api/schedulers/deis
title: DEISMultistepScheduler
- local: api/schedulers/discrete_ddim
title: DiscreteDDIMScheduler
- local: api/schedulers/multistep_dpm_solver_inverse
title: DPMSolverMultistepInverse
- local: api/schedulers/multistep_dpm_solver
Expand All @@ -722,6 +758,8 @@
title: EDMDPMSolverMultistepScheduler
- local: api/schedulers/edm_euler
title: EDMEulerScheduler
- local: api/schedulers/entropy_bound
title: EntropyBoundScheduler
- local: api/schedulers/euler_ancestral
title: EulerAncestralDiscreteScheduler
- local: api/schedulers/euler
Expand Down Expand Up @@ -750,6 +788,8 @@
title: LCMScheduler
- local: api/schedulers/lms_discrete
title: LMSDiscreteScheduler
- local: api/schedulers/minimax_h3
title: MiniMaxH3Scheduler
- local: api/schedulers/pndm
title: PNDMScheduler
- local: api/schedulers/repaint
Expand All @@ -774,6 +814,8 @@
title: Custom activation functions
- local: api/cache
title: Caching methods
- local: api/dype
title: Resolution extrapolation
- local: api/normalization
title: Custom normalization layers
- local: api/utilities
Expand Down
46 changes: 46 additions & 0 deletions docs/source/en/api/dype.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<!-- Copyright 2025 The HuggingFace Team. All rights reserved.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
specific language governing permissions and limitations under the License. -->

# Resolution extrapolation

Training-free methods that let RoPE-based diffusion transformers such as [`FluxTransformer2DModel`] generate above their trained resolution (for example 4096x4096 from a model trained at 1024x1024), with no fine-tuning and no extra sampling cost.

[DyPE](https://huggingface.co/papers/2510.20766) (Dynamic Position Extrapolation) swaps the transformer's rotary positional embedding for a timestep-aware YaRN / NTK-by-parts schedule that only engages above the trained resolution. [SEGA](https://huggingface.co/papers/2605.22668) (Spectral-Energy Guided Attention) additionally applies a per-frequency, content-aware attention temperature derived from the latent's spectrum, which suppresses the high-frequency speckle a scalar temperature can leave in flat regions at very high resolutions. Both are enabled through [`apply_dype`].

```python
import torch
from diffusers import FluxPipeline, apply_dype

pipe = FluxPipeline.from_pretrained("black-forest-labs/FLUX.1-Krea-dev", torch_dtype=torch.bfloat16)
pipe.enable_model_cpu_offload()

# method="yarn" (default) is plain DyPE; method="spectral" adds SEGA spectral attention.
apply_dype(pipe.transformer, method="spectral")

# Above the trained resolution, also flatten the flow-matching shift schedule so the sampler
# does not stall near pure noise (the default shift `mu` grows with the image sequence length).
pipe.scheduler.register_to_config(base_shift=1.15, max_shift=1.15)

image = pipe(
"a sunlit alpine meadow, snow-capped peaks, clear blue sky",
height=4096,
width=4096,
guidance_scale=4.5,
num_inference_steps=28,
).images[0]
```

> [!TIP]
> `apply_dype` is a no-op at or below the trained resolution (1024x1024 for Flux), so the hook can stay applied for standard-resolution generation.

## apply_dype

[[autodoc]] apply_dype
4 changes: 4 additions & 0 deletions src/diffusers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@
)
_import_structure["hooks"].extend(
[
"DyPEHook",
"FasterCacheConfig",
"FirstBlockCacheConfig",
"HookRegistry",
Expand All @@ -184,6 +185,7 @@
"SmoothedEnergyGuidanceConfig",
"TaylorSeerCacheConfig",
"TextKVCacheConfig",
"apply_dype",
"apply_faster_cache",
"apply_first_block_cache",
"apply_layer_skip",
Expand Down Expand Up @@ -1036,6 +1038,7 @@
TangentialClassifierFreeGuidance,
)
from .hooks import (
DyPEHook,
FasterCacheConfig,
FirstBlockCacheConfig,
HookRegistry,
Expand All @@ -1045,6 +1048,7 @@
SmoothedEnergyGuidanceConfig,
TaylorSeerCacheConfig,
TextKVCacheConfig,
apply_dype,
apply_faster_cache,
apply_first_block_cache,
apply_layer_skip,
Expand Down
1 change: 1 addition & 0 deletions src/diffusers/hooks/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

if is_torch_available():
from .context_parallel import apply_context_parallel
from .dype import DyPEHook, apply_dype
from .faster_cache import FasterCacheConfig, apply_faster_cache
from .first_block_cache import FirstBlockCacheConfig, apply_first_block_cache
from .group_offloading import apply_group_offloading
Expand Down
Loading
Loading