YAML Metadata Warning:empty or missing yaml metadata in repo card
Check out the documentation for more information.
Qwen-Image 2.1 custom blocks
Independent text-to-image custom blocks for the base and Turbo checkpoints. These are actual Modular Diffusers stages, not a wrapper around QwenImage21Pipeline. Editing and image conditioning are outside this initial workflow.
Components retain their native Diffusers/Transformers forwards. The VAE is AutoencoderKLQwenImage21, with no external strip-decoder patch. All numerical adaptations are from the Apache-2.0 Diffusers QwenImage21Pipeline; its copyright and license notices are retained. No GPL helper is included.
QwenImage21Blocks: base checkpoint, default 25 steps unless saved sigmas override.QwenImage21TurboBlocks: requires saved checkpoint sigmas or explicit sigmas.- Standalone stages: text_encoder, prepare, denoise, decode.
- CFG is configured through ClassifierFreeGuidance; no old-Qwen norm rescaling.
- KV caches are call-local and separate for conditional/unconditional passes.
- Encoder outputs are per prompt; preparation expands them per generated image.
With custom offload runtimes, pass execution_device to the encoder and
preparation calls. CPU-resident weights do not identify the compute device.
Without an explicit device, these stages retain Diffusers device inference.
Preparation places conditioning, latents and timesteps on the compute device
once; the scheduler and native model forward are unchanged.
Loading trusted code
from diffusers import ModularPipelineBlocks
from huggingface_hub import snapshot_download
code = snapshot_download(
"elismasilva/qwen_image_2.1_custom_blocks",
allow_patterns=["*.py", "modular_config.json"],
# revision="<published commit SHA>", # Pin code for reproducibility.
)
blocks = ModularPipelineBlocks.from_pretrained(code, trust_remote_code=True)
pipeline = blocks.init_pipeline()
The root configuration selects the base blockset. For Turbo, use
QwenImage21TurboPrepareStep from the loaded module with the checkpoint's saved
sample_sigmas; do not replace that schedule with a base step count.
Stages remain independently usable for phase-staged component cleanup.
The optional QwenImage21ImageVAE preserves the native decoder by default.
Single-frame cache removal and residual aliasing are explicit opt-ins; they
do not change installed Diffusers classes. Direct padding remains experimental.
Selected CPU parity contracts and Windows/Linux base-checkpoint generations
are recorded in the DDO examples host,
under docs/qwen-image-21.md and experiments/dynamic_offload_results.md.
This is not arbitrary-shape, Turbo CUDA or image-editing acceptance.
Use a current Diffusers build providing the Qwen-Image 2.1 component classes.
DDO is optional: these blocks retain native component forwards.