SGLang's Layer-Spanning Megakernel Pushes Muse Spark Open to 1,109 tok/s
Summary:The SGLang team has built a Blackwell-targeted megakernel for Muse Spark Open that fuses attention, MoE computation, the next layer's QKV projection, and KV-cache writes into a single per-layer launch. Written in roughly 8,000 lines of CUDA C++ and PTX, the implementation combines specialized warp roles, aggressive weight prefetching, mbarrier-based synchronization, and speculative decoding. On eight GB300 GPUs, reported decode throughput rises from 517 to 1,109 tok/s, a 2.15x improvement over a
Core Facts
The SGLang team has built a megakernel for Muse Spark Open on NVIDIA Blackwell. Each launch spans one decoder layer's attention and MoE computation, then continues through the next layer's QKV projection and KV-cache write. The implementation contains roughly 8,000 lines of CUDA C++ and PTX. Across eight GB300 GPUs at TP8, it raises decode throughput from a speculative-decoding baseline of 517 tok/s to 1,109 tok/s, an improvement of approximately 2.15x in wall-clock throughput.
This is not a single kernel covering all 62 layers. Launch boundaries are reduced to one per layer, while the first and last layers retain specialized operation sequences. Because the baseline already uses speculative decoding, the 517-to-1,109 tok/s gain is primarily attributable to kernel fusion, prefetching, and latency hiding rather than the addition of speculative decoding to only one side of the comparison.
From Roughly 1,450 Launches to One per Layer
A conventional GPU kernel generally performs one operation, such as a matrix multiplication or an attention pass. SGLang's conventional path launches about 1,450 kernels for each Muse Spark Open decoding step. When adjacent kernels have data dependencies, the GPU must drain and refill its compute queues at launch boundaries. During low-batch decoding, an individual operation often lacks enough arithmetic work to cover weight-fetch and synchronization latency, leaving performance bounded by launch overhead, memory delay, and tail latency rather than theoretical FLOPs.
The megakernel follows an analogy with CPUs moving from batch processing to multiprogramming: the kernel remains resident and reorganizes attention, MoE, communication, and projection stages into overlapping tasks. SGLang places one thread block containing 12 warps on each of the Blackwell GPU's 144 SMs. Blocks launch in clusters of four and use distributed shared memory where applicable to reduce access latency. Instead of asking every warp to execute the same generic operation, the implementation assigns specialized roles:
- One group performs attention, merging, and result transmission.
- Another handles SwiGLU, reduction, normalization, and receiving data.
- Additional warps load weights, KV data, activations, and scale factors.
- Tensor-core work is interleaved with data movement to hide HBM latency.
This role specialization is more aggressive than simply enlarging a matrix-multiplication kernel: the implementation must directly manage dependencies, thread synchronization, and execution order.
How the Megakernel Hides Memory Latency
Four mechanisms are central to the design.
First, weights are prefetched across cache levels. The weights consumed by the next operation do not depend on the current layer's output, so a prefetch warp can move them into multiple caches while the current operation is still running. This converts several short, serial transfer phases into a longer pipeline and reduces idle SM time.
Second, KV data is loaded early. Most of the KV history read by attention was produced in earlier decoding steps and has no direct dependency on the immediately preceding layer. The kernel can begin loading it as soon as the data lands instead of waiting for the previous layer to finish completely. This matters especially for sliding-window attention, although global-attention layers still require longer histories and more complex address traversal.
Third, TMA, mbarrier, and NVLink work together to coordinate data movement. TMA handles asynchronous bulk copies, mbarrier publishes arrival state, and data can be written across GPUs over NVLink and consumed after synchronization on the destination side. Rather than synchronizing at the granularity of a complete operator, this mechanism synchronizes individual data dependencies.
Fourth, the kernel records its own timestamps for profiling. The important question is not merely whether the GPU remains occupied, but whether DRAM bandwidth, tensor-core utilization, and barrier wait time can remain high simultaneously.
The MoE Model and a New Tensor-Parallel Layout
Muse Spark Open is a sparse MoE model that routes each token to 8 of 256 experts. It contains 62 decoder layers: 46 use sliding-window attention over the previous 2,048 tokens, while 16 use global attention. Most expert weights use 4-bit NVFP4, with some layers retaining BF16. A pooler reduces each token vector before expert computation, and an unpooler restores it afterward.
SGLang changes the TP weight layout to accommodate this structure. The weights of both MoE GEMMs are sharded along the N dimension, requiring an all-gather after each GEMM. Vanilla TP instead shards along the intermediate dimension and uses an all-reduce to produce the result. The new layout adds a communication point, but the team reports lower communication volume and better scaling at larger batches. It can also be implemented bitwise identically to Expert Parallel for training-numerical alignment.
That advantage cannot be separated from routing imbalance. Different GPUs may activate substantially different numbers of experts, while all-gather must wait for every rank. The published figures indicate that GPUs can differ by as much as roughly 4 μs, with the slowest GPU determining when the synchronization point completes. A megakernel can remove launch gaps inside the compute phase, but it cannot eliminate NVLink latency or global synchronization costs.
Speculative Decoding and Acceptance Length
Muse Spark Open uses DFlash V2 as its draft model. The draft predicts 15 subsequent tokens in one pass, after which the target model verifies a 16-token sequence in one forward pass. The team also evaluates a draft-token tree rather than accepting only a linear candidate chain. In the published comparison, Muse Spark Open verifies 16 tokens per step and accepts an average of 6.6.
For reference, MiMo-V2.5-Pro crossed 1,000 tok/s by verifying 8 tokens per step and accepting 6.3 on average. Verifying more tokens activates more experts and increases the target model's work per step, so the 16-token configuration is not free: it exchanges higher verification cost for a longer accepted length. Production deployments should inspect the acceptance-length distribution across prompts, output lengths, and task types rather than relying on a single average.
How to Interpret the Measured Result
The 1,109 tok/s figure is the median of 20 decoding steps from one GSM8K request at TP8. It clearly demonstrates the execution efficiency of the megakernel for that workload, but it should not be treated as multi-user serving throughput. Higher concurrency changes weight reuse, routing distribution, KV-cache occupancy, and the communication bottleneck.
The published results do not cover:
- TTFT, TPOT, or time to first useful response;
- Aggregate output throughput under concurrent requests;
- p95 and p99 tail latency or long-output stability;
- Expert-load balance at larger batch sizes;
- GPU power, cost per million tokens, or NVLink utilization;
- Independent quality measurements for NVFP4 and speculative decoding;
- Same-condition replication across other models, hardware, and serving stacks.
The MiMo-V2.5-Pro comparison shows that thousand-token-per-second decoding is already an engineering reality. Because the model, hardware, batch size, verification policy, and prompts may differ, however, it does not prove that Muse Spark Open is universally faster or establish a universal first-place record.
Engineering Trade-offs: Large Kernels Are Not Free
First, complexity moves from the serving framework into hand-written CUDA and PTX. Roughly 8,000 lines increase debugging, validation, and toolchain-maintenance costs. Work normally handled by frameworks, compilers, and runtimes becomes the kernel implementer's responsibility.
Second, monolithic kernels face instruction-cache and register-pressure risks. A very large kernel spreads hot instruction paths across more code, while the compiler may face higher register requirements and longer live ranges. Spills can quickly erase the benefit. Layer-level fusion preserves a manageable working set and synchronization boundary; a full-model kernel would amplify these issues. PTX provides finer control but also binds the implementation more tightly to a particular compiler and GPU architecture.
Third, role specialization reduces generic scheduling flexibility. If a warp waits on an mbarrier, NVLink data, or a KV address, the general GPU scheduler cannot easily reassign its work as it might in an ordinary kernel. The implementation must explicitly guarantee that no single dependency stalls the critical path.
Fourth, memory-hiding gains coexist with communication costs. Weight prefetch can improve bandwidth utilization, but it cannot shorten the physical time required to read NVFP4 weights or remove all-gathers. At larger batch sizes, MoE routing imbalance may make one GPU the synchronization bottleneck, requiring coordinated changes to expert placement, parallelism, and batch scheduling.
Fifth, the speed gain requires a quality audit. The post does not report accuracy, task pass rates, or inference-consistency results before and after quantization. A high token rate is not sufficient grounds for replacing a production baseline without quality regression tests.
Recommendations for Production Evaluation
-
Reproduce the exact baseline. Test the ordinary SGLang path and
facebookresearch/sgl-muse-megawith the same Muse Spark Open weights, NVFP4 precision, TP8 topology, DFlash V2 drafter, prompt lengths, and batch sizes. Before deployment, verify the repository license, CUDA toolchain requirements, and supported GPU architectures. -
Measure latency and aggregate throughput together. Report TTFT, TPOT, single-request output tok/s, aggregate tok/s at several concurrency levels, p50/p95/p99 latency, peak memory, and failure rates. A single-request tok/s figure can conceal service-capacity problems.
-
Verify that overlap really occurs. Inspect achieved occupancy, DRAM bandwidth, tensor-core utilization, instruction-cache misses, register spills, mbarrier waits, NVLink traffic, and kernel launch counts with profiling tools. If bandwidth rises without a TPOT improvement, investigate synchronization tails before adding more prefetching.
-
Test routing distributions at scale. Record activated experts per GPU, all-gather wait time, and the gap to the slowest rank across batch sizes and workload mixes. The layer-spanning megakernel is especially valuable for low-batch decoding, but production benefit ultimately depends on whether real traffic keeps the pipeline full.
-
Add quality and resilience guards. Compare outputs from the quantized model and speculative-decoding path, checking task success, factual consistency, long-output drift, and rejection-sampling behavior. Retain a conventional kernel or CUDA Graph path as a fallback.
The contribution is not a new model, but a demonstration that low-batch MoE decoding still contains substantial reclaimable systems overhead. Roughly 1,450 per-operator launches can be reduced to one per layer, weight movement can be organized into a continuous pipeline, and GPUs can perform a form of multiprogramming through warp specialization. The cost is a highly Blackwell-specific, eight-GPU TP implementation with substantial hand-written low-level code. Production value therefore depends on concurrent throughput, tail latency, power, and quality data rather than the headline token rate alone.
— END —Source: LMSYS / SGLang Blog (2026-11-11)
Tags: #SGLang #Megakernel #CUDA C++ #MoE Inference #NVIDIA Blackwell
Editorial & Fact-Checking Note: This article is compiled from primary research, official release documentation, and source papers by the ZICQ Newsroom pipeline with automated entity verification and human editorial review. If you notice any technical inaccuracy, please submit a correction via our corrections policy or email our editorial desk directly.
Community Comments