SGLang 与 Miles 首日支持 Inkling:975B 多模态前沿模型上线

SGLang 与 Miles 首日支持 Inkling:975B 多模态前沿模型上线

SGLang Team 与 Thinking Machines Lab 宣布合作,为新一代前沿多模态模型 InklingSGLangMiles 中提供 Day-0 支持。此次支持不仅覆盖推理服务,还包括针对 Inkling 新架构的专门内核优化、推测解码、分离式部署、LoRA 服务,以及在 Miles 中进行文本与视觉语言任务的全参数和 LoRA 强化学习训练。

同时,团队还与 Modal 合作,为 Inkling 训练了专用的 DFlash draft model,用于提升 speculative decoding 效率。SGLang 启动示例可参考官方 Cookbook,Miles 启动方式可参考其 Documentation 与 miles#1683 PR。

核心亮点

  • Inkling 是一个 975B 参数的多模态模型,最大上下文窗口可达 1M tokens
  • 模型架构引入 ShortConv、带相对位置偏置的 attention,以及带 shared-expert sink 的新型 MoE。
  • SGLang 在 Nvidia Blackwell GPU 上实现最高 71.7k tok/s 输入吞吐,以及 171.0 tok/s 单用户 decode 速度。
  • SGLang 支持 speculative decoding、PD disaggregation、NVIDIA GPU 上的 bf16 + NVFP4 checkpoint、AMD GPU 上的 bf16 checkpoint、multi-LoRA serving 与 HiCache。
  • Miles 基于定制 Megatron backend 实现 Inkling,支持 DP/PP/TP/SP/EP/CP 并行组合,可进行文本与视觉语言任务的 full-parameter RL 与 LoRA RL。

Inkling 模型架构:在标准 Decoder-only Transformer 上做三处关键改造

Inkling 并不是简单扩大参数规模,而是在标准 decoder-only Transformer 基础上加入三项结构变化:ShortConv、带相对位置嵌入的 attention,以及 MoE 中的 shared-expert sink

Inkling model architecture: attention and MoE submodules with ShortConv, relative logits, and the shared-expert sink

如图所示,Inkling 的 attention 与 MoE 子模块都在 residual connection 前加入了 ShortConv。Attention 部分还会在 Q/K normalization 之前对 K 与 V 做 ShortConv,并通过 RelLogitsProj 将学习到的 query-conditioned relative-position bias 直接加到 attention logits 中,以替代传统位置嵌入。

ShortConv:四处出现的短程因果卷积

ShortConv 是一种沿 token 维度执行的逐通道短因果卷积。对位置 t、通道 c 的 hidden state,它会读取当前 token 以及前 W-1 个位置的同一通道信息。当前 Inkling 配置中 W = 4

在每个 decoder layer 中,ShortConv 出现在四个位置:

  • K stream ShortConv:K projection 之后、Q/K normalization 之前。
  • V stream ShortConv:V projection 之后。
  • Attention-output ShortConv:attention 输出之后。
  • MLP/MoE-output ShortConv:MLP 或 MoE 输出之后。

带相对位置偏置的 Attention

Inkling 的每个 attention layer 都会在 softmax 之前向 logits 中加入学习得到的 per-head relative-position bias。每个 query token 除了携带 qkv 外,还携带相对位置特征 r,再通过学习矩阵 P 投影成按 causal distance bucket 索引的 relative logits。

对于 query i、key j 与 head h,attention logit 可理解为 scaled dot product 加上由相对距离 i-j 选择的相对位置偏置。超出 rel_extent 的距离在 full attention 中不贡献额外 bias,未来位置仍由 causal mask 屏蔽。

在 attention 布局上,Inkling 将 sliding-window attention 与 full attention 混合堆叠。默认模式为每 6 层中前 5 层使用 sliding-window,第 6 层使用 full attention,即 layer_id mod 6 = 5。这种设计让模型在局部层保持较低成本,同时周期性引入全局上下文信息。full attention 层还支持随长度变化的 log-scaling factor,用于在上下文增长时调节 logits 幅度。

MoE with Shared Expert Sink

Inkling 的前馈模块采用 sigmoid-gated top-k MoE:router 打分、选择 top-k routed experts,并对所选专家权重重新归一化。不同之处在于它如何处理两个 shared experts。

传统 shared-expert MoE 往往会在 router 之外额外添加一条始终开启的 dense path,shared experts 不与 routed experts 竞争概率质量。Inkling 则将 routed experts 与 shared experts 放在一起打分:top-k 仍只从 routed pool 中选择,但选出后会把 routed scores 与 shared-expert scores 拼接,再统一归一化。因此,shared experts 与 routed experts 共享同一份权重预算,最终共同缩放各自输出并求和。

SGLang 优化:为 Inkling 的新结构重写执行路径

Inkling 的三项架构变化都打破了标准 decoder-only serving 系统的常见假设。为了让模型在 SGLang 上高效运行,团队为 ShortConv、relative attention 与 MoE shared-expert sink 分别设计了新 kernel 和执行策略。

ShortConv 优化:融合、图捕获与分片

K/V stream ShortConv 位于 Q/K normalization 与 KV-cache 写入之前。SGLang 将 K/V convolution、Q/K RMSNorm 与 KV-cache write 融合进一个 attention-prologue kernel,从而避免多次 kernel launch 与中间写回。

Attention-output 与 MLP-output ShortConv 位于 residual stream 上,恰好处在 tensor-parallel all-reduce 的关键路径。SGLang 因此构建了一组定制 all-reduce kernels,相比 PyTorch 的 multimem_all_reduce_ 最高可快 2.1×。由于 ShortConv 紧跟 all-reduce,SGLang 进一步将其直接融合到 all-reduce kernel 中;在 decode 阶段,还把 RMSNorm 与 residual add 一并折叠进去。融合后,相比未融合链路速度提升 2.08–3.60×,在不同输入长度下带来 5–8% 的端到端吞吐提升。

CPU call-stack trace under BCG replay, showing each ShortConv site

在 prefill 阶段,常见的 Breakable CUDA GraphPiecewise CUDA Graph 可以减少 CPU launch overhead,但遇到需要实时请求元数据的算子仍需回退到 eager execution。Inkling 每层有四个 ShortConv 位置,加上 attention 本身,会导致大量 Python/Triton 调用栈残留,约 66 层累积后会造成明显 CUDA bubbles,即 GPU 等待 CPU 调度的空闲时间。

为此,SGLang 引入 Full CUDA Graph prefill:将包括 ShortConv 在内的整个 forward 捕获到一个图中,并按 full_prefill_max_req 限制请求槽位。回放时只刷新 buffer 内容,不再重新分发 Python 调用。在大形状下 Full CUDA Graph 与 BCG 性能接近;在 launch-bound 场景中,prefill 吞吐相比 BCG 提升约 14–17%

此外,SGLang 还提供 Sharded ShortConv。对于 attention-output 与 MLP-output ShortConv,如果不分片,每个 tensor-parallel rank 都会重复计算并缓存完整 hidden width。分片策略先 reduce-scatter partial sums,让每个 rank 只持有 hidden-dim shard,再在本地对分片 cache 执行 ShortConv,最后 all-gather 回完整宽度。该策略能释放 GPU 显存,但会引入额外通信,因此适合在显存压力较大的部署中使用。

Relative Attention 与 FA4 路径

Inkling 的 relative-position bias 会被直接加入 pre-softmax attention logits,这要求 serving runtime 在 attention kernel 内支持额外的 query-conditioned 相对位置项。SGLang 为此适配了专门的 attention 执行路径,并在 Blackwell GPU 上结合低精度 checkpoint 与高性能 attention kernel 进行优化。

FA4 warp-specialized schedule in the MXFP8 + sheared-bias configuration

其中,FA4 在 MXFP8 + sheared-bias 配置下采用 warp-specialized schedule,以兼顾相对位置 bias、低精度计算与高吞吐执行。该路径是 Inkling 在长上下文与高并发场景中保持服务效率的重要组成部分。

Shared-expert Fusion:降低 MoE 额外开销

Inkling 的 shared-expert sink 要求 routed experts 与 shared experts 在同一权重预算中归一化,这与常见“独立 shared path”的 MoE 实现不同。SGLang 因此对 shared-expert 计算进行了 fusion,将原本偏 expert-batched 的实现改造成更线性化的 GEMM 布局,从而减少调度与内存访问开销。

Shared-expert fusion: from an expert-batched implementation to a linearized GEMM layout

这种线性化 GEMM layout 让 shared experts 的计算更容易与 routed experts 的执行路径协同,也更适合在大规模 tensor parallel 与 expert parallel 设置下获得稳定吞吐。

Inkling 的一次 Decode Round

在 decode 阶段,Inkling 的执行流程会串联 KV ShortConv、Q/K normalization、relative attention、MoE routing、shared-expert sink,以及 residual stream 上的 ShortConv。SGLang 的核心目标是把这些原本容易碎片化的算子尽可能融合进少数高效 kernels,减少 CPU 调度与 GPU kernel launch 的边际成本。

One decode round of Inkling

通过这些优化,Inkling 可以在 SGLang 中获得接近工程化生产部署所需的低延迟与高吞吐表现,而不是停留在“能跑”的 Day-0 兼容层面。

Inkling

Serving 性能:Blackwell 上最高 71.7k tok/s 输入吞吐

在 Nvidia Blackwell GPU 上,SGLang 对 Inkling 的推理服务性能达到最高 71.7k tok/s 的 input throughput,以及 171.0 tok/s 的 per-user decode speed。团队还对 TP=4TP=8 的 throughput-interactivity Pareto 曲线进行了对比,并统计了不同 batch size 下的 ITL 表现。

One decode round of InklingInklingTrain-rollout KL during full-parameter RL

整体来看,TP 配置会影响吞吐与交互性之间的权衡:更高并行度通常有助于扩大模型服务能力,但也需要配合通信、KV-cache 与算子融合策略,才能在实际在线场景中取得更优 Pareto 点。

DFlash 推测解码与功能覆盖

SGLang 对 Inkling 提供了较完整的 serving 功能支持,包括 speculative decodingPD disaggregation、NVIDIA GPU 上的 bf16 + NVFP4 checkpoints、AMD GPU 上的 bf16 checkpointmulti-LoRA servingHiCache

在 speculative decoding 方面,SGLang 支持与 Inkling 专门适配的 DFlash,其 draft model 由 Modal 训练。该设计让大模型在保持输出一致性的前提下,用 draft model 预先生成候选 token,再由主模型验证,从而提升实际 decode 效率。

Miles:面向训练与 RL 的 Inkling 支持

除了推理服务,Miles 也在定制 Megatron backend 中实现了 Inkling,支持 Data Parallelism(DP)Pipeline Parallelism(PP)Tensor Parallelism(TP)Sequence Parallelism(SP)Expert Parallelism(EP)Context Parallelism(CP)。这使 Miles 可以承载 Inkling 在文本任务与视觉语言任务上的 full-parameter RL 和 LoRA RL。

对于大规模 RL,train–inference consistency 尤为关键。Miles 通过定制 kernels、routing replay 以及跨 runtime 参数同步,尽量确保训练侧 rollout、推理侧执行与参数状态保持一致,避免 MoE routing、低精度 kernel 或并行切分带来的偏差。

Train-rollout KL during full-parameter RL

在 full-parameter RL 过程中,train-rollout KL 曲线用于观察训练策略与 rollout 行为之间的偏移。稳定的 KL 控制意味着模型在强化学习中能在探索与分布稳定之间取得平衡。

Raw reward during full-parameter RL

Raw reward 曲线展示了全参数 RL 训练期间奖励信号的变化。结果表明,Miles 在 Inkling 上能够持续推动奖励改善,为更复杂的推理与多模态任务优化提供基础。

AIME25 evaluation during full-parameter RL

AIME25 评测进一步反映了 full-parameter RL 对数学与推理能力的影响。结合 KL、reward 与 benchmark 结果,团队认为 Miles 在文本-only 与 multimodal reasoning 任务上都能带来稳定提升。

总结

Inkling 的 Day-0 支持并不只是把模型接入 SGLang 与 Miles,而是一次覆盖架构适配、kernel fusion、CUDA Graph、MoE 执行、推测解码、分布式训练与 RL 一致性的完整工程化落地。对于 975B 参数、1M 上下文、多模态能力并存的前沿模型而言,这类系统级优化将直接决定模型能否从研究 checkpoint 走向可用的高性能服务与训练平台。

本文来自 LMSYS 博客,赢政天下(winzheng.com)进行了全文翻译。 点击这里查看原文 如果转载中文,请注明出处,谢谢支持!