Skip to main content

1. Model Introduction

Qwen-Image is a 20B text-to-image model built for strong prompt following and precise rendering of English and Chinese text. It is especially useful for posters, signs, diagrams, and dense layouts where typography and spatial relationships matter as much as general image quality. This page covers generation rather than editing: use Qwen-Image-Edit when an existing image, subject identity, or untouched region must be preserved. The full checkpoint is memory-heavy, while the validated ModelOpt NVFP4 release provides a supported low-precision deployment option with an expected quality tradeoff.

2. SGLang-diffusion Installation

SGLang-diffusion offers multiple installation methods. You can choose the most suitable installation method based on your hardware platform and requirements. Please refer to the official SGLang-diffusion installation guide for installation instructions.

3. Model Deployment

This section provides deployment configurations optimized for different hardware platforms and use cases.

3.1 Basic Configuration

Qwen-Image is a text-to-image model. The recommended launch configurations vary by hardware. SGLang supports serving Qwen-Image on NVIDIA B200, B300, H200, H100, AMD MI300X, MI325X, MI355X GPUs and Ascend A2, A3 NPUs. Interactive Command Generator: Use the configuration selector below to automatically generate the appropriate deployment command for your hardware platform. For the validated ModelOpt NVFP4 checkpoint on Blackwell, load the published Qwen-Image-2512 NVFP4 repo directly:
Command
For high-resolution B200 generations, the FlashInfer CUTLASS FP4 GEMM backend can be faster than the default TensorRT-LLM FP4 GEMM backend:
Command

3.2 Fixed-resolution latency on two H200 GPUs

For Qwen/Qwen-Image-2512 at 1024x1024, use breakable CUDA graph (BCG) to reduce launch overhead across graph-safe DiT segments while retaining explicit breakpoints around unsupported operations. This recipe was validated on two NVIDIA H200 GPUs with 50 denoising steps and no classifier-free guidance:
Command
Declare every production resolution in --warmup-resolutions. A request at an uncaptured resolution runs eagerly, so omitting 1024x1024 removes the gain from this recipe. Graph capture used about 5 GB more peak memory per GPU in the validation run. On CUDA, the TP path dispatches supported collectives through SRT CustomAllReduceV2. At 1024x1024, Qwen-Image reduces 24 MiB row-parallel outputs; the diffusion runtime reserves a 32 MiB V2 workspace so these collectives do not fall back to NCCL. If profiling shows large NCCL all-reduce kernels again, first confirm that V2 is enabled and the requested shape fits the workspace. BCG changed floating-point execution order but not the sampling algorithm. The fixed-seed output measured 0.984 SSIM and 39.7 dB PSNR against eager output; use eager execution when you require bit-exact output. Regional torch.compile was also tested on this profile and did not improve steady-state latency.

3.3 Configuration Tips

See Performance Optimization for acceleration features and their runtime requirements.
  • --vae-path: Path to a custom VAE model or HuggingFace model ID (e.g., fal/FLUX.2-Tiny-AutoEncoder). If not specified, the VAE will be loaded from the main model path.
  • --num-gpus: Number of GPUs to use
  • --tp-size: Tensor parallelism size (only for the encoder; should not be larger than 1 if text encoder offload is enabled, as layer-wise offload plus prefetch is faster)
  • --sp-degree: Sequence parallelism size (typically should match the number of GPUs)
  • --ulysses-degree: The degree of DeepSpeed-Ulysses-style SP in USP
  • --ring-degree: The degree of ring attention-style SP in USP
AMD ROCm Notes: Requires SGLang >= v0.5.8.

4. API Usage

For complete API documentation, please refer to the official API usage guide.

4.1 Generate an Image

Example

4.2 Advanced Usage

4.2.1 Cache-DiT Acceleration

SGLang integrates Cache-DiT, a caching acceleration engine for Diffusion Transformers (DiT), to achieve up to 7.4x inference speedup with minimal quality loss. You can set SGLANG_CACHE_DIT_ENABLED=True to enable it. For more details, please refer to the SGLang Cache-DiT documentation. Basic Usage
Command
Advanced Usage
  • DBCache Parameters: DBCache controls block-level caching behavior:
ParameterEnv VariableDefaultDescription
FnSGLANG_CACHE_DIT_FN1Number of first blocks to always compute
BnSGLANG_CACHE_DIT_BN0Number of last blocks to always compute
WSGLANG_CACHE_DIT_WARMUP4Warmup steps before caching starts
RSGLANG_CACHE_DIT_RDT0.24Residual difference threshold
MCSGLANG_CACHE_DIT_MC3Maximum continuous cached steps
  • TaylorSeer Configuration: TaylorSeer improves caching accuracy using Taylor expansion:
ParameterEnv VariableDefaultDescription
EnableSGLANG_CACHE_DIT_TAYLORSEERfalseEnable TaylorSeer calibrator
OrderSGLANG_CACHE_DIT_TS_ORDER1Taylor expansion order (1 or 2)
Combined Configuration Example:
Command

4.2.2 CPU Offload

  • --dit-cpu-offload: Use CPU offload for DiT inference. Enable if run out of memory.
  • --text-encoder-cpu-offload: Use CPU offload for text encoder inference.
  • --vae-cpu-offload: Use CPU offload for VAE.
  • --pin-cpu-memory: Pin memory for CPU offload. Only added as a temp workaround if it throws “CUDA error: invalid argument”.

4.2.3 Known LoRA examples

Use --lora-path at startup or the LoRA management API to load an adapter. Known Qwen-Image examples include:

5. Benchmark

Test Environment:
  • Hardware: AMD Instinct MI300X GPU (1x)
  • Model: Qwen/Qwen-Image
  • Docker Image: lmsysorg/sglang:v0.5.8-rocm700-mi30x
  • sglang diffusion version: 0.5.8

5.1 Speedup Benchmark

5.1.1 Generate an image

Server Command:
Command
Benchmark Command:
Command
Result:
Output

5.1.2 Generate images with high concurrency

Benchmark Command:
Command
Result:
Output