# Haru

[Haru-122B-A10B-Preview](https://huggingface.co/higurashi-ai/Haru-122B-A10B-Preview) and [Haru-4B](https://huggingface.co/higurashi-ai/Haru-4B) are full-duplex spoken dialogue models from [higurashi-ai](https://github.com/higurashi-ai/Haru). Every **133 ms** (7.5 Hz, 3,200 samples at 24 kHz), the model takes one frame of caller audio and predicts one frame of its own audio and text, using a Qwen3.5 backbone, a one-step MeanFlow audio head, and the causal VibeVoice acoustic codec. SGLang-Omni serves both models over the `/v1/realtime` WebSocket endpoint.

| Checkpoint | Backbone | Hardware |
|---|---|---|
| [`higurashi-ai/Haru-4B`](https://huggingface.co/higurashi-ai/Haru-4B) | Qwen3.5-4B (dense) | 1 CUDA GPU |
| [`higurashi-ai/Haru-122B-A10B-Preview`](https://huggingface.co/higurashi-ai/Haru-122B-A10B-Preview) | Continually pretrained from `Qwen/Qwen3.5-122B-A10B` (122B total, 10B active) | 4 × 80 GB CUDA GPUs (`tp_size: 4`; ~247 GB bf16 checkpoint) |

The model weights are released under the Apache-2.0 license, and the audio codec parameters come from [microsoft/VibeVoice](https://github.com/microsoft/VibeVoice) (MIT).

## Quick start

### Installation requirements

Follow the [CUDA installation guide](../get_started/installation.md) on Linux with NVIDIA CUDA GPUs, then install the `haru` extra (`haru-speech==0.1.1`):

```bash
pip install "sglang-omni[haru]"
```

For a source install from the repository root, run `uv pip install --prerelease=allow -e '.[haru]'`. Run the commands below from the repository root when referencing `examples/haru/session_122b_h100.yaml` or `playground/realtime/app.py`.

### Start the server and check readiness

Haru-4B on one CUDA GPU:

```bash
sgl-omni serve --model-path higurashi-ai/Haru-4B --enable-realtime --port 8000
```

Haru-122B-A10B-Preview on four 80 GB CUDA GPUs with tensor parallelism (`examples/haru/session_122b_h100.yaml` sets `gpu: [0, 1, 2, 3]`, `tp_size: 4`, and `mem_fraction_static: 0.85`):

```bash
sgl-omni serve --config examples/haru/session_122b_h100.yaml --model-path higurashi-ai/Haru-122B-A10B-Preview --enable-realtime --port 8000
```

`--enable-realtime` is required because Haru serves only `/v1/realtime`. `--model-path` also accepts a local checkpoint directory containing `config.json`, `tokenizer.json`, and `model.safetensors` (or `model.safetensors.index.json` with its weight shards). On four 80 GB H100s, each rank holds about 59 GB of weights alongside the codec, MeanFlow head, and audio projectors; `mem_fraction_static: 0.85` leaves about 6 GB per rank for session caches and 12 GB to run.

Before reporting ready, the server warms up `max_sessions` conversations so codec streams and CUDA graphs are captured upfront. In another terminal, check readiness:

```bash
curl -fS http://localhost:8000/v1/realtime/capabilities
```

Continue when this returns HTTP 200 with `"native_full_duplex":true` (or check `curl -fS http://localhost:8000/health` for HTTP 200 with `"status": "healthy"`). During startup these endpoints may return HTTP 503 or refuse the connection.

### Connect over /v1/realtime

Clients connect to `ws://localhost:8000/v1/realtime` using the shared [Native Full-Duplex Protocol](../developer_reference/full_duplex_guide.md#native-full-duplex-protocol):

1. Wait for `session.created`, then send `session.update` with the character card in `session.instructions`, an optional voice clip as a base64 PCM16 WAV in `session.sglang.reference_audio`, and any sampling overrides in `session.sglang.sampling`:

```json
{
  "type": "session.update",
  "event_id": "configure",
  "session": {
    "type": "realtime",
    "instructions": "<character card text>",
    "output_modalities": ["audio", "text"],
    "sglang": {
      "reference_audio": {
        "media_type": "audio/wav",
        "data": "<base64 PCM16 WAV>"
      },
      "sampling": {
        "temperature": 0.7,
        "speak_first": false
      }
    }
  }
}
```

2. Wait for `session.updated`. The server prefills the prompt before sending `session.updated`. With `speak_first: true`, the server emits frame 0 immediately after `session.updated`, before any caller audio.
3. Stream **24 kHz mono PCM16** caller audio in `input_audio_buffer.append` (`audio` as base64 PCM16, with contiguous `sglang.seq` starting at `0`). Haru processes each 3,200-sample (133 ms) frame as it arrives and returns 24 kHz mono PCM16 frames in `response.output_audio.delta` together with text in `response.output_text.delta` (or `response.output_audio_transcript.delta` when `output_modalities` is `["audio"]`). `sglang.unit.done` acknowledges each 400 ms wire unit (three frames). Sending `response.cancel` ends the current response (`response.done` with status `cancelled`), and the next input frame continues the same session under a new response.
4. When input ends, send `sglang.input_audio.end` (any trailing partial unit is padded with silence), wait for `sglang.input_audio.drained`, then send `session.close`.

To talk to the server in a browser, start the realtime playground:

```bash
python playground/realtime/app.py --api-base http://127.0.0.1:8000 --port 8080
```

Open <http://localhost:8080> and click **Start talking**. Open the page through `localhost`, or the browser will not grant microphone access. Pass `--preset-root playground/realtime/assets/haru/presets` to load the bundled Chinese character-card preset, or build a character card using `render_card` in the [official Haru repository](https://github.com/higurashi-ai/Haru).

## Common options

Session sampling parameters go under `session.sglang.sampling` in `session.update`, or as server defaults with `--sampling.<field>`:

| Parameter | Default | Usage |
|---|---|---|
| `temperature` | `0.7` | Text sampling temperature in `[0, 2]`; `0` selects greedy decoding. |
| `top_k` | `25` | Top-k text sampling; integer `>= 1`. |
| `top_p` | `1.0` | Nucleus sampling in `(0, 1]`. |
| `guidance_scale` | `1.5` | Classifier-free guidance scale for the MeanFlow audio head, in `[1, 2]`. |
| `seed` | unset | Integer in `[0, 2^63 - 1]`; when omitted, the server draws a random 63-bit seed shared across tensor-parallel ranks. |
| `speak_first` | `false` | When `true`, emit frame 0 immediately after `session.updated` before any caller audio. |
| `eop_bias` | `0.0` | Logit bias added to the end-of-padding token, which starts the model's speech; positive values make it speak sooner. |
| `dry` | `true` | Enable DRY repetition penalty on text tokens. |

Server-side pipeline settings are passed as CLI flags to `sgl-omni serve` or set in a YAML config:

| Flag | Default | Usage |
|---|---|---|
| `--max_sessions` | `1` | Maximum concurrent conversations. Extra connections receive HTTP 503. Warmup exercises every batch size up to this value. |
| `--codec_backend` | `auto` | VibeVoice codec backend: `auto`, `triton`, or `torch`. |
| `--instructions` | `""` | Default character card when a session omits `instructions`. |
| `--haru.engine.mem_fraction_static` | auto (`0.85` in `session_122b_h100.yaml`) | Static GPU memory fraction for the `haru` stage (`--mem-fraction-static` also sets it). |
| `--skip-server-warmup` | `false` | Report ready without running startup warmup sessions. |

## Known limitations

- **Research preview behavior.** Haru-122B-A10B-Preview is a research preview and Haru-4B is a pretrained base model. Output depends strongly on the character card (`instructions`) and voice reference (`reference_audio`), and the model can stay silent in some conversations.
- **Realtime-only endpoint.** Haru serves `/v1/realtime` only; `/v1/chat/completions` and `/v1/audio/speech` are not supported.
- **CUDA only.** Requires NVIDIA CUDA without pipeline or expert parallelism (`pp_size == 1`, `ep_size == 1`).
- **Reference audio limits.** `session.sglang.reference_audio` (or its alias `session.sglang.tts_reference_audio`; passing both is rejected) must be a nonempty PCM16 WAV, 8–48 kHz, mono or stereo, at most **30 seconds** and **1 MiB**. Haru ships without voice clips; only use voices you have the right to use.
- **Session state and context.** Each session holds at most **32,768** positions (about 70 minutes minus prompt at 7.5 Hz) and closes with `context_exhausted` when full. `instructions`, `reference_audio`, and `sampling` are fixed after the first `session.update`, and `conversation.item.truncate` is not supported.

## Next steps

Protocol details, close codes, and the browser playground are documented in the [Full-Duplex Guide](../developer_reference/full_duplex_guide.md#native-full-duplex-haru). For model cards, character-card templates, and upstream details, see [higurashi-ai/Haru-122B-A10B-Preview](https://huggingface.co/higurashi-ai/Haru-122B-A10B-Preview), [higurashi-ai/Haru-4B](https://huggingface.co/higurashi-ai/Haru-4B), and [higurashi-ai/Haru](https://github.com/higurashi-ai/Haru).

## Benchmark results

Measured on an 8×H100 80 GB node (Haru-122B-A10B-Preview with `tp_size: 4` and `mem_fraction_static: 0.85`; Haru-4B on one H100 80 GB), against the **133 ms** (7.5 Hz) frame budget:

| Model | GPUs | Per-frame latency p50 | Max concurrent (0 frames > 133 ms) | Steady-state p99 at max |
|---|---|---:|---:|---:|
| Haru-4B | 1 × H100 80 GB | 9.8 ms | - | - |
| Haru-122B-A10B-Preview | 4 × H100 80 GB (TP=4) | 13.5 ms | 24 | 55 ms |

Concurrency for Haru-122B-A10B-Preview was measured with 40 s conversations joining 1 s apart: up to 24 concurrent conversations completed with zero frames over 133 ms including while new sessions joined, with steady-state p99 per-frame latency of 55 ms at 24.
