> ## 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.

# Configure a deployment

> Choose a model configuration, place workers on GPUs, and set limits for concurrent requests.

Start with a shipped configuration that fits your hardware. Each entry in the [model catalog](https://docs.m-star.org/models.md#matrix) gives the launch key, default YAML and GPU count. Use a copy of that YAML to change placement or memory limits.

## Start a server

For Qwen3-Omni’s default two-GPU configuration, run:

```bash theme={null}
mstar serve qwen3_omni --gpus 0,1 --host 127.0.0.1
```

In another terminal, wait for `curl -fsS http://127.0.0.1:8000/health` to return `{"status":"healthy"}`. The launcher prints its banner before loading weights. See [cold start](https://docs.m-star.org/cold-start.md) for typical timings and startup errors.

To run a second deployment, give it its own GPUs and port. The launcher derives a separate socket directory from the port.

[Launch from a YAML file with `mstar-serve`](https://docs.m-star.org/reference/cli#mstar-serve).

## Use a custom YAML

Copy the default for your model from `configs/` in a checkout. For a wheel install, copy it from the installed package. For example, with Qwen3.5 9B installed:

```bash theme={null}
python -c 'from importlib.resources import files; from pathlib import Path; Path("my_qwen.yaml").write_bytes(files("mstar.default_configs").joinpath("qwen3_5_9b.yaml").read_bytes())'
mstar serve qwen3_5_9b --config my_qwen.yaml --host 127.0.0.1
```

The `model:` field in your YAML selects the model. Keep the positional launch key consistent with it so the startup examples match. To launch a YAML directly on one machine, use `mstar-serve --config my_qwen.yaml --tensor-comm-protocol SHM`. This lower-level command defaults to RDMA. [CLI reference](https://docs.m-star.org/reference/cli.md)

## Read a deployment config

`model` selects the implementation, `node_groups` assigns the model’s named components to workers, and `max_seq_len` is a required top-level key. Each KV cache has its own sequence limit. This [single-GPU BAGEL config](https://github.com/mstar-project/mstar/blob/main/configs/bagel_single_gpu.yaml) places all four components on rank 0:

```yaml theme={null}
model: bagel
max_seq_len: 32768
node_groups:
  - {node_names: [vit_encoder], ranks: [0]}
  - {node_names: [vae_encoder, vae_decoder], ranks: [0]}
  - {node_names: [LLM], ranks: [0]}
```

### Size a resource

Use the resource name the model declares. For example, Qwen3-Omni calls its Thinker cache `thinker_kv`. The following override sets its device and host page pools. An unknown resource name or field fails deployment validation. [Qwen3-Omni config](https://github.com/mstar-project/mstar/blob/main/configs/qwen3omni_2gpu.yaml)

```yaml theme={null}
resources:
  thinker_kv:
    max_num_pages: 1024
    cpu_offload_pages: 1024
```

A single-rank replica can reuse prefixes cached on that replica. To share prefix decisions across ranks in a TP group, set `prefix_cache_tp: true` and `cpu_offload_pages: 0`. All nodes and walks that use that pool must run in that one group. [Replica routing](#data-parallelism)

Set `prefix_cache: false` on a cache to disable reuse, or send it in an individual request’s `model_kwargs`. Sliding-window caches cannot reuse prefixes. A model without a checkpoint identity needs a `prefix_cache_salt` to enable reuse. [Resource declarations](https://docs.m-star.org/contributing/state-contract.md)

`dtype`, for example `dtype: bfloat16`, sets the dtype a resource stores in, or the dtype an attention plans its kernel in. Paged and ring KV caches, attention, cross-attention, ragged attention and `lora` accept it. The value is a torch dtype name such as `bfloat16` or `torch.bfloat16`, and must be a float of 16 bits or more. fp8 and fp4 fail at load, since a quantized cache needs scales rather than a cast. FlashInfer and dense attention take float16 and bfloat16 only, so a float32 paged cache read through them fails at load. Without `dtype`, a resource takes the dtype the model declares for it, then, for an attention, its KV cache’s dtype, then the dtype its nodes compute in. A recurrent pool sets its state’s dtype with `state_dtype` instead. [Resource dtypes](https://docs.m-star.org/contributing/state-contract.md#resource-dtype)

### Set a node’s precision

The model gives each node a precision policy: the dtype its parameters are cast to, the modules kept in fp32, and whether its forward runs under autocast. Autocast is off unless the model turns it on. A `nodes:` block tightens the policy for one deployment:

```yaml theme={null}
nodes:
  LLM:
    precision:
      param_dtype: float32     # also: fp32_modules: [...], autocast: false
```

The block can turn autocast off but not on, and add fp32 modules but not remove the model’s. It cannot set `param_dtype` on a node that keeps its build dtypes. Widening a tensor that the model allocates in a narrower dtype fails at load, because its weights would already be rounded. For example, `param_dtype: float32` or an added fp32 module fails on a node whose model builds it in bfloat16 regardless of the policy. An unplaced node or an unknown key also fails at startup. The top-level `autocast_dtype` key is no longer read, and setting it fails at startup. [Node precision](https://docs.m-star.org/adding_models.md#node-precision)

### Bound concurrency and KV pressure

`max_concurrent_requests` limits admitted requests. At capacity, ordinary requests queue and an incoming live-input call receives 503. Set a positive cap appropriate to your prompt and output lengths. Separately, `MSTAR_MAX_CONCURRENT_REQUESTS` limits HTTP requests at the Rust frontend. [Configuration](https://docs.m-star.org/reference/config.md#admission) · [HTTP limits](https://docs.m-star.org/reference/http-api.md#routes)

While a request is running, its KV pool may need pages that other requests hold. `cpu_offload_pages` gives the pool host space for preempted requests. Rebuildable requests can also release pages and recompute from saved input. Streaming output modalities listed in `unpausable_outputs` (default `[audio]`) reserve their footprint before starting. Watch queue time, page use and preemptions together. [Metrics](https://docs.m-star.org/metrics.md#engine-workers)

### Set the prefill token budget

`max_batch_tokens` limits the prompt tokens processed in one step on a node that supports chunking. This Qwen3.5 example applies one budget to all budgeted walks on `LLM`:

```yaml theme={null}
max_batch_tokens:
  LLM: 512
```

For a mixed prefill/decode walk, the combined walk’s budget caps the step. For example, Qwen3-Omni accepts `Thinker: {thinker_mixed: 512}` under `max_batch_tokens`. Sequence-parallel nodes with `sp_size` above one run whole prefills. [Scheduling keys](https://docs.m-star.org/reference/config.md#scheduling)

## Place workers

Each rank identifies a worker process. Unless `rank_devices` maps it elsewhere, rank *n* uses visible device *n*. Use the default topology first. Choose a different shipped config according to the resource you need to distribute.

### Separate prefill and decode

Use `graph_walks` to assign a node’s prefill and decode work to different ranks. [BAGEL’s disaggregated config](https://github.com/mstar-project/mstar/blob/main/configs/bagel_pd_disaggregated.yaml) places its prefill walks on rank 0 and its decoding and image generation on rank 1.

### Split weights across GPUs

For a tensor-parallel node, list the distinct ranks in ascending order and set `tp_size`. The model must support TP for that node. In [Qwen3.5 9B TP2](https://github.com/mstar-project/mstar/blob/main/configs/qwen3_5_9b_tp2.yaml), only the language model is sharded:

```yaml theme={null}
node_groups:
  - {node_names: [vision_encoder], ranks: [0]}
  - {node_names: [LLM], ranks: [0, 1], tp_size: 2}
```

### Split tokens or guidance branches

`sp_size` distributes tokens for a compatible node. `cfg_size` distributes classifier-free guidance branches. Each instance needs `cfg_size × sp_size × tp_size` ranks, with adjacent TP ranks. [Wan2.2’s four-GPU config](https://github.com/mstar-project/mstar/blob/main/configs/wan22_cfg2_sp2_4gpu.yaml) uses two sequence shards per guidance branch.

### Replicate for concurrent requests

Supply enough ranks for several complete instances. In [Qwen3.5 9B DP2](https://github.com/mstar-project/mstar/blob/main/configs/qwen3_5_9b_dp2.yaml), each GPU holds the entire model. The conductor chooses a replica using its current load and expected prefix-cache hit. Set `routing_weights.prefix: 0` to route by load alone.

### Distribute experts

On an EP-enabled node, `ep_config: {parallel: ep}` assigns whole experts to TP ranks while attention and dense layers stay tensor-parallel. The number of experts must be divisible by the group size. [Qwen3-Omni Thinker EP2](https://github.com/mstar-project/mstar/blob/main/configs/qwen3omni_thinker_ep2.yaml)

### Share a GPU between workers

Use `rank_devices` to place separate worker processes on one device. On NVIDIA, `mps: true` lets their kernels overlap and requires `nvidia-cuda-mps-control` on `PATH`. Give each worker a `gpu_memory_fraction` that leaves room for other workers, CUDA contexts and communication buffers. [Qwen3-TTS split-worker config](https://github.com/mstar-project/mstar/blob/main/configs/qwen3tts_split.yaml)

## Set model defaults

The YAML’s `model_kwargs` go to the model constructor. Use them for deployment-wide choices such as a checkpoint or camera count. Sampling options, output length and voice usually belong to the individual request. [Model guides](https://docs.m-star.org/models.md) · [Generation parameters](https://docs.m-star.org/clients.md#generation-parameters)

## Authenticate clients

Both launchers bind `0.0.0.0` by default. For local use, pass `--host 127.0.0.1`. For bearer authentication, provide `MSTAR_API_KEY` in the server’s environment and send the same key with the client. An explicit `--api-key` overrides the environment, including an empty value. A missing or incorrect credential returns 401 on protected HTTP routes.

The server warns at startup if authentication is disabled. Passing an empty `--api-key` after shell expansion turns it off even if the environment contains a key. With authentication enabled, protected WebSocket handshakes also require the key.

The health, metrics and openpi health probes are public. The openpi socket also accepts `Authorization: Api-Key <key>`. A Dynamo deployment handles authentication at the Dynamo frontend or its gateway. [HTTP routes](https://docs.m-star.org/reference/http-api.md#routes)

## Choose tensor transport

| Transport | Use | Requirements |
| - | - | - |
| `SHM` | Workers on one host. Default for `mstar serve`. | Shared memory visible to the workers. |
| `TCP` | Transfer over a TCP interface. Set `--tcp-transfer-device` to select one. | Mooncake transfer engine. |
| `RDMA` | Transfer over an RDMA fabric. Default for `mstar-serve`. | Mooncake and RDMA-capable NICs. |

For TCP or RDMA, install `mooncake-transfer-engine>=0.3.13.post1`. Mooncake does not authenticate peers. Each worker chooses its handshake and data ports at startup, so restrict network access to the worker hosts themselves. Only hosts in the deployment should be able to reach them.

Before 0.3.12.post1, a host that could reach the TCP data port could read or write worker memory (CVE-2026-103764). Two denial-of-service issues on the handshake port remain open at the minimum version, 0.3.13.post1 (CVE-2026-103760 and CVE-2026-103761).

## Select the HTTP frontend

The launcher normally starts `mstar-server` after worker setup and warmup. If a source checkout reports a missing or stale binary, follow the build command in the error. The Linux wheel installs the binary into the environment’s scripts directory. `--rust-frontend-bin` selects an explicit build. `--python-frontend` selects the deprecated FastAPI frontend. [CLI options](https://docs.m-star.org/reference/cli.md#serve)

[Reuse compiled kernels](https://docs.m-star.org/cold-start.md#compile-cache).

## Profile one request

Start with `--log-stats` for a per-request timeline or `--log-stats-file stats.txt` to save it. The timeline measures wall time from input to delivery. Graph timings measure CPU work and launch time. Postprocessing may overlap the next step. For GPU waits and batch-wide costs, use the [worker phase harness](https://github.com/mstar-project/mstar/tree/main/benchmark/worker_phases). For continuous monitoring, [enable metrics](https://docs.m-star.org/metrics.md#enable).

[Scrape serving metrics](https://docs.m-star.org/metrics.md#enable).

For example, this excerpt from a `--log-stats` timeline shows when the first output arrived and how long streaming continued.

```text theme={null}
Timeline:
  recv → preprocess done                 62.6 ms
  preprocess done → conductor ingest      2.3 ms
  conductor ingest → first chunk        133.7 ms
  first chunk → last chunk              683.3 ms
  last chunk → conductor done             1.5 ms
  conductor done → finish                 3.1 ms
  total                                 886.5 ms
```

The first chunk arrived 198.6 ms after receipt (62.6 + 2.3 + 133.7). Another 683.3 ms elapsed before the last chunk. The transfer section reports time spent reading or registering tensors on each edge. Those intervals can overlap the graph timings.

## Tune CPU wakeup latency

If a profile shows gaps between short decode steps on an otherwise idle host, measure a representative workload before changing CPU affinity. `step_thread_core` controls thread placement. `idle_hold: qos` asks Linux to limit deep idle states and requires access to `/dev/cpu_dma_latency`. [Engine knobs](https://docs.m-star.org/reference/config.md#knobs)


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