--- title: Qwen-Image-Edit-2511 metatags: description: "Deploy Qwen-Image-Edit-2511 with SGLang - 20B image editing model with text rendering, character consistency, and geometric reasoning." --- import { DiffusionModelTags } from '/src/snippets/diffusion/model-tags.jsx'; import { QwenImageEditDeployment } from '/src/snippets/diffusion/qwen-image-edit-deployment.jsx'; ## 1. Model Introduction [Qwen-Image-Edit-2511](https://huggingface.co/Qwen/Qwen-Image-Edit-2511) is the 20B editing counterpart to Qwen-Image. It is strongest at changing text, materials, lighting, viewpoint, or composition while reducing drift in regions that were not requested to change. Choose it for identity-sensitive portrait edits, multi-person composition, typography replacement, and geometry-aware design work. It is substantially heavier than small specialist editors, and consistency is improved rather than guaranteed; evaluate untouched-region drift on the actual editing workload. ## 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](https://docs.sglang.io/docs/sglang-diffusion/installation) 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-Edit-2511 is a 20B parameter model optimized for image editing tasks. The recommended launch configurations vary by hardware. **Interactive Command Generator**: Use the configuration selector below to automatically generate the appropriate deployment command for your hardware platform. ### 3.2 Configuration Tips See [Performance Optimization](/docs/sglang-diffusion/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 ### 3.3 Decompose an image into layers on H200 `Qwen/Qwen-Image-Layered` returns separate RGBA images. For this model, `--num-frames 4` requests four output layers. The CLI saves all four PNGs, and `DiffGenerator.generate()` returns one result per layer. On Linux with NVIDIA CUDA and two H200 GPUs, you can run the conditional and unconditional branches on separate GPUs: ```bash Command CUDA_VISIBLE_DEVICES=0,1 sglang generate \ --model-path Qwen/Qwen-Image-Layered \ --num-gpus 2 \ --cfg-parallel-size 2 \ --tp-size 1 \ --ulysses-degree 1 \ --quality lossless \ --enable-torch-compile false \ --warmup-mode request \ --width 640 --height 640 --num-frames 4 \ --num-inference-steps 50 --guidance-scale 4.0 --seed 42 \ --image-path https://raw.githubusercontent.com/QwenLM/Qwen-Image-Layered/main/assets/test_images/4.png \ --prompt "a high quality, cute halloween themed illustration, consistent style and lighting" \ --output-path outputs/qwen-layered \ --save-output ``` For a single H200, set `CUDA_VISIBLE_DEVICES=0`, `--num-gpus 1`, and `--cfg-parallel-size 1`. Both configurations use eager execution. Layered does not currently support breakable CUDA graph; enabling BCG falls back to eager execution. The Layered CFG policy gathers the branch predictions before applying the single-GPU arithmetic order, preserving BF16 rounding and alpha values in the validated fixed-seed example. Each GPU still holds a full DiT replica, so CFG parallelism reduces request latency without reducing the model memory needed on each GPU. ## 4. API Usage For complete API documentation, please refer to the [official API usage guide](/docs/sglang-diffusion/api/openai_api). ### 4.1 Edit an Image ```python Example import base64 from openai import OpenAI client = OpenAI(api_key="EMPTY", base_url="http://localhost:3000/v1") response = client.images.edit( model="Qwen/Qwen-Image-Edit-2511", image=open("input.png", "rb"), prompt="Change the color of the taxi to black.", n=1, response_format="b64_json", ) # Save the edited image image_bytes = base64.b64decode(response.data[0].b64_json) with open("output.png", "wb") as f: f.write(image_bytes) ``` ### 4.2 Advanced Usage #### 4.2.1 Cache-DiT Acceleration SGLang integrates [Cache-DiT](https://github.com/vipshop/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](/docs/sglang-diffusion/cache_dit). **Basic Usage** ```bash Command SGLANG_CACHE_DIT_ENABLED=true sglang serve --model-path Qwen/Qwen-Image-Edit-2511 ``` **Advanced Usage** - DBCache Parameters: DBCache controls block-level caching behavior:
Parameter Env Variable Default Description
Fn `SGLANG_CACHE_DIT_FN` 1 Number of first blocks to always compute
Bn `SGLANG_CACHE_DIT_BN` 0 Number of last blocks to always compute
W `SGLANG_CACHE_DIT_WARMUP` 4 Warmup steps before caching starts
R `SGLANG_CACHE_DIT_RDT` 0.24 Residual difference threshold
MC `SGLANG_CACHE_DIT_MC` 3 Maximum continuous cached steps
- TaylorSeer Configuration: TaylorSeer improves caching accuracy using Taylor expansion:
Parameter Env Variable Default Description
Enable `SGLANG_CACHE_DIT_TAYLORSEER` false Enable TaylorSeer calibrator
Order `SGLANG_CACHE_DIT_TS_ORDER` 1 Taylor expansion order (1 or 2)
Combined Configuration Example: ```bash Command SGLANG_CACHE_DIT_ENABLED=true \ SGLANG_CACHE_DIT_FN=2 \ SGLANG_CACHE_DIT_BN=1 \ SGLANG_CACHE_DIT_WARMUP=4 \ SGLANG_CACHE_DIT_RDT=0.4 \ SGLANG_CACHE_DIT_MC=4 \ SGLANG_CACHE_DIT_TAYLORSEER=true \ SGLANG_CACHE_DIT_TS_ORDER=2 \ sglang serve --model-path Qwen/Qwen-Image-Edit-2511 ``` #### 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. - `--image-encoder-cpu-offload`: Use CPU offload for image 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](/docs/sglang-diffusion/api/openai_api#lora-management) to load an adapter. Known Qwen-Image-Edit examples include: - [`ostris/qwen_image_edit_inpainting`](https://huggingface.co/ostris/qwen_image_edit_inpainting) - [`lightx2v/Qwen-Image-Edit-2511-Lightning`](https://huggingface.co/lightx2v/Qwen-Image-Edit-2511-Lightning) ## 5. Benchmark Test Environment: - Hardware: NVIDIA B200 GPU (1x) - Model: Qwen/Qwen-Image-Edit-2511 - sglang diffusion version: 0.5.6.post2 ### 5.1 Speedup Benchmark #### 5.1.1 Edit a image **Server Command**: ```shell Command sglang serve --model-path Qwen/Qwen-Image-Edit-2511 --port 30000 ``` **Benchmark Command**: ```shell Command python3 -m sglang.multimodal_gen.benchmarks.bench_serving \ --dataset vbench --task image-to-image --num-prompts 1 --max-concurrency 1 ``` **Result**: ```text Output ================= Serving Benchmark Result ================= Model: Qwen/Qwen-Image-Edit-2511 Dataset: vbench Task: image-to-image -------------------------------------------------- Benchmark duration (s): 35.31 Request rate: inf Max request concurrency: 1 Successful requests: 1/1 -------------------------------------------------- Request throughput (req/s): 0.03 Latency Mean (s): 35.3053 Latency Median (s): 35.3053 Latency P99 (s): 35.3053 -------------------------------------------------- Peak Memory Max (MB): 47959.35 Peak Memory Mean (MB): 47959.35 Peak Memory Median (MB): 47959.35 ============================================================ ``` #### 5.1.2 Edit a image with high concurrency **Benchmark Command**: ```shell Command python3 -m sglang.multimodal_gen.benchmarks.bench_serving \ --dataset vbench --task image-to-image --num-prompts 20 --max-concurrency 20 ``` **Result**: ```text Output ================= Serving Benchmark Result ================= Model: Qwen/Qwen-Image-Edit-2511 Dataset: vbench Task: image-to-image -------------------------------------------------- Benchmark duration (s): 286.11 Request rate: inf Max request concurrency: 20 Successful requests: 20/20 -------------------------------------------------- Request throughput (req/s): 0.07 Latency Mean (s): 150.0428 Latency Median (s): 150.0600 Latency P99 (s): 283.3843 -------------------------------------------------- Peak Memory Max (MB): 47971.82 Peak Memory Mean (MB): 47971.49 Peak Memory Median (MB): 47971.29 ============================================================ ``` ## 6. Run in ComfyUI import { ComfyUISupport } from '/src/snippets/diffusion/comfyui-support.jsx';