Skip to content

[diffusion] model: support LongCat-Image - #23274

Merged
BBuf merged 2 commits into
sgl-project:mainfrom
Dragonliu2018:lzl/feat/support_longcat_image
Aug 13, 2026
Merged

BBuf merged 2 commits into
sgl-project:mainfrom
Dragonliu2018:lzl/feat/support_longcat_image

Conversation

@Dragonliu2018

@Dragonliu2018 Dragonliu2018 commented Apr 20, 2026 •

Copy link
Copy Markdown
Contributor

Motivation

This PR adds support for LongCat-Image, a new text-to-image model based on a Flux-like MMDiT architecture with a Qwen2.5-VL (7B) text encoder.

Modifications

New components:

  • LongCatImageTransformer2DModel: Flux-like MMDiT, 19 double + 38 single-stream blocks, 24×128 dim, 2×2 latent packing, RoPE (axes=[16,56,56]), AdaLN-Zero. USPAttention (FA3/FA4) + fused qk-norm; weights load without remapping.
  • LongCatPromptRewriteStage(model-specific): optional prompt rewrite via Qwen2.5-VL .generate() (max_new_tokens=512, top_k=1 → effectively greedy; sampling params from checkpoint's generation_config.json). Loads the HF encoder in-stage and shares it with TextEncodingStage; sets CPU generator for seed reproducibility.
  • LongCatImagePipeline: PromptRewriteStage → TextEncoding → LatentPrep → TimestepPrep → Denoising → Decoding (only the first is model-specific).
  • LongCatImagePipelineConfig hooks: quotation-aware tokenization with fixed system prefix/assistant suffix (512-token body), 2×2 pack/unpack, 3D modality-aware pos ids (txt=0 / img=1 @ offset 512), seq-len-dependent flow-match shift, CFG renorm (cond_norm/noise_norm clamped to [min, 1.0]).
  • Bilingual (EN/ZH) few-shot rewrite system prompts.
  • LongCatImageSamplingParams: guidance_scale=4.5, steps=50, 1024×1024, cfg_renorm + prompt_rewrite on by default.

Shared changes:

  • SamplingParams: add enable_cfg_renorm / cfg_renorm_min / enable_prompt_rewrite (+ CLI).
  • AutoProcessorLoader: add "text_processor" to component_names.
  • registry: register LongCat-Image ("longcat" detector, excludes "edit").

Examples

sglang generate \
  --model-path /root/models/LongCat-Image \
  --prompt "一个年轻的亚裔女性,身穿黄色针织衫,搭配白色项链。她的双手放在膝盖上,表 情恬静。背景是一堵粗糙的砖墙,午后的阳光温暖地洒在她身上,营造出一种宁静而温馨的氛围 。镜头采用中距离视角,突出她的神态和服饰的细节。光线柔和地打在她的脸上,强调她的五官 和饰品的质感,增加画面的层次感与亲和力。整个画面构图简洁,砖墙的纹理与阳光的光影效果 相得益彰,突显出人物的优雅与从容。" \
  --height 768 --width 1344 \
  --enable-prompt-rewrite=True \
  --enable-cfg-renorm=True \
  --num-inference-steps=50 \
  --negative-prompt "" \
  --seed=43 \
  --guidance-scale=4.0 \
  --save-output
20260421-003446_4bac9823

Accuracy Tests

Speed Tests and Profiling

Checklist

Review and Merge Process

  1. Ping Merge Oncalls to start the process. 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.
    • Common commands include /tag-and-rerun-ci, /tag-run-ci-label, /rerun-failed-ci
  4. After green CI and required approvals, ask Merge Oncalls or people with Write permission to merge the PR.

CI States

Latest PR Test (Base): ✅ Run #31676886716
Latest PR Test (Extra): ✅ Run #31676886686

@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 Apr 20, 2026
@Dragonliu2018
Dragonliu2018 force-pushed the lzl/feat/support_longcat_image branch 9 times, most recently from ee7ed31 to a88ce4e Compare April 29, 2026 05:01
@Dragonliu2018
Dragonliu2018 force-pushed the lzl/feat/support_longcat_image branch 3 times, most recently from b6adc4f to a0e6f74 Compare April 29, 2026 16:21
@Dragonliu2018
Dragonliu2018 marked this pull request as ready for review April 29, 2026 16:42
@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!

@Dragonliu2018

Copy link
Copy Markdown
Contributor Author

Please review this PR. Thanks!
@mickqian @yhyang201 @BBuf @yingluosanqian @ping1jing2

@Dragonliu2018
Dragonliu2018 force-pushed the lzl/feat/support_longcat_image branch 2 times, most recently from adc6ed1 to ee51d28 Compare May 20, 2026 16:19
@Dragonliu2018

Copy link
Copy Markdown
Contributor Author

/tag-and-rerun-ci

@mickqian mickqian left a comment

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.

left some comments

@Dragonliu2018
Dragonliu2018 force-pushed the lzl/feat/support_longcat_image branch 3 times, most recently from e291b38 to f47d906 Compare July 15, 2026 13:39
@Dragonliu2018

Copy link
Copy Markdown
Contributor Author

left some comments

Hi @mickqian, addressed the comments above.

@Dragonliu2018
Dragonliu2018 requested a review from mickqian August 4, 2026 06:44
@Dragonliu2018
Dragonliu2018 force-pushed the lzl/feat/support_longcat_image branch from f47d906 to 9e07394 Compare August 9, 2026 15:35
@BBuf BBuf added the run-ci CI: run the baseline test suite on this PR label Aug 12, 2026 — with ChatGPT Codex Connector

BBuf commented Aug 12, 2026

Copy link
Copy Markdown
Collaborator

/tag-and-rerun-ci

@BBuf BBuf added the run-ci-extra CI: also run the extra suite (requires run-ci) label Aug 12, 2026
@BBuf
BBuf merged commit b764194 into sgl-project:main Aug 13, 2026
129 of 142 checks passed
saturn-acc pushed a commit to saturn-acc/sglang that referenced this pull request Aug 16, 2026
Atituiset pushed a commit to Atituiset/sglang that referenced this pull request Sep 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

diffusion SGLang Diffusion run-ci CI: run the baseline test suite on this PR run-ci-extra CI: also run the extra suite (requires run-ci)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants