[Bug][Diffusion] Qwen-Image native SP=4 is killed by host OOM while loading DiT on 4×48GB GPUs
Checklist
- I searched related issues but found no solution.
- The bug persists in the latest version.
- Issues without environment info and a minimal reproducible demo are hard to resolve and may receive no feedback.
- If this is not a bug report but a general question, please start a discussion at https://github.com/sgl-project/sglang/discussions. Otherwise, it will be closed.
- Please use English. Otherwise, it will be closed.
Describe the bug
Describe the bug
Serving Qwen/Qwen-Image with the native SGLang diffusion pipeline and
--num-gpus 4 --sp-degree 4 causes host memory usage to grow rapidly while
loading the transformer.
One scheduler rank is eventually killed by the host OOM killer (SIGKILL,
exit code -9), followed by NCCL/TCPStore errors on the remaining ranks.
The same model can start with the Diffusers backend. The native pipeline also works on a single RTX 6000 Ada when the DiT is GPU-resident.
Environment
- SGLang: v0.5.10
- Commit:
1519acf37c23f2189adb93f57ca9cd2db1bebf18 - Repository state: dirty, but no loader files were modified
- GPUs: 4 × NVIDIA RTX 6000 Ada, 48 GB each
- Host RAM: 377 GiB
- Host swap: 2 GiB
- Model:
Qwen/Qwen-Image - Model dtype: BF16
- PyTorch: 2.9.1+cu128
Reproduction command
HF_ENDPOINT=https://huggingface.co \
CUDA_VISIBLE_DEVICES=0,1,2,3 \
PYTORCH_CUDA_ALLOC_CONF=expandable_segments:True \
sglang serve \
--model-path Qwen/Qwen-Image \
--host 0.0.0.0 \
--port 30010 \
--num-gpus 4 \
--sp-degree 4 \
--text-encoder-cpu-offload \
--vae-cpu-offload \
--pin-cpu-memoryThe resolved arguments include:
{
"backend": "auto",
"dit_cpu_offload": true,
"text_encoder_cpu_offload": true,
"vae_cpu_offload": true,
"pin_cpu_memory": true,
"num_gpus": 4,
"sp_degree": 4,
"use_fsdp_inference": false
}The native pipeline is correctly selected:
Using pipeline from model_index.json: QwenImagePipelineAll four ranks read the text encoder weights:
[RunAI Streamer] Overall time to stream 15.4 GiB of all files to cpu
[RunAI Streamer] Overall time to stream 15.4 GiB of all files to cpu
[RunAI Streamer] Overall time to stream 15.4 GiB of all files to cpu
[RunAI Streamer] Overall time to stream 15.4 GiB of all files to cpuHost available memory decreases from approximately 295 GiB before loading to approximately 89 GiB while the transformer is being loaded. The 2 GiB swap is also exhausted.
The process then dies while loading the approximately 38 GiB DiT:
Loading QwenImageTransformer2DModel from 9 safetensors file(s)
...
Rank 0 scheduler is dead
Exit code: -9
EOFErrorThe other NCCL/TCPStore errors occur after rank 0 has already disappeared and appear to be secondary failures.
Control experiments
1. Diffusers backend
The Diffusers backend can start successfully:
CUDA_VISIBLE_DEVICES=0,1,2,3 \
sglang serve \
--backend diffusers \
--model-path Qwen/Qwen-Image \
--num-gpus 4 \
--sp-degree 4 \
--text-encoder-cpu-offload \
--vae-cpu-offloadThis control uses a different execution/loading path and is included only to show that the checkpoint itself is valid and can be loaded on this machine.
2. Native single-GPU pipeline
The native pipeline works on one GPU when the DiT is GPU-resident:
HF_ENDPOINT=https://huggingface.co \
CUDA_VISIBLE_DEVICES=0 \
sglang serve \
--model-path Qwen/Qwen-Image \
--num-gpus 1 \
--sp-degree 1 \
--dit-cpu-offload false \
--text-encoder-cpu-offload \
--vae-cpu-offload \
--pin-cpu-memory falseAt 512×512, the observed peak reserved GPU memory is approximately 42.1 GiB.
3. Native SP=4 without DiT CPU offload
The native SP=4 pipeline is still killed by the host OOM killer during transformer loading with:
--dit-cpu-offload false --pin-cpu-memory falseThis suggests that the failure is related to the transient multi-rank loading peak, rather than only the final CPU-resident model size or pinned memory.
Expected behavior
The native SP=4 pipeline should do at least one of the following:
- avoid materializing full temporary checkpoint states independently on every rank;
- load or shard weights directly to their destination devices;
- stagger rank loading to limit peak host memory;
- support effective FSDP weight sharding for Qwen-Image;
- document the required host-memory capacity;
- or fail early with a clear host-memory diagnostic instead of being silently killed by the OS.
Suspected cause
This is a hypothesis based on code inspection and has not yet been confirmed.
Sequence parallelism splits the latent sequence but does not shard the DiT
weights. With use_fsdp_inference=false, every SP rank loads the complete
Qwen-Image transformer.
In addition, hf_to_custom_state_dict() consumes the checkpoint iterator into
a complete custom_param_sd before
load_model_from_full_model_state_dict() constructs the state passed to
model.load_state_dict().
During dtype/device/offload conversion, checkpoint tensors, converted tensors, and final parameters may coexist temporarily. When four ranks perform this work concurrently, the transient host-memory requirement may scale with the number of ranks.
Relevant code:
python/sglang/multimodal_gen/runtime/loader/utils.pypython/sglang/multimodal_gen/runtime/loader/fsdp_load.py
A potentially related report for another diffusion model is:
Reproduction
Model: Qwen/Qwen-Image
HF_ENDPOINT=https://huggingface.co \
CUDA_VISIBLE_DEVICES=0,1,2,3 \
PYTORCH_CUDA_ALLOC_CONF=expandable_segments:True \
/opt/conda/envs/sgl-diffusion/bin/sglang serve \
--model-path Qwen/Qwen-Image \
--host 0.0.0.0 \
--port 30010 \
--num-gpus 4 \
--sp-degree 4 \
--text-encoder-cpu-offload \
--vae-cpu-offload \
--pin-cpu-memoryThe native pipeline is selected successfully:
Using pipeline from model_index.json: QwenImagePipelineHost memory usage then grows rapidly while loading:
Loading QwenImageTransformer2DModel from 9 safetensors file(s)Eventually rank 0 is killed by the host OOM killer:
Rank 0 scheduler is dead
Exit code: -9
EOFErrorThe subsequent NCCL/TCPStore errors occur after rank 0 has been killed.
Environment
Python: 3.12.14 | packaged by conda-forge | (main, Aug 21 2026, 22:48:28) [GCC 14.4.0]
CUDA available: True
GPU 0,1,2,3: NVIDIA RTX 6000 Ada Generation
GPU 0,1,2,3 Compute Capability: 8.9
CUDA_HOME: /usr/local/cuda
NVCC: Cuda compilation tools, release 12.8, V12.8.93
CUDA Driver Version: 570.124.06
PyTorch: 2.9.1+cu128
sglang: 0.5.10
sglang-kernel: 0.4.1
flashinfer_python: 0.6.7.post2
flashinfer_cubin: 0.6.7.post2
flashinfer_jit_cache: Module Not Found
triton: 3.5.1
transformers: 5.3.0
torchao: 0.9.0
numpy: 2.5.2
aiohttp: 3.14.3
fastapi: 0.141.1
huggingface_hub: 1.29.0rc1
interegular: 0.3.3
modelscope: 1.39.1
orjson: 3.12.0
outlines: 0.1.11
packaging: 26.3
psutil: 7.2.2
pydantic: 2.14.0b1
python-multipart: 0.0.32
pyzmq: 27.2.0
uvicorn: 0.52.4
uvloop: 0.22.1
vllm: Module Not Found
xgrammar: 0.1.32
openai: 2.6.1
tiktoken: 0.14.0
anthropic: 1.1.0
litellm: Module Not Found
torchcodec: 0.9.1
NVIDIA Topology:
GPU0 GPU1 GPU2 GPU3 CPU Affinity NUMA Affinity
GPU0 X PIX SYS SYS 0-31,64-95 0
GPU1 PIX X SYS SYS 0-31,64-95 0
GPU2 SYS SYS X NODE 32-63,96-127 1
GPU3 SYS SYS NODE X 32-63,96-127 1
ulimit soft: 1048576Additional hardware information:
- Host RAM: 377 GiB
- Host swap: 2 GiB
- GPU memory: 48 GB per GPU
- Git commit:
1519acf37c23f2189adb93f57ca9cd2db1bebf18 - Git describe:
v0.5.10-dirty - The local modifications do not include the model loader files.
Source: sgl-project/sglang