原文 Full-Stack Performance Optimization of AR+DiT in SGL-Diffusion · 作者 Ascend Team · 来源 LMSYS Blog · 原文发布 2026-08-05 · 中英对照·AI 译 2026-08-07 翻译为 AI 初稿 + 人工校对,如有出入以原文为准。
TL;DR
- Replaces the HF backend with SRT to accelerate AR modeling and resolve parallelism conflicts, with dedicated TP for AR and SP for DiT
- Boosts hardware utilization via dynamic batching and enables early return for completed images
- Implements one-denoiser-per-device parallel DiT execution and overlaps AR & DiT workflows via buffered AR results
译: 用 SRT 替换 HF 后端以加速 AR 建模并解决并行策略冲突——AR 用 TP、DiT 用 SP 各自独立;通过动态批处理提升硬件利用率,并支持已完成图像的提前返回;实现一卡一去噪器的并行 DiT 执行,通过缓冲 AR 结果重叠 AR 与 DiT 工作流。

1. Background
Hybrid autoregressive–diffusion (AR+DiT) generation is a unified framework that combines AR modeling for global context with DiT methods for local detail refinement. It leverages AR transformers to capture long-range dependencies while DiT models iteratively refine outputs, ensuring improved quality and efficiency. GLM-Image exemplifies this trend: a 9B vision-language model first autoregressively generates semantic prior tokens from a text prompt, and a 7B DiT then denoises those tokens into a high-resolution image over 30–50 steps. This “plan-then-paint” design delivers SOTA results on knowledge-intensive and text-heavy visual tasks—such as posters, infographics, and precise typography—where end-to-end diffusion models often struggle.
译: 混合自回归-扩散(AR+DiT)生成是一个统一框架,将用于全局上下文的 AR 建模与用于局部细节精修的 DiT 方法相结合。它利用 AR transformer 捕获长距离依赖,同时 DiT 模型迭代地精修输出,确保提升的质量与效率。GLM-Image 是这一趋势的典型:一个 9B 视觉语言模型首先从文本提示自回归地生成语义先验 token,然后一个 7B DiT 在 30–50 步内将这些 token 去噪为高分辨率图像。这种”先规划后绘制”的设计在知识密集型和文字密集的视觉任务上取得了 SOTA 结果——如海报、信息图和精确排版——这些场景下端到端扩散模型往往表现不佳。
Yet serving such hybrid pipelines efficiently in SGLang exposes a fundamental tension. In the native deployment, the AR encoder, DiT denoiser, and VAE decoder are chained inside a single monolithic worker process, which creates three critical pain points:
译: 然而,在 SGLang 中高效地 serving 这类混合流水线暴露了一个根本矛盾。在原生部署中,AR encoder、DiT denoiser 和 VAE decoder 串联在单一的单体 worker 进程内,由此产生三个关键痛点:
- Architectural coupling. AR and DiT share the same process, weight-loading lifecycle, and scheduling domain. Scaling up one stage necessarily drags the other along; there is no way to provision resources independently. AR is fundamentally an LLM-decode workload—throughput scales with batch size and tensor parallelism (TP). DiT denoising, by contrast, is a large-tensor, per-image computation that favors spatial parallelism (SP) across cards and is most efficient at batch=1. A homogeneous deployment must pick a single strategy, guaranteeing that one stage is always sub-optimal.
译: 1. 架构耦合。 AR 和 DiT 共享同一进程、权重加载生命周期和调度域。扩展某一阶段必然拖动另一阶段;无法独立配置资源。AR 本质上是 LLM-decode 工作负载——吞吐随 batch size 和张量并行(TP)扩展。DiT 去噪则相反,是大张量、逐图像计算,适合跨卡空间并行(SP),在 batch=1 时效率最高。同构部署必须选择单一策略,注定某一阶段总是次优的。
- Low resource utilization under concurrency. Without dynamic batching, concurrent requests are processed serially. End-to-end latency grows almost linearly with request concurrency, leaving a large fraction of the available compute idle.
译: 2. 并发下资源利用率低。 没有动态批处理时,并发请求被串行处理。端到端延迟几乎随请求并发度线性增长,大量可用算力闲置。
- Mismatched resource allocation. DiT achieves its best per-request latency at batch=1 per device, but bundling all devices into a single monolithic pipeline forces DiT to run in a multi-card spatial-parallel configuration even when throughput is the priority, resulting in underutilized hardware capacity.
译: 3. 资源分配错配。 DiT 在每设备 batch=1 时达到最佳单请求延迟,但将所有设备捆绑进单一单体流水线后,即使优先目标是吞吐,DiT 也被迫以多卡空间并行配置运行,导致硬件容量利用不足。
To resolve these issues, we contributed three progressively staged PRs that evolve the system from a monolith to a fully decoupled, heterogeneous distributed architecture:
译: 为解决这些问题,我们贡献了三个渐进式 PR,将系统从单体演化为完全解耦的异构分布式架构:
Note: PR #31320 has not been merged yet. The commit SHA we adopt here is 4e520bd
译: 注:PR #31320 尚未合并。此处采用的 commit SHA 为 4e520bd

2. SRT-ifying the AR Backend (PR #25381)
In order to reduce per-image generation latency, our analysis led us to replace the HF backend with SRT, culminating in PR #25381. It decouples the AR stage from the diffusion worker process into a standalone SRT service, so AR and DiT load weights separately, have decoupled scheduling lifecycles, and can scale independently. Meanwhile, the AR server can now configure TP on its own, no longer constrained by DiT’s SP strategy.
译: 为降低单图像生成延迟,我们的分析促使我们用 SRT 替换 HF 后端,最终形成 PR #25381。它将 AR 阶段从 diffusion worker 进程中解耦为独立的 SRT 服务,使 AR 和 DiT 分别加载权重、拥有解耦的调度生命周期、可独立扩展。同时,AR server 现在可以自行配置 TP,不再受 DiT 的 SP 策略约束。

The AR vision-language encoder is spun up as a standard SGLang SRT service, invoked remotely by the Diffusion pipeline via a new --srt-encoder-url option. The AR server reuses SGLang’s existing multimodal sglang serve capability (srt/models/glm_image_vl.py + srt/multimodal/processors/glm_image.py); the Diffusion side only adds an HTTP /generate branch to the GlmImageAR stage, and VisionLanguageEncoderLoader simply performs a /health check and returns the URL when srt-encoder-url is set, instead of calling from_pretrained to load weights. This “standalone server + HTTP” approach turns the giant task of “rewriting a VLM into SRT” into “reuse existing infrastructure + one HTTP call,” dramatically reducing coupling and minimizing invasive changes to the diffusion pipeline.
译: AR 视觉语言 encoder 作为标准 SGLang SRT 服务启动,由 Diffusion 流水线通过新的
--srt-encoder-url选项远程调用。AR server 复用 SGLang 既有的多模态sglang serve能力(srt/models/glm_image_vl.py+srt/multimodal/processors/glm_image.py);Diffusion 侧仅向GlmImageAR阶段添加一个 HTTP/generate分支,VisionLanguageEncoderLoader在设置了srt-encoder-url时只做一次/health检查并返回 URL,而非调用from_pretrained加载权重。这种”独立 server + HTTP”方式将”把 VLM 重写为 SRT”的巨大任务变为”复用既有基础设施 + 一次 HTTP 调用”,大幅降低耦合并最小化对 diffusion 流水线的侵入式改动。
Performance gains (please refer to PR #25381 description for reproducing):
译: 性能收益(复现请参考 PR #25381 描述):
| Configuration | NPUs | E2E latency (s) | AR stage (s) | Denoising (s) | Decoding (s) |
|---|---|---|---|---|---|
| Monolithic baseline (HF AR backend) | 1 | 154.6 | 122.8 | 31.6 | 0.046 |
| Decoupled SRT AR (DiT unchanged) | 1 | 78.3 (−49.4%) | 46.6 (−62.1%) | 31.6 | 0.035 |
| 4-NPU heterogeneous (TP=4 AR, SP=4 DiT) | 4 | 35.2 (−77.2%) | 26.1 (−78.8%) | 9.0 | 0.009 |
Resource-matched comparison: The
Decoupled SRT AR (DiT unchanged)row shows the software-only speedup over themonolithic baseline (HF AR backend).
译: 资源匹配对比:
Decoupled SRT AR (DiT unchanged)行展示相对于monolithic baseline (HF AR backend)的纯软件加速。
Combined scaling: The
4-NPU heterogeneous (TP=4 AR, SP=4 DiT)row shows the combined software and hardware-scaling result (software decoupling + 4× NPU parallelism) over the same1-NPU monolithic baseline.
译: 组合扩展:
4-NPU heterogeneous (TP=4 AR, SP=4 DiT)行展示相对于同一1-NPU monolithic baseline的软件+硬件扩展组合结果(软件解耦 + 4× NPU 并行)。
Prior to PR #25381, because AR and DiT were constrained to share the same parallelism strategy, data is only available for the 4-NPU heterogeneous configuration.
译: 在 PR #25381 之前,由于 AR 和 DiT 被约束共享同一并行策略,数据仅适用于 4-NPU 异构配置。
The AR stage sees the most dramatic speedup: single-card 122.8 s → 26.1 s, a 78.8% reduction on 4 cards. Even at TP=1, SRT’s graph execution, continuous batching, and memory reuse deliver a −62.1% gain over the naive transformers generate. Notably, the baseline 2-NPU setup uses SP to cut denoising by 46.7%, but AR actually slows by 4.1% — under the old path AR gets zero benefit from SP and even regresses due to communication overhead; only the SRT path lets AR truly leverage multi-card TP.
译: AR 阶段加速最为显著:单卡 122.8 s → 26.1 s,4 卡上降低 78.8%。即使在 TP=1 下,SRT 的图执行、连续批处理和内存复用也带来了相对于朴素 transformers
generate−62.1% 的提升。值得注意的是,基线 2-NPU 配置用 SP 将去噪削减 46.7%,但 AR 实际变慢 4.1%——在旧路径下 AR 从 SP 中零收益甚至因通信开销而退化;只有 SRT 路径让 AR 真正利用多卡 TP。
3. Dynamic Batching Adaptation and Early Return Support (PR #30683)
After the separation, AR and DiT still execute one request at a time, so latency grows linearly under high concurrency (issue #30634). To boost throughput in multi-input scenarios, we followed up with PR #30683. It packs concurrent requests into single forward passes, eliminating the idle compute caused by serial execution.
译: 分离之后,AR 和 DiT 仍然一次执行一个请求,因此高并发下延迟线性增长(issue #30634)。为提升多输入场景下的吞吐,我们跟进 PR #30683。它将并发请求打包进单次前向传播,消除串行执行导致的算力闲置。
- Dynamic batching adaptation: SGL-Diffusion already includes a generic dynamic batching infrastructure (introduced in PR #18764); our work extends this capability to GLM-Image by implementing the
supports_dynamic_batchingandsupports_native_grouped_requestsinterfaces and associated pipeline logic. After evaluation, we apply batching only to the AR stage, as DiT per-step latency scales proportionally with batch size and yields no net throughput benefit.
译: 1. 动态批处理适配:SGL-Diffusion 已包含通用动态批处理基础设施(在 PR #18764 中引入);我们的工作通过实现
supports_dynamic_batching和supports_native_grouped_requests接口及关联流水线逻辑,将此能力扩展到 GLM-Image。评估后,我们仅对 AR 阶段应用批处理,因为 DiT 每步延迟随 batch size 成比例增长,无净吞吐收益。
- Support early return: we add the
supports_sequential_dit_inferencevariable and related functions to support early return when each output image is ready, instead of waiting for the entire batch to finish.
译: 2. 支持提前返回:我们添加
supports_sequential_dit_inference变量及相关函数,支持每张输出图像就绪时提前返回,而非等待整个 batch 完成。
Performance gains (please refer to PR #30683 description for reproducing):
译: 性能收益(复现请参考 PR #30683 描述):
| Metric | BS1 | BS4 | BS8 | BS16 |
|---|---|---|---|---|
| Throughput (img/s) | 0.0388 | 0.0896 | 0.1171 | 0.1368 |
| Per‑request processing latency (s)¹ | 25.9 | 28.3 → 33.3 → 39.3 → 44.7 | 30.0 → 35.3 → … → 68.3 | 33 → 39 → … → 117 |
| AR stage per request (s) | 20.17 | 5.65 | 3.20 | 1.85 |
| Peak NPU memory (MB) | 28 163 | 28 046 | 28 052 | 28 062 |
Notes:
译: 注:
¹ Processing latency is measured from batch dispatch to individual request completion. For BS4/BS8/BS16, the values represent a latency range across the batch: the first number corresponds to the fastest-finishing request, and the last to the slowest. Additional queueing wait time (≤14 ms in this test) is negligible.
译: ¹ 处理延迟从 batch 派发到单个请求完成测量。对于 BS4/BS8/BS16,数值表示 batch 内的延迟范围:第一个数字对应最快完成的请求,最后一个对应最慢的。额外的排队等待时间(本测试中 ≤14 ms)可忽略。
4. Disaggregation and AR-to-DiT Fan-Out Architecture (PR #31320)
Fully decouple the two stages so AR and DiT each adopt the parallelism and deployment strategy that suits them best. The AR encoder favors large batch + TP (throughput-oriented); DiT denoising is optimal at batch=1 on a single NPU for both latency and throughput.
译: 完全解耦两个阶段,使 AR 和 DiT 各自采用最适合的并行与部署策略。AR encoder 偏好大 batch + TP(面向吞吐);DiT 去噪在单 NPU 上 batch=1 时延迟和吞吐均最优。
| Batch size | AR (s) | Denoising, 30 step (s) | Denoising, 30 steps (s) |
|---|---|---|---|
| 1 | 20.4 | 0.407 | 12.2 |
| 2 | 21.3 (+4.4%) | 0.854 (+110%) | 25.6 (+110%) |
| 4 | 22.8 (+12%) | 1.98 (+386%) | 59.6 (+389%) |
| 8 | 25.9 (+27%) | 3.73 (+816%) | 112.2 (+820%) |
| 16 | 29.4 (+44%) | 7.24 (+1679%) | 217.3 (+1681%) |
| 32 | 33.2 (+63%) | 14.0 (+3339%) | 420.6 (+3348%) |
Then #31320 introduces a heterogeneous topology: one batched AR server + a pool of independent batch=1 denoisers. This achieves optimal system-wide hardware utilization in single-node scenarios.
译: 随后 #31320 引入异构拓扑:一个批量 AR server + 一组独立的 batch=1 去噪器。这在单节点场景下实现了最优的全系统硬件利用率。

SGL-Diffusion provides a generic disaggregation framework; PR #31320 adapts this framework to GLM-Image’s two-stage topology, enabling parallel DiT execution and pipeline overlap between AR generation and denoising. A key design choice is that only request metadata and CPU-side prior token IDs are transferred over ZMQ — no large tensors, latents, embeddings, or GPU buffers are sent across nodes — designed to keep communication overhead low.
译: SGL-Diffusion 提供通用解耦框架;PR #31320 将此框架适配到 GLM-Image 的两阶段拓扑,实现并行 DiT 执行和 AR 生成与去噪之间的流水线重叠。一个关键设计选择是:仅通过 ZMQ 传输请求元数据和 CPU 侧先验 token ID——不跨节点传输大张量、latent、embedding 或 GPU buffer——旨在保持低通信开销。
Performance gains (please refer to PR #31320 description for reproducing):
译: 性能收益(复现请参考 PR #31320 描述):
| Configuration | NPU | throughput (image/s) | Avg. E2E latency (s) |
|---|---|---|---|
| AR(TP2) + monolithic sequential denoiser(BS28) | 16 | 0.2 | 90 |
| AR(TP2) + disaggregated parallel denoiser(14 x BS=1) | 16 | 0.74 | 37 |
5. Acknowledgments
- Huawei Ascend Team
We thank the Huawei Ascend NPU team for its continued contributions to GLM-Image optimization. In particular, we recognize Maksim Emelin (@Makcum888e), Artem Savkin (@OrangeRedeng), Egor Filimonov (@ssshinigami), and Liang Zhen (@ping1jing2).
We also extend our thanks to Yuefeng Wu (@ChefWu551) and Qianqian Zheng (@AuFlow) from CMB. They contributed to GLM-Image optimization on Ascend platform, improving stability and deployment efficiency.
译: 我们感谢华为 Ascend NPU 团队持续贡献 GLM-Image 优化。特别致谢 Maksim Emelin(@Makcum888e)、Artem Savkin(@OrangeRedeng)、Egor Filimonov(@ssshinigami)和 Liang Zhen(@ping1jing2)。
我们还感谢来自 CMB 的 Yuefeng Wu(@ChefWu551)和 Qianqian Zheng(@AuFlow)。他们在 Ascend 平台上为 GLM-Image 优化做出贡献,提升了稳定性和部署效率。
- SGLang Community
We are grateful to the broader SGLang community, including code review from Xiaoyu Zhang (@BBuf), and initial discussion (issue #20032) and implementation (PR #18809) from Yuhao Yang (@yhyang201) and other contributors.
Finally, we thank the SGLang maintainers and reviewers for their careful guidance, the Zhipu AI team for open-sourcing the GLM-Image model and weights, and everyone who has contributed to SGL-Diffusion.
译: 我们感谢更广泛的 SGLang 社区,包括 Xiaoyu Zhang(@BBuf)的代码审查,以及 Yuhao Yang(@yhyang201)等贡献者的初始讨论(issue #20032)和实现(PR #18809)。
最后,我们感谢 SGLang 维护者和审查者的悉心指导,感谢 Zhipu AI 团队开源 GLM-Image 模型和权重,以及每一位为 SGL-Diffusion 做出贡献的人。
6. Appendix
Full reproduction steps are listed in issue #33526 due to the length of the commands.
译: 由于命令篇幅较长,完整复现步骤列于 issue #33526。