Skip to main content
A model declares what each graph node keeps between steps. The engine chooses storage, reserves capacity, plans the step, and binds handles to the node. That separation lets an eager forward and a captured forward address the same request rows.

Trace one decoder step

Orpheus’s LLM appends keys and values, applies causal attention, and samples the next token. Its SNAC decoder only needs the audio-token window it receives. The following excerpt shows the shape of the LLM declaration. The full declaration includes the checkpoint’s RoPE scaling.
  1. Declare. Return the array and a Sampler from declare_state(). The array, its read, and the sampler have distinct names. Node and layer names must match the graph and the layers that bind them.
  2. Plan. A Segment gives the request, label, and span for one row. The decoder scaffold builds the segments. Its node_step supplies an ArrayStep and a SampleStep under the declared names. The engine checks capacity before the forward and commits the kept entries afterward.
  3. Run. A layer receives the array handle in bind_state, rotates Q and K with rope, and calls add_read(handle, layer, q, k=k, v=v). The node obtains each row’s last hidden state with at_last_token and draws through the sampler. Padding uses the resource’s sink. Handle calls

Choose a declaration

An ArrayStep can override segments for one array, fork a label at the start or end of a step, mark a scratch write with keep=False, or supply explicit positions. Set eager_add when the context must be inserted before graph replay. Set fixed_layout only if all replays truly match the captured segment layout. A SampleStep can specify which rows’ samples are retained. The contract definitions give all fields and their defaults. The public import surface lists the available model-side operations. A verify step, ArrayStep(verify=True), makes each row’s adds a verify block of 1 to the array’s verify_span entries (1 by default), on one label, kept, with no forks or placeholders. The forward calls settle(handle, kept) once, and row r keeps the first kept[r] entries of its block, the rest being as if never added. A verify step that ends without a settle raises. The pool and the position counter apply the counts at their next admit, or sooner where an offload, a drop or position() needs them. GLM-5.2’s MTP drafting verifies this way: with k draft tokens its latent array’s verify_span is k + 1, and a Value carries the next verify step’s input token and the draft’s seed, so the decode loop carries only the count. GLM-5.3-Flash’s MTP keeps each verify block whole instead, so the next step’s plan doesn’t wait on this step’s counts. A LatentEntry with rope_dim=0 on an array whose verify_span is above 1 does this: settle marks a row’s rejected entries, which every later read skips. Its pool holds max_len * verify_span entries per request, and it keeps no positions. A Value with a verify_span above 1 takes verify steps through KimiDelta, the one update that keeps verify blocks. The step’s settle comes after that update, and the Value can’t be read whole, since part of its entry lives in those blocks between steps. openable(handle) gives how many more requests can open a label on a Value, which at bind is its capacity.

Size and bind resources

Use the declaration name under the deployment’s resources: block. An array’s pool and its attention read have separate keys. For example, Orpheus’s kv_cache sets page capacity while its attn selects attention options. A misspelled name or incompatible setting fails at load. Keep the checkpoint’s head geometry in the model. Put the number of pages, host offload capacity, and deployment backend in YAML. Binding and overrides

Deployment overrides

Resource dtypes

A KV cache, attention, LoRA pool or recurrent state block resolves one dtype at load. A cache or pool stores in it, and an attention plans its kernel in it. The engine takes the first of:
  1. The dtype the resource declares: an entry’s TensorType or KVEntry dtype, a config’s or LoraSpec’s dtype, or the YAML dtype key.
  2. For an attention or cross-attention, the dtype of the KV cache it reads, since the kernel is planned against those pages.
  3. The dtype every node of the resource computes in: its autocast dtype under autocast, else its param_dtype (node precision).
If none applies, loading fails. That happens when a node keeps its build dtypes without autocast (param_dtype=None, autocast=False) or when the nodes compute in different dtypes. Declare the dtype in those cases; the engine never falls back to fp32. A resource can store in a different dtype from its nodes. An fp32 node whose KVEntry declares dtype=torch.bfloat16 gets bf16 pages, and its attention is planned in bf16. A declared KV, attention or LoRA dtype must be float16, bfloat16, or float32 (float64 for a CPU reference run). fp8 and fp4 need scales and a kernel that reads them, so they fail at load, as do integer and bool dtypes. FlashInfer, FlashInfer MLA and dense attention have float16 and bfloat16 kernels only, so a paged attention or cross-attention on one of them that resolves to float32 fails at load. Of the CUDA backends that read a KV cache, only flex, which reads ring caches, takes float32. RoPE stores nothing on CUDA. Its rope_dtype and rope_table_dtype set the rotation’s math and table. On XPU, the cos/sin cache is stored in rope_dtype, else in the nodes’ dtype.

Budget pages from a request

Describe each append-only label in the prompt’s state_layout. A Layout can include initial spans, growth per loop iteration, the largest scratch write, and a cap on growth. Its kept_windows gives each kept-window read its KeptWindow(sink, window=) in entries: the storage keeps the label’s first sink entries and its last window and gives back what lies between, so the footprint is the window’s. The layout and the request’s loop cap determine what admission needs to reserve. An encoder context written during prefill needs pages for the whole decode lifetime, even though its later steps append zero tokens. For Whisper’s 128-token pages, a 448-token decoder needs four pages per request and a 1,500-token encoder context needs twelve. At 64 requests plus the sink page, the two pools need 257 and 769 pages respectively. Keep the serving concurrency cap consistent with both pools. Whisper sizing test

Pick an attention read

Use Read(mask=Causal(), op=Attend(...)) for ordinary self-attention. Attend takes the query head count, a multiple of the entry’s heads, and an optional softmax scale, which defaults to head_dim ** -0.5. A read with queries= attends to a separate context. Whisper adds that context once with eager_add=True and reuses the resident pages on later steps. A finite paged array with a Window(N) read retains the recent window for those layers. The engine can pick different implementations for the same read on different accelerators. Two masks keep part of a long stream:
  • Bidirectional(kept_window=True) sees the first sink and last window entries the row kept before the step, and every entry the step adds. On an unbounded array a bounded cache holds it (below). On a finite array the layout’s kept_windows gives the sizes, as LingBot-World’s chunks read their sink and latest window, and the engine holds the array in the rolling store, which hands the read each row’s sink, window and step as one range. There the read must be its array’s only one, on an array of one label with no positions, walks or queries; loading refuses it on any other finite array. It takes packed queries, a step that reads it is never captured, and each step lists one row, adds one iteration of its loop’s growth and keeps its adds.
  • FrameWindow(tokens, frames=, stride=1) sees frames of tokens entries: every stride-th of the latest frames, and the step’s own frame. An array whose reads are all frame windows is held in a ring of frames per session, which a compiled region adds to and reads through FlexAttention, as Waypoint’s is. Each step adds one frame per row, and position() counts the frames a request has committed.
A read with op=None takes no queries and returns the entries it reaches as Reached, which the model attends itself. It needs a kept window, as LingBot-World’s reference_numerics reads one for its FlashAttention-2. An MLA checkpoint declares a LatentEntry(rank=, rope_dim=): the latent ckv of rank and, with rope_dim above 0, the decoupled RoPE key kpe, neither sharded, since every query head reads both. Its LatentAttend(q_heads=, scale=) read runs absorbed MLA. The model folds the key up-projection into q, passes each head’s RoPE part as q_pe, and applies the value up-projection to what the read returns. scale is the original query-key head dim’s, which the absorbed width doesn’t give. A latent array’s state op takes PagedLatent and writes at a PagedLatentTarget: the layer’s pages of rank + rope_dim and, with rope_table=True, the cos and sin rows of the step’s positions. The handle takes that format only where the array’s Rope declares a table_dtype and interleaves, and the reference runs otherwise. GLM-5.2’s mla_prep_attend normalizes, rotates and writes its latents in one launch this way. DeepSeek sparse attention (DSA) takes two arrays:
  • TopK(count=, heads=) is the indexer, over an array whose entry is one unsharded k. The read takes the indexer’s q and weights and returns each query’s count best positions. selects(handle) says whether some row reaches more than count picks.
  • Selected(of=) on the latent read sees only the positions passed as selected, which the TopK read of array of picked, and with selected=None what Causal() sees. The two arrays hold an entry at the same positions, so analysis refuses them with different verify_span.
The engine builds a DSASpec from the pair, as GLM-5.2 declares under dsa_long_context. Its keys sit in per-request buffers outside the paged pool and the selection runs per request on the host, so it can’t capture: GLM-5.2 offers no graph config under dsa_long_context, and the runner drops any config whose step reaches it. A prompt must fit in count, and past it a request decodes one row per step; once one row of a batch passes count, every row of it attends its pick. A layer that reuses an earlier layer’s pick takes the last full pick, which the model carries. AMD ROCm support is in progress. The AMD rows describe backend selection on that development path. Paged cross-attention supports both FlashInfer and AITER subject to these restrictions. On FlashInfer, one query per row uses the decode path; decode_tensor_cores selects its variant. Use the actual model and batch to measure a backend change. Paged backend selection · AITER constraints · Supported hardware

Keep attention within one step

An array with max_len=0 and a Block() read holds the current forward’s tokens. Use this for an encoder or diffusion transformer whose attention does not persist KV between iterations. A block read with queries= can pair separate query and key spans for each request. Preserve the request pairing when packing several rows. BlockCausal(size) instead sees the segment’s blocks of size entries up to the token’s own, as an audio tower that attends in chunks does. kernel_settings() can set backend on a Block or BlockCausal read. Queries that nothing on the node attends among themselves, such as a resampler’s learned queries, come from an array with max_len=0, entry=Entry({}) and no reads: its step plans nothing, it takes no add or read, and loading refuses one that no read’s queries names. Ragged auto defaults to FlashInfer on NVIDIA and AITER varlen attention on the in-progress AMD ROCm backend, with AMD FlashInfer as a fallback if AITER is missing. Unforced self-attention can select a measured kernel from the architecture’s tuning table. Cross-attention, an explicit flashinfer_backend, or an explicit backend change that choice. Unequal-length self-attention segments fall back to FlashInfer. Explicit cuDNN is refused for cross, key-prefix and block-causal attention. A capture can replay its cuDNN layout only if the step keeps it fixed. max_tokens_per_request, max_segments_per_request, or max_segments_per_step size capture capacity. Ragged selection · Tuning tables

Bound a stream’s history

An unbounded stream with one Window(size) read and max_len=None can keep its newest entries in a fixed-size ring. The stream holds its slot for its lifetime. A kept-window read instead keeps the sink and trailing window contiguous in the rolling store, which runs no attention of its own; a legacy RollingKVSpec declares the same store by hand. A block-causal read and a key-prefix read mask different positions. Choose the form the checkpoint requires. Bounded cache implementation · Rolling layout An unbounded array can take one kept-window read in place of the Window read. It keeps a sink and a window of a stream that begins with the row’s start: entries kept once and read where they live, as a voice prompt every request in the voice reads. start_lengths is the range of lengths a start may have, and the array’s kept_windows gives the read’s base KeptWindow(sink, window=, grows=), whose grows side, "sink" or "window", adds the start’s length; either side may be 0. The handle takes the starts once at bind (set_starts, each field (layers, n, *shape)), and each step names each row’s start by index (ArrayStep.starts), which a region’s step takes from the open step.
  • Bidirectional(kept_window=True, last_first=True) joins each step’s adds to the kept entries last-first, for attention that ignores key order, so a cut keeps the entries a step adds first the longest.
  • A row at span 0 attends its adds and keeps none, as a stream’s last window does, so such an array takes no keep=False.
  • Its distance_bias is (rows, q_heads, T, R), whose entry d + T - 1 adds to the key at distance d.
  • A float32 cache attends in IEEE fp32 rather than TF32. The read’s kernel setting ieee is on for a float32 cache, whether the entry names float32 or takes its nodes’ dtype.
MiniCPM-o’s token2wav declares its two conformer caches and its DiT’s cache this way (token2wav_state). Its voices’ prompts are the arrays’ starts, and the DiT’s two guidance rows are heads of one entry.

Positions

Positions() supplies a counter for learned embeddings. Add Rope(...) only when the resource rotates the layer’s queries and keys; rope(handle, q, None, at=ids) rotates q alone, at positions the model passes. On AMD this avoids building tables for a node that never uses them. Set partial rotary dimensions, interleaving, and scaling to match the checkpoint. With LongRoPE, choose the short or long table using the length its reference implementation uses. That choice must also be reflected in the prefix identity.

Samplers

Declare the filters the checkpoint supports. penalty, min_p, repetition_window and top_p_first on a Sampler declare capabilities, and each selects the kernel variant recorded into the captured graph. A request’s repetition_window needs the sampler to declare at least that window, and its top_p_first, or a top_p_min_keep above 1, needs top_p_first=True. A checkpoint that does not support a requested penalty or min-p filter should reject it at intake or admission. A multi-stage model can use two independently named samplers on one node. Give each its own settings, step, and handle. Padded rows and discarded samples must not become the next real token. Sampling declarations

Recurrent state

Use a Value for per-request state updated in place. Declare named GatedDeltaNet, Mamba2, CausalConv or KimiDelta operations where applicable. KimiDelta(lower_bound=) needs both a conv field of shape (3 * h * d, kernel - 1) and a float32 state of shape (h, d, d), and a layer runs it as one update through kimi_delta, as GLM-5.3-Flash’s ParallelKimiDeltaAttention does. Layers call the bound op on the current rows, so concurrent requests and padding address their own slots. A prefix hit on a recurrent model also needs the recurrent state at that boundary. Qwen3.5 state and node steps A sized Value, Value(..., largest={...}), has fields whose shapes name sizes, such as Size("lat_h", scale=8). Its layout gives each request’s own sizes (Layout(sizes={...})), and the engine admits the request by its fields’ bytes at those sizes, against max_bytes; a request whose fields take more bytes than at largest is refused at intake. Its read hands the row’s tensors over and write keeps the ones it is given, with no copy either way, so a step writes or clears every field it read. LingBot-World’s VAE caches are a sized Value.

LoRA weights

Declare supported weight targets in lora_roots(). The deployment chooses configured adapters, slot capacity, and whether to allow runtime updates. A base-model or padding row uses the zero adapter. Admission must be able to reserve the requested adapter before starting its row. The runtime can unload an adapter for new requests while existing requests finish using it. Adapter pool

Reuse a prefix

A model opts in by supplying stable prefix keys and a checkpoint identity. Include any input that changes KV, such as image content, adapter identity, and a position-scaling variant. Reuse only up to the boundary that every relevant resource can restore. For a prefix cache spanning a multi-rank group, follow the TP placement and offload restrictions. Prefix index · KV configuration

Admission and routing

Capacity held for a request’s lifetime goes through ask, reserve, and unreserve. The admission coordinator reserves all required resources or returns any partial reservation. A resource signals when capacity has grown enough to retry. Capacity held for one step uses admit and rollback_admit. Admission coordinator

Replica routing

When the conductor chooses among data-parallel replicas, a resource’s routing_mirror can estimate what each replica already has, including a cached prefix. Keep that estimate separate from the worker’s actual admission check. KV routing

Captures that omit unused operations

A resource can declare a lean capture that omits its kernels when every row allows it. A LoRA pool can do this for a batch with no adapters, and a sampler for an all-greedy batched draw. Every lockstep rank must make the same choice. The engine can fall back to the full bucket when a lean variant was not captured. Capture runner

Distribute attention

A SeqShard names the computations and walks that can split a step over sequence ranks. Pass its handle to the free functions scatter, gather and split_range. Specify the global token dimension before dividing work. Every rank in the instance must use the same group, shapes, and collective order. Sequence shard resource independent=True declares that no op on the shard’s nodes mixes the label’s units, so no array there opens the label. MiniMax-H3’s video decoder declares its clips this way. The shard splits the segments the node’s steps declare, each request’s units as one row, and exchanges none of them, so a rank may get none. Its exchange is auto or none.

Choose the exchange

Choose the exchange for the model’s head geometry and layout. With KV stored by head, Ulysses uses all-to-all to redistribute tokens and heads. With KV stored by position, auto leaves the step copied on the ranks. Opt into all_gather or ring to split its tokens: all-gather collects Q, K, and V before attention, while ring keeps K and V in place, rotates the queries and combines partial results.

Context-parallel KV

context_parallel: true stripes tokens within a logical page across partner ranks. Page size must divide evenly by the partner count. In TP mode the partners are ranks that would otherwise hold the same KV head. In SP mode the partners are the node’s SP ranks. Each resource reading the pool must support the placement. Configure all paged pools required by the node, and size the logical page count for the memory you intend to use. Placement validation