> ## Documentation Index
> Fetch the complete documentation index at: https://docs.m-star.org/llms.txt
> Use this file to discover all available pages before exploring further.

# Declare and use state

> Choose an array, value, sampler, or sequence shard and follow it from admission to a forward.

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](https://github.com/mstar-project/mstar/blob/main/mstar/model/orpheus/orpheus_model.py) includes the checkpoint’s RoPE scaling.

```python theme={null}
Array(
    KV_CACHE, nodes={"LLM"}, layers=frozenset(range(c.num_hidden_layers)),
    entry=KVEntry(heads=c.num_key_value_heads, head_dim=c.head_dim),
    max_len=c.max_position_embeddings,
    positions=Positions(rope=Rope(theta=c.rope_theta)),
    reads={ATTN: Read(mask=Causal(), op=Attend(q_heads=c.num_attention_heads))},
)
```

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](https://github.com/mstar-project/mstar/blob/main/mstar/model/components/sampled_token_decoder.py) 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](https://github.com/mstar-project/mstar/blob/main/mstar/engine/state/calls.py)

## Choose a declaration

| What the node needs | Declare | What the forward does |
| - | - | - |
| Append-only history, such as KV | `Array` with an `Entry` or `KVEntry`, layers, labels, and reads | Add and read through its handle. Select a causal, bidirectional, block, or window mask. |
| A per-request tensor overwritten across steps | `Value` with fields, plus any named update ops | Read and write the current value or call the declared recurrent operator. |
| Token draws, prompt penalties, and filters | `Sampler` plus per-request `SampleSettings` | Call `sample` on this node’s sampler handle. |
| Steps split across sequence ranks | `SeqShard` with nodes, a label, walks and an exchange | Scatter or gather the declared token dimensions. |

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](https://github.com/mstar-project/mstar/blob/main/mstar/engine/state/contract.py) give all fields and their defaults. The [public import surface](https://github.com/mstar-project/mstar/blob/main/mstar/engine/state/__init__.py) 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](https://github.com/mstar-project/mstar/blob/main/mstar/engine/state/adapters.py)

### Deployment overrides

| Declaration | Resource | Key | `resources:` keys |
| - | - | - | - |
| `Array` with `max_len` above 0 | `KVSpec` with a `PagedKVConfig`: a paged KV pool | the array's name | `max_num_pages`, `page_size`, `max_seq_len`, `cpu_offload_pages`, `prefix_cache`, `prefix_cache_salt`, `prefix_cache_tp`, `context_parallel`, `dtype` |
| its `Attend` read (`Causal`, `Window` or `Bidirectional`) | `AttentionSpec` over the pool | the read's key | `backend` (e.g. `auto`, `flashinfer`, `dense`, `xpu_paged`), `flashinfer_backend` (`auto`, `fa2`, `fa3`), `decode_tensor_cores`, `decode_fmha`, `dtype` |
| its `Attend` read with `queries=` | `CrossAttentionSpec` over the pool | the read's key | `backend` (`auto`, `flashinfer`), `flashinfer_backend`, `decode_tensor_cores`, `dtype` |
| its `Positions` | `PositionSpec` | `rope`, or `<x>_pos` for an array named `<x>_kv` | none |
| `Array` of one unsharded `k` with a `TopK` read that a latent array's `Selected(of=)` mask names | `DSASpec` over the latent array's pool | the key array's name | none |
| `Array` with `max_len=0` and a `Block` read | `RaggedAttentionSpec`, or `RaggedCrossAttentionSpec` with `queries=`; reads of one kind, nodes and config share the first one's | the read's key | `backend` (`auto`, `flashinfer`, `dense`, `cudnn`, or `sdpa`, which builds no resource), `flashinfer_backend`, `max_segments_per_request`, `max_segments_per_step`, `max_tokens_per_request`, `dtype` |
| `Array` with `max_len=0` and a `BlockCausal` read | `RaggedBlockCausalAttentionSpec` of the mask's block size | the read's key | as a `Block` read's |
| `Array` with `max_len=None` and one `Window` or kept-window read | `BoundedKVSpec`: one slot per request | the array's name | `max_slots` |
| `Array` whose reads are all `FrameWindow` reads | `KVSpec` with a `RingKVConfig`: a ring of frames per session, read through flex attention | the array's name | `num_sessions`, `dtype` |
| `Array` with one `Bidirectional(kept_window=True)` read | `RollingKVSpec`: the rolling store, one region per request | the array's name | `pool_tokens` |
| `Value` with tensor fields | `RecurrentStateSpec`: one slot per request and label | the Value's name | `max_slots`, `max_slots_of` (unless the block sets `max_slots`: a paged array whose pages size this pool, a slot per label for each request they could hold, or another `Value`, whose pool size this one takes), `state_dtype` (the `state` field of a `GatedDeltaNet` or the `ssm` field of a `Mamba2`), `prefix_slots` |
| `Value` with `largest=` (a sized Value) | `SizedValueSpec`: each request's fields at its own sizes, admitted by their bytes | the Value's name | `max_bytes` |
| its `GatedDeltaNet` or `Mamba2` update | `LinearAttnSpec` over the Value's pool | the update's key | `backend` (`flashinfer`, the default and the only backend GDN and Mamba-2 run) |
| its `CausalConv` update | runs inside the Value's linear attention | the linear attention's | none |
| `Value` with host fields only | nothing on the device | none | none |
| `Sampler` | `SamplerSpec` | the sampler's name | `enable_logprobs`, `enable_processed_logprobs`, `greedy_capture` |
| `SeqShard` | `SeqShardSpec` | the shard's name | `min_tokens`, `exchange` (`auto`, `none`, `ulysses`, `all_gather`, `ring`) |
| `lora_roots()` | `LoraSpec`, only with a `resources: lora:` block | `lora`; each node's pool is `lora@<node>` | `max_slots`, `max_rank`, `cpu_capacity`, `adapters`, `targets`, `runtime_updates`, `runtime_update_timeout_s`, `dtype` (the slot weights’) |

### 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](https://docs.m-star.org/adding_models.md#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](#attention) 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](https://github.com/mstar-project/mstar/blob/main/test/modular/test_whisper_kv_sizing.py)

### 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](#bounded-kv)). 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`](https://github.com/mstar-project/mstar/blob/main/mstar/model/components/mla.py) 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 attention workload | Default implementation |
| - | - |
| NVIDIA | FlashInfer. A deployment can select a supported kernel variant or explicitly choose another supported backend. |
| AMD, ordinary paged causal attention | AITER’s unified attention when available, otherwise AMD FlashInfer. A non-causal step with one query per row can run there too. |
| AMD, power-of-two page size of 64 or less | AMD FlashInfer. The AITER kernel can read an unmasked page tail at these sizes. Install AMD FlashInfer or choose a supported layout such as 128-token pages. |
| AMD, sliding windows, windowed pools, an explicit attention scale, context-parallel KV, or SP-split steps | AMD FlashInfer FA2. The AITER manager cannot handle these configurations. |
| AMD, non-causal step with several queries per row | AMD FlashInfer FA2. This need is checked when the first such step is planned. |

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](https://github.com/mstar-project/mstar/blob/main/mstar/engine/resources/attn/base.py) · [AITER constraints](https://github.com/mstar-project/mstar/blob/main/mstar/engine/resources/attn/aiter.py) · [Supported hardware](https://docs.m-star.org/hardware.md)

### 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](https://github.com/mstar-project/mstar/blob/main/mstar/engine/resources/attn/ragged/base.py) · [Tuning tables](https://github.com/mstar-project/mstar/tree/main/mstar/kernels/tables/ragged_attention)

### 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](#attention) instead keeps the sink and trailing window contiguous in the rolling store, which runs no attention of its own; a [legacy](https://docs.m-star.org/contributing/legacy-resources.md#hand-written-specs) `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](https://github.com/mstar-project/mstar/tree/main/mstar/engine/resources/kv/bounded) · [Rolling layout](https://github.com/mstar-project/mstar/blob/main/mstar/engine/resources/kv/rolling/config.py)

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`](https://github.com/mstar-project/mstar/blob/main/mstar/model/components/token2wav/state.py)). 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](https://github.com/mstar-project/mstar/blob/main/mstar/engine/state/contract.py)

### 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](https://github.com/mstar-project/mstar/blob/main/mstar/model/qwen3_5/submodules.py)

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](https://github.com/mstar-project/mstar/tree/main/mstar/engine/resources/lora)

### 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](https://docs.m-star.org/serving.md#resources). [Prefix index](https://github.com/mstar-project/mstar/blob/main/mstar/engine/resources/kv/prefix_index.py) · [KV configuration](https://github.com/mstar-project/mstar/blob/main/mstar/engine/resources/kv/config.py)

### 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](https://github.com/mstar-project/mstar/blob/main/mstar/engine/resources/admission.py)

### 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](https://github.com/mstar-project/mstar/blob/main/mstar/engine/resources/kv/routing.py)

### 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](https://github.com/mstar-project/mstar/blob/main/mstar/engine/accelerator_graph_runner.py)

## 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](https://github.com/mstar-project/mstar/blob/main/mstar/engine/resources/sequence_shard.py)

`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](https://github.com/mstar-project/mstar/blob/main/mstar/engine/resources/kv/config.py)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.