Zero Labs
Industry News / AI

SGLang-Omni: The Model Was Never the Hard Part

Source · Towards AI By Aadishagrawal

From the publisher’s feed, collected in the ZeroLabs newsroom.

How SGLang serves a model that sees, hears, and talks back — and why it needed a whole new runtime on top of SGLang.The misconception I started withWhen I first heard about SGLang-Omni, I assumed I knew what it was.SGLang, the core project, is famous for making a single large language model fast — RadixAttention for KV-cache reuse, speculative decoding, a zero-overhead scheduler, all the clever tricks that squeeze more tokens per second out of a GPU. So “Omni,” I figured, must be the same bag of tricks applied to other modalities. Some radix-cache-like reuse for audio. Some speculative decoding for image tokens. Modality-specific algorithmic wins.That guess was wrong, and the way it was wrong turned out to be the interesting part.SGLang-Omni is not a set of per-modality algorithm optimizations. It’s a systems-level orchestration play. Its whole reason to exist is to take a model that isn’t one model at all — it’s a little committee of models that talk to each other — and decouple it into independent stages, so you can:put each stage on the right hardware,give each stage the scheduler it actually needs,scale up only the stage that’s the bottleneck,and contain a crash to one stage instead of taking down the whole request.In other words, the hard problem was never “make the model faster.” The model math was mostly already solved. The hard problem was serving it: how do you run a graph of cooperating models, streaming state between them in real time, across multiple GPUs, without the whole thing turning into a tangle?This post walks through how SGLang-Omni answers that, using Qwen3-Omni as the running example. We’ll follow one request from HTTP call to audio waveform, and along the way see why a plain script couldn’t do the job, how the pipeline is wired, and — importantly — how Omni leans on plain old SGLang for the heavy lifting rather than reinventing it.What Qwen3-Omni actually demandsTo see why Omni needed a new runtime, you have to look at what a modern omni-modal model actually is. Core SGLang is built to serve one autoregressive model behind one scheduler and one KV cache. Qwen3-Omni is a committee.Diagram 1 — The mental shift: one model vs a pipeline of stages.Qwen3-Omni isn’t a single autoregressive model. It’s built around two large decode backbones that hand off to each other:Thinker — the “understanding” brain. It takes text, images, video, and audio, fuses them, and generates text tokens. This is where the reasoning lives.Talker — the “speaking” brain. It takes Thinker’s output as it’s being produced and turns it into a stream of speech codec tokens, which a vocoder later turns into an actual waveform.Around those two, there’s a supporting cast: a vision encoder, an audio encoder, an aggregation step, a code predictor that fills in the fine detail of the audio codes, and a final vocoder. But the two things that dominate everything are Thinker and Talker.Here’s what makes this genuinely different from serving one LLM:Two backbones of roughly equal size. This is the crux. It’s not “one big model plus some small helpers.” Thinker and Talker are both heavy, both need continuous batching, both maintain a KV cache. The moment you have two comparably-sized models, you have a placement and resource-partitioning problem: do they share a GPU or not? If they share, how do you split GPU memory and KV cache between them — is 50/50 even right? If they don’t, how do you coordinate the traffic between devices? This is the real engineering pressure, far more than “supporting a vocoder.”Dual output. A single request can produce two results — a text answer and an audio answer. The system can’t just return whichever finishes first; it has to gather both.Real streaming between models. Talker doesn’t wait for Thinker to finish. It consumes Thinker’s hidden states token by token, so audio can start playing while the text is still being generated.A feedback loop. Talker and the Code Predictor play ping-pong: Talker emits one codec token, waits for the Code Predictor to send back an aggregated embedding, and only then takes its next step.None of these is a “just add a component” problem. They’re all about timing and coordination — who can run when, who’s waiting on whom, and where the intermediate state lives. That’s a scheduling and dataflow problem, and it’s exactly the kind of thing a single-model server isn’t built to express.Why a serial script — or even asyncio — can’t do itThe natural first reaction is: if core SGLang doesn’t handle this, why not just write a function that chains the models together?# The most naive serial approachdef process_request(request): state = preprocess(request) # CPU image_embeds = image_encoder(state) # GPU audio_embeds = audio_encoder(state) # GPU — only starts after image_encoder finishes merged = aggregate(state, image_embeds, audio_embeds) # CPU text_tokens = thinker(merged) # GPU:0 — next step only after thinker fully finishes text_result = decode(text_tokens) # CPU codec_tokens = talker(text_tokens) # GPU:1 — only starts after thinker fully finishes codes = code_predictor(codec_tokens) # GPU:1 audio = code2wav(codes) # GPU:1 return text_result, audioThis runs. It’s also a performance disaster, and the reason is subtle enough to be worth a number.Talker has to wait until Thinker is completely done before it starts. Say Thinker generates 100 tokens at 30 ms each, and Talker takes 20 ms per step. Serial time-to-first-audio is roughly 3000 ms + 20 ms ≈ 3020 ms. But if Talker could consume Thinker’s tokens as they arrive, time-to-first-audio drops to about 30 ms + 20 ms ≈ 50 ms. That’s a ~60× difference in perceived latency, and it comes entirely from overlapping work that the serial version forces into a line.So the next instinct is: fine, use asyncio, fire the encoders off in parallel, stream Thinker into Talker. That’s better — it at least admits the stages can advance concurrently. But single-process async only pushes the real problems back one layer. Five of them survive:GPU-memory isolation. Thinker is on GPU:0, Talker on GPU:1. Managing multiple large models across multiple GPUs in one process couples their CUDA contexts, memory allocation, and error handling. One model’s OOM becomes everyone’s problem. Separate processes give each stage its own clean device view.Different scheduling policies. Thinker needs continuous batching, KV-cache management, and dynamic batch changes. The Code Predictor is a lightweight step-by-step forward. Cramming both into one scheduler means either a monstrous unified abstraction or a pile of special-cased local logic. Split into stages, each stage picks the executor and policy that fits it.Fault isolation. In production, one model hanging or crashing shouldn’t kill the whole request chain. Process boundaries turn a stage crash into a stage crash.Bottleneck-only scaling. If Thinker is the bottleneck, you want to scale just Thinker. If a request doesn’t need speech, you want to drop Talker / Code Predictor / vocoder entirely. Stages make that a config change, not a rewrite.Control/data separation. Multi-process doesn’t have to mean “copy tensors everywhere.” The trick — which we’ll get to — is to send tiny metadata between stages (“the data is at this shared-memory slot”) while the big tensors move over shared memory or CUDA IPC, near zero-copy.Put together, these push you toward a specific shape: a multi-process, asynchronous producer–consumer pipeline, where each stage is its own process, upstream stages produce incremental results, and downstream stages consume them at their own pace.That shape is SGLang-Omni.The answer: a pipeline of stagesAt the top, SGLang-Omni is three layers:Diagram 2 — The three-layer runtime.The Coordinator is the front door and the mailroom. It does exactly three things: wrap the incoming request and hand it to the first stage; wait for the terminal stages to report back and merge their results; and, if the user disconnects, broadcast an “abort” to everyone. Crucially, it does not route between stages — it doesn’t decide “where does the encoder’s output go next.” Each stage decides that for itself via its own get_next. The Coordinator is a gatekeeper and a gatherer, not a traffic cop.Stage → Worker → Executor is where a request actually gets computed. The Stage is a runtime shell: it receives messages, aggregates inputs when several upstream stages feed into it, and manages routing. The Worker is the execution unit inside a stage. The Executor is the thing that finally calls the model.Control plane + Data plane is how stages communicate — and this split is the single most important idea in the whole system.The waiter and the food runnerHere’s the intuition. In a restaurant, the waiter carries the order ticket — small, fast, “table 4 wants the salmon.” The food runner carries the plate — big, heavy, needs care. You don’t make the waiter carry plates, and you don’t make the runner memorize orders.SGLang-Omni splits communication exactly this way:Control plane (ZMQ): the order tickets. Tens of bytes, microsecond latency. “Stage A finished; the result for request 7 is sitting in shared-memory slot 2.” That’s it.Data plane (the Relay): the plates. The actual tensors — encoder outputs, hidden states — move over shared memory, CUDA IPC, or NCCL, essentially zero-copy. They never touch ZMQ.Diagram 3 — Control plane vs data plane, and the credit system.The reason to separate them is that notifications and bulk data have opposite requirements. ZMQ is great for small control messages and terrible for moving giant tensors; shared memory and CUDA IPC are the reverse. Try to make one channel do both and you do neither well.The Relay also needs flow control, and it uses a beautifully simple mechanism: credits, which is really just a semaphore. Picture a fixed number of serving trays between two kitchen stations — say two trays. A “credit” is an empty tray.Upstream wants to send data → it takes a credit (grabs a tray), writes the tensor into that shared-memory slot, and sends a “data ready” ticket over ZMQ.Downstream reads the data → releases the credit (returns the tray) so upstream can reuse the slot.When all trays are full and downstream hasn’t caught up → upstream blocks. That’s backpressure, and it’s exactly what you want: a slow downstream naturally throttles a fast upstream instead of blowing up memory.This is why downstream stages are built to read incoming data as fast as they can — every read frees a tray and keeps the line moving.Add a model without touching the backboneOne design choice makes this framework more than a Qwen3-Omni special case: the pipeline topology isn’t hardcoded. It’s declarative config. A model doesn’t inherit a fixed set of steps — it declares its own stage graph, and the framework compiles that into a runnable pipeline.# sglang_omni/models/qwen3_omni/config.py (trimmed)class Qwen3OmniSpeechPipelineConfig(PipelineConfig): entry_stage = "preprocessing" terminal_stages = ["decode", "code2wav"] # two ends: text + speech gpu_placement = {"thinker": 0, "talker_ar": 1, "code_predictor": 1, "code2wav": 1} stages = [ StageConfig("preprocessing", get_next=preprocessing_next, ...), StageConfig("image_encoder", get_next=encoder_next, ...), StageConfig("audio_encoder", get_next=encoder_next, ...), StageConfig("mm_aggregate", get_next=aggregate_next, input_handler=AggregatedInput(sources=["preprocessing", "image_encoder", "audio_encoder"])), StageConfig("thinker", get_next=thinker_next_speech, stream_to=["talker_ar"]), # stream hidden states StageConfig("decode", get_next=None), # terminal StageConfig("talker_ar", get_next=talker_ar_next, stream_to=["code_predictor"]), StageConfig("code_predictor", get_next=code_predictor_next, stream_to=["code2wav", "talker_ar"]), # dual path: output + feedback StageConfig("code2wav", get_next=None), # terminal ]Notice how much of the system’s behavior is data here: which stage is the entry, which are terminals, which GPU each stage lives on, which stages stream to which. compile_pipeline() turns this into live processes.The payoff showed up when the team later added Ming-Omni, whose speech path uses a completely different approach (CFM/DiT flow-matching instead of Qwen3-Omni’s RVQ codec). The framework backbone barely changed — they wrote a new PipelineConfig and the model-specific executors, and the pipeline machinery just carried it. Model differences got pushed into config and executors, not into the runtime's core. There's even a variant mechanism so the same model can expose a 6-stage text-only pipeline and a 9-stage text-plus-speech pipeline, chosen at startup with --variant speech.Walk one request through the nine stagesLet’s follow a “text + image + audio” request through Qwen3-Omni’s full speech pipeline. With speech output on, it’s nine stages:STAGE ROLE DEVICE WHAT IT DOES───────────── ──────────────── ────── ────────────────────────────────────────────────────preprocessing Entry CPU Tokenize text; parse image/audio/video into tensorsimage_encoder Encode GPU Vision Transformer → image embeddingsaudio_encoder Encode GPU Mel-spectrogram encoder → audio embeddingsaggregate Fan-in CPU Merge text tokens with encoder outputs into one inputthinker Inference GPU:0 MoE Transformer; generates text tokens (then fans out)decode Output (terminal) CPU Turn token ids back into texttalker_ar Speech GPU:1 Autoregressively generate speech codec tokenscode_predictor Speech GPU:1 Fill in remaining RVQ code layers (feedback loop)code2wav Speech (terminal) GPU:1 Vocoder synthesizes the final audio waveformDiagram 4 — The Qwen3-Omni 9-stage pipeline. Note the fan-out (one input, many branches) at preprocessing and the fan-in (many branches, one input) at aggregate — plus the second fan-out at Thinker, where text and speech split.Reading the flow:Preprocessing (CPU) turns raw input into tensors and metadata. The instant it’s done, the result fans out to three places at once — the image encoder, the audio encoder, and the aggregate stage. True parallelism starts here, not at the model.Image & audio encoders (GPU) run independently and in parallel. The image encoder is a Vision Transformer; the audio encoder is a Transformer over Mel-spectrogram features. Each sends its embeddings to aggregate.Aggregate (CPU) is the classic fan-in node. It waits until all its upstream inputs have arrived, then merges the text tokens with the encoder outputs into a single input Thinker can consume in one shot. It does little compute — its job is synchronization.Thinker (GPU:0) is the semantic center. It embeds the tokens, injects the encoder outputs at the right placeholder positions, runs its Transformer stack, and generates text tokens. Then it fans out again — the most important branch in the system, because this is where text and speech formally split: A. the text branch sends the full result to decode;B. the speech branch streams to talker_ar token by token, passing along not just the token ids but Thinker's embeddings and a chosen layer's hidden states, so Talker can align to what Thinker meant.Decode (CPU, terminal) turns Thinker’s token ids back into text and reports completion.Talker AR → Code Predictor → Code2Wav (GPU:1) is the speech chain. Talker autoregressively generates codec tokens; the Code Predictor fills in the fine-grained RVQ layers (and feeds information back to Talker, more on that below); Code2Wav — a neural vocoder — accumulates codes and streams out 24 kHz audio chunks.When both terminals — decode and code2wav — report done, the Coordinator merges the text and the audio and returns them together.How Omni rides on SGLangHere’s the part I most misjudged at the start, and the part worth being precise about: SGLang-Omni is not a fork of SGLang. It’s an orchestration layer that sits on top of SGLang and treats it as a library for the compute-heavy work.Think of it as a division of labor:Diagram 5 — Omni owns the pipeline; SGLang owns the AR mathThe heavy autoregressive stages — Thinker and Talker — are the ones that need everything core SGLang is good at: continuous batching, KV-cache management, fast attention. So Omni doesn’t rebuild any of that. Those stages run through an EngineExecutor wrapping OmniEngine, a compact serving loop with its own Scheduler (picks requests, builds batches) and ModelRunner (runs the forward). And that ModelRunner stands on SGLang's shoulders — the Thinker model, for example, reuses:RadixAttention for efficient KV-cache management,SGLang’s fused kernels (like a fused QK-norm + RoPE kernel for a big speedup),and the same ModelRunner / forward / sampling machinery SGLang uses to serve a plain LLM.The lighter stages don’t need any of this. An image encoder is a one-shot operator: input in, forward once, output out. It runs through a much thinner DirectModelExecutor — no request state, no KV cache, no scheduler. This is the whole point of the Executor abstraction:class Executor(ABC): async def add_request(payload) -> None # submit async def get_result() -> StagePayload # collect async def abort(request_id) -> None # cancel def set_stream_fn(fn) -> None # streaming hookSame interface, wildly different implementations — a stateless forward for encoders, a stateful multi-step engine for Thinker and Talker. The pipeline doesn’t care which; it just calls add_request and awaits get_result.One more detail earns a single sentence: OmniEngine supports an overlap mode that runs the current step's GPU work while the CPU processes the previous step's results, the same GPU/CPU pipelining trick that made core SGLang's scheduler "zero-overhead." Omni reuses the idea rather than the exact code.So the mental model is: Omni owns when and where things run; SGLang owns how the autoregressive math runs. Everything speech-specific — encoders, vocoders, streaming audio, the pipeline itself — is Omni’s. The transformer decode loop is SGLang’s.The two clever tricksMost of the pipeline is boring in a good way: stage finishes, next stage picks up. But two relationships aren’t like that, and they’re where “temporal orchestration” stops being a phrase and starts being code.Diagram 6 — Streaming (Thinker→Talker) and the feedback loop (Talker↔Code Predictor).① Streaming (stream_to). Thinker doesn't hand Talker a finished paragraph. Every time it generates a token, it immediately pushes the corresponding hidden states out. Talker consumes them as a true producer–consumer stream:If Thinker is faster, a few tokens queue up and Talker catches up at its own pace.If Talker is faster, the queue empties and Talker simply awaits the next token.When Thinker finishes, it appends an end-of-text marker to the stream, and once Talker consumes it, Talker knows the text is done.There’s even a nice optimization on startup: if Talker finds several tokens already waiting when it begins, it prefills on the whole batch at once instead of crawling forward one token at a time.② The feedback loop (WAITING_FEEDBACK). This is the most intricate state transition in the system. Every time Talker emits a codec token, it can't just barrel ahead. It sends the token to the Code Predictor and deliberately parks itself in a WAITING_FEEDBACK state — and while it's parked, the scheduler won't pick it. The Code Predictor does its work, sends back a summed_embeddings, and only then does the engine flip Talker back to WAITING so it can take its next step. It's genuine ping-pong: step, pause, wait for the partner, resume. Expressing that cleanly is why the runtime needs an explicit notion of request state with pause and resume points — a plain streaming pipe couldn't capture it.Both patterns are invisible in a static DAG drawing. The DAG tells you the topology; these tell you the timing. And the timing is the actual product.TakeawaysComing back to where I started: SGLang-Omni taught me that for this class of model, the interesting engineering isn’t in the algorithms — it’s in the serving system.It’s decoupling, not a new algorithm. The core move is splitting one logical model into independent stages that run as separate processes. That’s what unlocks everything else.Right hardware, right scheduler, per stage. Two equal-sized decode backbones make placement and KV-cache/GPU-memory partitioning the central problem. Encoders and vocoders get lightweight one-shot executors; Thinker and Talker get full serving loops. One size does not fit all.Scale and trim by stage. Bottleneck at Thinker? Scale Thinker. No speech needed? Drop the whole speech chain via config. The pipeline bends to the workload.Separate the ticket from the plate. The control-plane / data-plane split — tiny ZMQ notifications alongside zero-copy tensor transport with credit-based backpressure — is what makes multi-process cheap instead of copy-heavy.Compose, don’t fork. The compute-heavy autoregressive stages delegate to SGLang and reuse RadixAttention, fused kernels, and its ModelRunner. Omni adds orchestration around SGLang; it doesn’t replace it.I came in expecting a bag of modality-specific speed tricks. What I found was a runtime whose entire job is coordination in time — getting a committee of models to see, think, and speak in a smooth, streamed, fault-tolerant flow. The model was never the hard part. The pipeline was.SGLang-Omni: The Model Was Never the Hard Part was originally published in Towards AI on Medium, where people are continuing the conversation by highlighting and responding to this story.