Skip to content

[diffusion] Support stable-diffusion-3-medium-diffusers with sglang backend#19225

Merged
mickqian merged 86 commits intosgl-project:mainfrom
gxlvera:sd3
Apr 13, 2026
Merged

[diffusion] Support stable-diffusion-3-medium-diffusers with sglang backend#19225
mickqian merged 86 commits intosgl-project:mainfrom
gxlvera:sd3

Conversation

@gxlvera
Copy link
Copy Markdown
Contributor

@gxlvera gxlvera commented Feb 24, 2026

Overview

This PR supports

  1. stable-diffusion-3-medium
  2. stable-diffusion-3.5-medium
  3. stable-diffusion-3.5-large

as sglang-native (using sglang as backend instead of diffusers).

Note:

  1. this PR hasn't supported TP
  2. it doesn't use sglang USPAttention so not yet supported SP.

Run with cli:

SGLANG_USE_MODELSCOPE=true sglang generate   --model-path stabilityai/stable-diffusion-3-medium-diffusers  --prompt "Epic anime artwork of a wizard atop a mountain at night casting a cosmic spell into the dark sky that says Stable Diffusion 3 made out of colorful energy"   --height 1024   --width 1024   --num-inference-steps 20   --guidance-scale 7.0   --num-gpus 1 --backend sglang
Epic_anime_artwork_of_a_wizard_atop_a_mountain_at_night_casting_a_cosmic_spell_into_the_dark_sky_tha_20260224-064924_e044671b

Modifications

Accuracy Tests

Benchmarking and Profiling

Checklist

Review Process

  1. Ping Merge Oncalls to start the PR flow. See the PR Merge Process.
  2. Get approvals from CODEOWNERS and other reviewers.
  3. Trigger CI tests with comments or contact authorized users to do so.
    • /tag-run-ci-label, /rerun-failed-ci, /tag-and-rerun-ci
  4. After green CI and required approvals, ask Merge Oncalls to merge.

@gemini-code-assist
Copy link
Copy Markdown
Contributor

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

@github-actions github-actions Bot added the diffusion SGLang Diffusion label Feb 24, 2026
Comment thread python/sglang/multimodal_gen/runtime/models/registry.py Outdated
Comment thread python/sglang/multimodal_gen/registry.py Outdated
Comment thread python/sglang/multimodal_gen/runtime/models/encoders/clip.py
Comment thread python/sglang/multimodal_gen/runtime/models/dits/stablediffusion3.py Outdated
Comment thread python/sglang/multimodal_gen/runtime/models/dits/stablediffusion3.py Outdated
Comment thread python/sglang/multimodal_gen/runtime/models/dits/stablediffusion3.py Outdated
Comment thread python/sglang/multimodal_gen/runtime/loader/component_loaders/vae_loader.py Outdated
Comment thread python/sglang/multimodal_gen/configs/pipeline_configs/stablediffusion3.py Outdated
Comment thread python/sglang/multimodal_gen/configs/models/vaes/stablediffusion3.py Outdated
Comment thread python/sglang/multimodal_gen/configs/models/vaes/stablediffusion3.py Outdated
Comment thread python/sglang/multimodal_gen/configs/models/vaes/stablediffusion3.py Outdated
Comment thread python/sglang/multimodal_gen/runtime/models/dits/stablediffusion3.py Outdated
@ping1jing2
Copy link
Copy Markdown
Collaborator

please provide a performance comparison report according to docs/diffusion/contributing.md

  1. Baseline: run the benchmark (for a single generation task)

    $ sglang generate --model-path <model> --prompt "A benchmark prompt" --perf-dump-path baseline.json
  2. New: run the same benchmark, without modifying any server_args or sampling_params

    $ sglang generate --model-path <model> --prompt "A benchmark prompt" --perf-dump-path new.json
  3. Compare: run the compare script, which will print a Markdown table to the console

    $ python python/sglang/multimodal_gen/benchmarks/compare_perf.py baseline.json new.json [new2.json ...]
    ### Performance Comparison Report
    ...
  4. Paste: paste the table into the PR description

@gxlvera
Copy link
Copy Markdown
Contributor Author

gxlvera commented Feb 27, 2026

please provide a performance comparison report according to docs/diffusion/contributing.md

  1. Baseline: run the benchmark (for a single generation task)
    $ sglang generate --model-path <model> --prompt "A benchmark prompt" --perf-dump-path baseline.json
  2. New: run the same benchmark, without modifying any server_args or sampling_params
    $ sglang generate --model-path <model> --prompt "A benchmark prompt" --perf-dump-path new.json
  3. Compare: run the compare script, which will print a Markdown table to the console
    $ python python/sglang/multimodal_gen/benchmarks/compare_perf.py baseline.json new.json [new2.json ...]
    ### Performance Comparison Report
    ...
  4. Paste: paste the table into the PR description

Ok I will do that, thanks!

Comment thread python/sglang/multimodal_gen/runtime/pipelines_core/stages/text_encoding.py Outdated
@zhaochenyang20
Copy link
Copy Markdown
Collaborator

zhaochenyang20 commented Feb 27, 2026

sglang generate   --model-path stabilityai/stable-diffusion-3-medium-diffusers  --prompt "Close-up shot of a tiny, fluffy white Siberian Forest kitten cuddling and allogrooming with a massive, round brown Maine Coon/British Shorthair mix. They are curled together, softly licking each other's fur."   --height 1024   --width 1024   --num-inference-steps 20   --guidance-scale 7.0   --num-gpus 1 --backend sglang
image

Comment thread python/sglang/multimodal_gen/configs/models/vaes/stablediffusion3.py Outdated
Comment thread python/sglang/multimodal_gen/configs/models/vaes/stablediffusion3.py Outdated
Comment thread python/sglang/multimodal_gen/configs/pipeline_configs/stablediffusion3.py Outdated
Comment thread python/sglang/multimodal_gen/configs/pipeline_configs/stablediffusion3.py Outdated
Copy link
Copy Markdown
Collaborator

@mickqian mickqian left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO:

  1. support combined cfg

Comment thread python/sglang/multimodal_gen/runtime/pipelines_core/stages/text_encoding.py Outdated
Comment thread python/sglang/multimodal_gen/runtime/loader/component_loaders/vae_loader.py Outdated
@mickqian mickqian dismissed stale reviews from zhaochenyang20 and dreamyang-liu April 7, 2026 03:41

footer

)
if is_flux_v1:
pooled_embeds_list.append(outputs.pooler_output)
elif is_sd3 and i <= 1:
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could we use something like use_pooler_output = is_sd3 or is_flux_v1

@yhyang201
Copy link
Copy Markdown
Collaborator

/tag-and-rerun-ci

@mickqian mickqian merged commit 4df6043 into sgl-project:main Apr 13, 2026
76 of 78 checks passed
pyc96 pushed a commit to pyc96/sglang that referenced this pull request Apr 14, 2026
…roject#19225)

Co-authored-by: zhaochenyang20 <zhaochen20@outlook.com>
Co-authored-by: Kangrui Du <kangruidu@gmail.com>
Co-authored-by: Xiaole Guo <gxlvera@gmail.com>
yhyang201 pushed a commit to yhyang201/sglang that referenced this pull request Apr 22, 2026
…roject#19225)

Co-authored-by: zhaochenyang20 <zhaochen20@outlook.com>
Co-authored-by: Kangrui Du <kangruidu@gmail.com>
Co-authored-by: Xiaole Guo <gxlvera@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

diffusion SGLang Diffusion run-ci

Projects

None yet

Development

Successfully merging this pull request may close these issues.

10 participants