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

# Motubrain 2.0

> Deploy GensPI Motubrain 2.0 world action policies over HTTP and OpenPI WebSockets with SGLang Diffusion.

## 1. Quick start

Follow the [SGLang Diffusion installation guide](https://docs.sglang.io/docs/sglang-diffusion/installation.md), install `motubrain2` into the same Python environment, write `sglang.json`, and choose your checkpoint and server options below.

> [accordion] Installation and prerequisites
>
> Install SGLang with the diffusion extra from source:
>
> ```bash Command theme={null}
> git clone https://github.com/sgl-project/sglang.git
> cd sglang
> pip install -e "python[diffusion]"
> ```
>
> Install `motubrain2` from [`shengshu-ai/Motubrain-2.0`](https://github.com/shengshu-ai/Motubrain-2.0) into the same environment once you have repository read access (`motubrain2` is unpublished on PyPI). Include the `geometry` extra for checkpoints whose `config.json` declares `feature_layers` (all three published checkpoints), and arrange access for T5Gemma as noted on the [Distill model card](https://huggingface.co/GensPI/Motubrain2.0-Distill/tree/main).
>
> The three BF16 checkpoints are public on Hugging Face (`config.json`, `model.safetensors`, and `sampling.json`). Robot profiles (`profile.json`), PT3 normalization stats, and standalone MXFP8 bundles are pending upload to each `GensPI` repository.
>
> To add an optional explicit `--model-type motubrain2` CLI alias alongside default `sglang serve` auto-detection:
>
> ```bash Command theme={null}
> pip install -e examples/runtime/multimodal/motubrain2_backend
> ```

Create `sglang.json` pointing at your frozen encoders and robot profile (add `"action_stats"` when normalization stats sit outside the profile directory, and `"wan_config"` / `"da3_config"` for standalone `.pth` files):

```json Config theme={null}
{
  "wan": "Wan-AI/Wan2.2-TI2V-5B-Diffusers",
  "text_encoder": "/path/to/t5gemma",
  "da3": "/path/to/da3",
  "profile": "/path/to/profile.json"
}
```

## 2. Model capabilities

[Motubrain 2.0](https://github.com/shengshu-ai/Motubrain-2.0) is a world action model from GensPI that jointly denoises future video latents and continuous robot actions from camera clips, proprioceptive state, and a language instruction. SGLang serves the V2A action-only path through the native `motubrain2` package with Wan 2.2 VAE, T5Gemma text encoding, and optional DA3 geometry features, returning controller-space action chunks without video decoding.

Pick `Motubrain2.0-Distill` for lower-step Astribot control (`24x25`), `Motubrain2.0-Base` for the base Astribot policy, or `Motubrain2.0-Base-AgileX-Piper` for AgileX PiPER (`24x14` on the published model card, with active wire width loaded from `profile.json`). Serving runs on a single GPU (`TP=SP=DP=1`) with monolithic execution and no multi-GPU parallelism, classifier-free guidance, `--webui`, or CUDA graphs.

<table>
  <thead>
    <tr>
      <th>Component</th>
      <th>Implementation</th>
    </tr>
  </thead>

  <tbody>
    <tr>
      <td>Policy DiT</td>
      <td>Joint video-action transformer (`model.safetensors` BF16 or standalone `model-mxfp8.safetensors`), V2A action-only readout with no video decode.</td>
    </tr>

    <tr>
      <td>Visual encoder (`wan`)</td>
      <td>Frozen Wan 2.2 VAE (`Wan-AI/Wan2.2-TI2V-5B-Diffusers` or standalone `.pth` with `wan_config`).</td>
    </tr>

    <tr>
      <td>Text encoder (`text_encoder`)</td>
      <td>Frozen T5Gemma (`text_dim` 3584, up to 109 tokens, LRU-cached up to 64 instructions).</td>
    </tr>

    <tr>
      <td>Geometry encoder (`da3`)</td>
      <td>Optional frozen DA3 encoder, required when checkpoint `config.json` declares `feature_layers` (all three published checkpoints).</td>
    </tr>
  </tbody>
</table>

<table>
  <thead>
    <tr>
      <th>Model ID</th>
      <th>Embodiment</th>
      <th>Published action chunk</th>
    </tr>
  </thead>

  <tbody>
    <tr>
      <td>[`GensPI/Motubrain2.0-Distill`](https://huggingface.co/GensPI/Motubrain2.0-Distill/tree/main)</td>
      <td>Astribot (distilled)</td>
      <td>`24 x 25`</td>
    </tr>

    <tr>
      <td>[`GensPI/Motubrain2.0-Base`](https://huggingface.co/GensPI/Motubrain2.0-Base/tree/main)</td>
      <td>Astribot (base)</td>
      <td>`24 x 25`</td>
    </tr>

    <tr>
      <td>[`GensPI/Motubrain2.0-Base-AgileX-Piper`](https://huggingface.co/GensPI/Motubrain2.0-Base-AgileX-Piper/tree/main)</td>
      <td>AgileX PiPER</td>
      <td>`24 x 14` (14-dim state, profile-driven)</td>
    </tr>
  </tbody>
</table>

The matching `-serving` IDs and `GensPI/motubrain2-serving` are also registered. Active camera keys, observation frame counts, state width, and action shape always load from `profile.json` and `config.json` at startup and are exposed at `GET /v1/actions/metadata`.

References: [Motubrain 2.0 repo](https://github.com/shengshu-ai/Motubrain-2.0), [Action Models](https://docs.sglang.io/cookbook/vla/intro.md), [Robotics & Physical AI](https://docs.sglang.io/cookbook/use-cases/robotics-physical-ai.md), and [Action generation API](https://docs.sglang.io/docs/sglang-diffusion/api/openai_api.md#action-generation-sglang-extension).

## 3. API usage

Query `GET /v1/actions/metadata` once at startup (or read the initial `action.metadata` frame on WebSocket connect), then send observations over HTTP or OpenPI WebSockets. `/v1/actions/realtime` accepts the same enveloped payload as HTTP over WebSockets, while `/openpi/policy` accepts flat OpenPI payloads and preserves per-connection RNG and RTC state.

> [tab] HTTP (MessagePack)
>
> ```python Example theme={null}
> import numpy as np
> import requests
> from sglang.multimodal_gen.runtime.entrypoints.action.protocol import pack_msgpack, unpack_msgpack
>
> BASE = "http://127.0.0.1:30000"
> meta_resp = requests.get(f"{BASE}/v1/actions/metadata", timeout=30)
> meta_resp.raise_for_status()
> inp = meta_resp.json()["input"]
> clip = np.zeros((inp["observation_frames"], 256, 256, 3), dtype=np.uint8)
> obs = {"images": {c: clip for c in inp["image_keys"]}, "session_id": "episode-0", "reset": True}
> if inp["state_required"]:
>     obs["state"] = np.zeros(inp["state_dim"], dtype=np.float32)
> if inp["camera_extrinsic_required"]:
>     obs["camera_extrinsic"] = np.eye(4, dtype=np.float32)
> if inp["history_frames"] is not None:
>     obs["history_cameras"] = {c: np.zeros((inp["history_frames"], 256, 256, 3), dtype=np.uint8) for c in inp["image_keys"]}
>
> body = {"input": {"task": "pick up the cup and place it on the tray", "observation": obs}, "parameters": {"seed": 42}, "runtime": {"output_format": "numpy"}}
> hdrs = {"Content-Type": "application/msgpack", "Accept": "application/msgpack"}
> resp = requests.post(f"{BASE}/v1/actions/generations", data=pack_msgpack(body), headers=hdrs, timeout=60)
> resp.raise_for_status()
> res = unpack_msgpack(resp.content)
> print(res["data"][0]["action"]["values"].shape, res.get("timings"))
> ```

> [tab] WebSocket (/openpi/policy)
>
> ```python Example theme={null}
> import asyncio
> import numpy as np
> import websockets
> from sglang.multimodal_gen.runtime.entrypoints.action.protocol import pack_msgpack, unpack_msgpack
>
> async def main():
>     async with websockets.connect("ws://127.0.0.1:30000/openpi/policy", max_size=None) as ws:
>         inp = unpack_msgpack(await ws.recv())["input"]
>         clip = np.zeros((inp["observation_frames"], 256, 256, 3), dtype=np.uint8)
>         obs = {"prompt": "pick up the cup and place it on the tray", "images": {c: clip for c in inp["image_keys"]}, "reset": True}
>         if inp["state_required"]:
>             obs["state"] = np.zeros(inp["state_dim"], dtype=np.float32)
>         if inp["camera_extrinsic_required"]:
>             obs["camera_extrinsic"] = np.eye(4, dtype=np.float32)
>         if inp["history_frames"] is not None:
>             obs["history_cameras"] = {c: np.zeros((inp["history_frames"], 256, 256, 3), dtype=np.uint8) for c in inp["image_keys"]}
>         await ws.send(pack_msgpack(obs))
>         reply = unpack_msgpack(await ws.recv())
>         print(reply["actions"].shape, reply["server_timing"])
>
> asyncio.run(main())
> ```

> [accordion] Return all four native tensors (safetensors)
>
> Set `parameters.return_native_outputs: true` on HTTP (or top-level `return_native_outputs: true` on `/openpi/policy`) to retrieve `video`, `action`, `decoded_action`, and `decoded_valid` from one forward pass:
>
> ```python Example theme={null}
> import base64
> from safetensors.torch import load
>
> archive = res["extras"]["native_outputs"]
> tensors = load(base64.b64decode(archive["data"], validate=True))
> decoded_action, decoded_valid = tensors["decoded_action"], tensors["decoded_valid"]
> ```

> [accordion] Action request schema
>
> <table>
>   <thead>
>     <tr>
>       <th>Field</th>
>       <th>Type</th>
>       <th>Description</th>
>     </tr>
>   </thead>
>
>   <tbody>
>     <tr>
>       <td>`input.task`</td>
>       <td>string</td>
>       <td>Nonempty language instruction (also `prompt` or `instruction` on `/openpi/policy`).</td>
>     </tr>
>
>     <tr>
>       <td>`input.observation.images`</td>
>       <td>object</td>
>       <td>Map from each key in `image_keys` (or alias) to an RGB image or clip matching `observation_frames` (uint8/float arrays, base64, or multipart).</td>
>     </tr>
>
>     <tr>
>       <td>`input.observation.state`</td>
>       <td>array</td>
>       <td>Proprioceptive state vector of length `state_dim`. Required when `state_required` is true unless an anchored `rtc` constraint supplies the pose.</td>
>     </tr>
>
>     <tr>
>       <td>`input.observation.camera_extrinsic`</td>
>       <td>array, optional</td>
>       <td>Calibrated 4x4 base-from-camera matrix, required when `camera_extrinsic_required` is true.</td>
>     </tr>
>
>     <tr>
>       <td>`input.observation.history_cameras`</td>
>       <td>object, optional</td>
>       <td>Per-camera RGB clips with `history_frames` frames when sparse history is enabled.</td>
>     </tr>
>
>     <tr>
>       <td>`input.observation.session_id` / `reset`</td>
>       <td>string / bool</td>
>       <td>Episode ID for per-session RNG and server-side RTC state (required when `rtc_enabled` is true, LRU-bounded by `max_sessions`, default 64). Set `reset: true` to clear an active episode.</td>
>     </tr>
>
>     <tr>
>       <td>`input.observation.rtc`</td>
>       <td>object, optional</td>
>       <td>Explicit controller-space RTC constraint with `future` (`[N, action_dim]`), nonnegative `delay`, and optional `anchor` (`[action_dim]`). Works even when `rtc_enabled` is false.</td>
>     </tr>
>
>     <tr>
>       <td>`parameters.num_inference_steps` / `seed`</td>
>       <td>int, optional</td>
>       <td>Overrides default denoising steps from `sampling.json`. One-shot `seed` in `[0, 2^64 - 1]` preserves session RNG state.</td>
>     </tr>
>
>     <tr>
>       <td>`parameters.return_native_outputs`</td>
>       <td>bool, optional</td>
>       <td>Attaches a base64 safetensors archive under `extras.native_outputs` with `video`, `action`, `decoded_action`, and `decoded_valid`.</td>
>     </tr>
>
>     <tr>
>       <td>`runtime.prefix_cache`</td>
>       <td>bool, optional</td>
>       <td>Controls exact observation and text conditioning reuse per request (default `true`).</td>
>     </tr>
>
>     <tr>
>       <td>`runtime.output_format` / `response_format`</td>
>       <td>string, optional</td>
>       <td>`output_format` defaults to `"list"` for JSON and `"numpy"` for MessagePack and WebSockets. HTTP `response_format` selects `"envelope"` (default) or `"raw"`.</td>
>     </tr>
>   </tbody>
> </table>

## 4. Limitations

<table>
  <thead>
    <tr>
      <th>Feature</th>
      <th>Support or constraint</th>
    </tr>
  </thead>

  <tbody>
    <tr>
      <td>Single-GPU serving (BF16 / MXFP8)</td>
      <td>Supported on 1 GPU (`TP=SP=DP=1`). BF16 is the default. Standalone MXFP8 (`--mxfp8` or `"mxfp8": true` in `sglang.json`, overridden by `--mxfp8 false`) requires Blackwell (B200), `motubrain2[mxfp8]`, a complete local bundle (`manifest.json`, `config.json`, `sampling.json`, `model-mxfp8.safetensors`), `materialize_dtype: "bf16"`, and `compile: false`.</td>
    </tr>

    <tr>
      <td>Multi-GPU, CFG parallel, disaggregation</td>
      <td>Rejected at startup. Motubrain 2.0 runs monolithically on a single rank.</td>
    </tr>

    <tr>
      <td>`torch.compile` and CUDA graphs</td>
      <td>Generic `--enable-torch-compile` and per-request `runtime.cuda_graph: true` are rejected. Set `"compile": true` in `sglang.json` for BF16 compilation, or `"deterministic": true` for process-wide deterministic PyTorch execution.</td>
    </tr>

    <tr>
      <td>Conditioning cache and DiT cache</td>
      <td>Exact encoder and text caching default to enabled (bounded by `--conditioning-cache-max-size-mb`, `prefix_cache_max_entries` default `8`, `text_cache_size` default `64`, disabled with `--disable-conditioning-cache`). Approximate `dit_cache_enabled` defaults to `false`.</td>
    </tr>

    <tr>
      <td>Real-Time Chunking (RTC)</td>
      <td>Server-side RTC (`rtc_enabled: true`, `rtc_execute_prefix` default `1` below `action_horizon`, `rtc_delay` default `1`) requires a nonempty `session_id` on every HTTP call. Explicit per-request `input.observation.rtc` works even when `rtc_enabled` is false.</td>
    </tr>

    <tr>
      <td>`--webui`, generic quantization, ComfyUI</td>
      <td>Unsupported. Passing `--webui`, `--quantization`, `--component-precisions`, generic weight overrides, or legacy `video_mxfp8` keys fails startup.</td>
    </tr>
  </tbody>
</table>

### Silent defaults and runtime notes

* Local policy directories lacking a Diffusers `model_index.json` with `_diffusers_version` skip automatic pipeline detection. Pass `--pipeline-class-name Motubrain2Pipeline` (or select Local directory in the Server tab above).
* `POST /v1/actions/generations` accepts MessagePack, JSON, and `multipart/form-data`. `runtime.output_format` silently defaults to `"list"` for JSON and `"numpy"` for MessagePack and WebSockets. Floating-point camera clips are scaled by `255` and rounded to `uint8` only when every floating-point frame in the clip has maximum value `<= 1.0`. If any floating-point frame in the clip exceeds `1.0`, every frame in that clip is rounded and clipped directly to `[0, 255]`.
* Named HTTP sessions sit in an LRU table bounded by `max_sessions` (default `64`). Passing `parameters.seed` runs a one-shot seeded call without advancing session RNG state, while omitting it draws from the session generator (`inference_seed`, default `0`). Under `rtc_enabled: true`, omitting `session_id` raises `observation.session_id must be a nonempty string for RTC`. An absent or LRU-evicted session already starts with empty episode state (use `reset: true` to clear a live session, and note that per-request `input.observation.rtc` supplies an explicit RTC prefix without restoring evicted RNG state).
* Enabling approximate `dit_cache_enabled: true` (`dit_cache_skip_steps` default `4`, `dit_cache_skip_steps_2` default `2`, `dit_cache_damping` default `0.25`, requiring `DiTCacheConfig.for_recipe`) can shift predicted video latents and action chunks, so compare `return_native_outputs: true` against cache-off on fixed seeds before robot deployment.
* Startup pipeline config validation rejects non-`1.0` guidance with `Motubrain2 supports guidance scales of None or 1 only`, and rejects `"compile": true` or `"materialize_dtype": "fp32"` alongside `--mxfp8` with `mxfp8 requires eager execution with compile=False` or `mxfp8 requires materialize_dtype=bf16`. At request time, passing caller `noise`, `runtime.cuda_graph: true`, or a `guidance_scale` / `guidance_scale_action` value other than `1.0` returns HTTP 400 or WS 1008 (`Motubrain2 accepts a seed to generate joint video and action noise`, `Motubrain2 does not implement CUDA graphs`, or a field-specific unsupported-CFG error). Inspect active `runtime.mxfp8` and `runtime.weight_precision` at `GET /v1/actions/metadata`.

### Validation boundaries

In the initial integration PR, author-reported single-GPU NVIDIA B200 live HTTP parity replays matched native `motubrain2` inference byte for byte (regular actions and all four native outputs at seed 42) across local bundles of Distill (`24x25`), Base (`24x25`), and Base-AgileX-Piper (tested with a `24x16` robot profile) in both BF16 and standalone MXFP8 (`motubrain2[mxfp8]`), including Base-AgileX-Piper BF16 with `dit_cache_enabled` both `false` and `true`. Generated picker commands stay marked unverified pending public release of `motubrain2`, robot profiles, and PT3 stats, and H200/H100 serving, BF16 `torch.compile`, steady-state latency, and peak VRAM remain unmeasured.


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