Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions docs/design/module/model_integration.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,11 @@ sufficient; an override MUST document the behavioral difference.

Test registration, checkpoint loading, input conversion, and representative
model execution. Test shared utilities against more than one integration.

## Platform-specific model adapters

Drama 3's Ascend attention compatibility, hybrid model state, and FP8 expert
adapter live under `platforms/npu/models/` and `platforms/npu/quant/`. Shared
model code selects these adapters lazily on NPU; CUDA keeps the upstream
implementations. Generic eager kernels and request-history snapshots remain
in the shared model implementation.
8 changes: 8 additions & 0 deletions docs/design/module/stage_runtime.md
Original file line number Diff line number Diff line change
Expand Up @@ -144,3 +144,11 @@ cleanup without duplicate stage shutdown.
processes.
- Obtain approval from a technical owner and an independent validation
reviewer.

## Platform preparation before stage construction

`StageEngineCoreProc` calls `current_omni_platform.prepare_stage_engine()`
before the upstream engine constructor creates its scheduler and cache
managers. The default hook is a no-op. The NPU implementation installs its
Mamba allocator signature compatibility here, so Ascend imports and patches
remain in the NPU platform and are not applied to other platforms.
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,7 @@ vllm serve fishaudio/drama-3 --omni --port 8091
```

The deploy config auto-loads from `vllm_omni/deploy/fish_omni.yaml` (the HF `model_type` on the checkpoint is `fish_omni`).
On Ascend, the same command uses the `npu` profile: Model Runner V2 with tensor parallel 2 and expert parallel across two 910B cards, and the DAC stage sharing the second card. See the recipe.

### Voice cloning

Expand Down
1 change: 1 addition & 0 deletions examples/online_serving/text_to_speech/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -417,6 +417,7 @@ vllm serve fishaudio/drama-3 --omni --port 8091
```

The deploy config auto-loads from `vllm_omni/deploy/fish_omni.yaml` (the HF `model_type` on the checkpoint is `fish_omni`).
On Ascend, the same command uses the `npu` profile: Model Runner V2 with tensor parallel 2 and expert parallel across two 910B cards, and the DAC stage sharing the second card. See the recipe.

### Voice cloning

Expand Down
2 changes: 1 addition & 1 deletion recipes/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ for RTX 4090, RTX 5090, DGX Spark, and RTX PRO 6000 Blackwell.
| [`FastVideo/FastH3-V2.md`](./FastVideo/FastH3-V2.md) | FastH3 V2 eight-step T2VA checkpoint | CUDA with FastVideo tile64 or FlashInfer on SM120/SM121; full-model qualification pending |
| [`FastVideo/FastH3-Omni.md`](./FastVideo/FastH3-Omni.md) | FastH3 Omni eight-step Ref2VA, multi-GPU serving | Shared eight-GPU profile; PRO 5000 baseline in recipe |
| [FastH3 RefOmni Single Card](<./FastVideo/FastH3 RefOmni Single Card.md>) | Single-card installation, serving, and generation guide | RTX 4090 / 5090 / DGX Spark / RTX PRO 6000 Blackwell |
| [`fishaudio/Drama-3.md`](./fishaudio/Drama-3.md) | Online serving for TTS | 1x H100 80GB |
| [`fishaudio/Drama-3.md`](./fishaudio/Drama-3.md) | Online serving for TTS | 1x H200 141GB / 2x Ascend 910B 64GB |
| [`fishaudio/Fish-Speech-S2-Pro.md`](./fishaudio/Fish-Speech-S2-Pro.md) | Online serving for TTS | 1x A800 80GB |
| [`Helios/Helios.md`](./Helios/Helios.md) | Text-to-video, image-to-video, and video-to-video generation | 1x NVIDIA H20 |
| [`HiDream-ai/HiDream-O1-Image.md`](./HiDream-ai/HiDream-O1-Image.md) | Text-to-image with shared offline example | 1x or 2x H100 80GB |
Expand Down
35 changes: 34 additions & 1 deletion recipes/fishaudio/Drama-3.md
Original file line number Diff line number Diff line change
Expand Up @@ -163,11 +163,44 @@ Throughput is seconds of audio generated per wall-clock second.

#### Known limitations

- One tensor and pipeline rank only.
- Pipeline parallel is not supported. The CUDA deploy uses one tensor rank.
The Ascend profile shards the backbone across two cards and the routed
experts with them (see NPU below).
- Prefix caching is off: prompt rows carry ten codes per audio row that
token-id hashing does not see.
- Some takes stop speaking after the first word or event and emit silence
until `max_tokens`. This is model behaviour; it is more frequent for lines
that start with a filler word or a tag, and with pause-heavy references.
- `previous_takes` (editing as continuation) and long-text chunking are not
exposed by the speech API yet.

## NPU

### 2x Ascend 910B 64GB

Stage 0 (backbone + codebook tower) uses Model Runner V2 on both cards:
tensor parallel 2 and expert parallel, replaying piecewise ACL graphs
(`enforce_eager: false`, `cudagraph_mode: PIECEWISE`). The NPU AR runner builds
Ascend input state (`AscendInputBatch` with `attn_state` and `seq_lens_np`)
and the model state builds Ascend attention metadata. Gated-delta-net stays on
the Ascend implementation. The codebook tower uses the eager norm and sampling
path. Stage 1 (DAC) shares the second card and stays eager, without ACL graphs
or MPS.
Sampling noise is broadcast from tensor-parallel rank 0 so both ranks draw
the same frame.

```bash
ASCEND_RT_VISIBLE_DEVICES=0,1 vllm serve fishaudio/drama-3 --omni --port 8091
```

`vllm_omni/deploy/fish_omni.yaml` applies this `npu` profile automatically
(`tensor_parallel_size: 2`, `enable_expert_parallel: true`, `max_num_seqs: 64`,
stage 0 `enforce_eager: false`).
Stage 0 reserves 0.72 of each card and stage 1 reserves 0.10 of the second
card. The speech request is the same as the GPU section.

vLLM-Ascend on 910B still expands this checkpoint's block-FP8 experts to
bfloat16 (64.4 GiB for all 256 routed experts). One card cannot hold that
expansion. Expert parallel places 128 experts on each card, about 32 GiB,
plus the sharded backbone. The codec then fits in the headroom on the second
card. This profile has not been scored for WER or RTF.
33 changes: 30 additions & 3 deletions tests/config/test_omni_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -971,10 +971,37 @@ def test_deploy_model_runner_selection_propagates_to_every_stage(tmp_path: Path,
assert all(stage.model_config.use_v2_model_runner is expect_v2 for stage in structured.stage_configs)


@pytest.mark.parametrize("platform", ["npu", "xpu"])
def test_mrv2_fails_fast_on_platforms_without_native_workers(platform: str):
def test_mrv2_fails_fast_on_xpu():
with pytest.raises(NotImplementedError, match="Model Runner V2"):
_apply_platform_overrides(DeployConfig(model_runner="v2"), platform=platform)
_apply_platform_overrides(DeployConfig(model_runner="v2"), platform="xpu")


@pytest.mark.parametrize("stage_override", [False, True])
def test_mrv2_config_is_allowed_on_npu(stage_override):
deploy = (
DeployConfig(stages=[StageDeployConfig(stage_id=0, model_runner="v2")])
if stage_override
else DeployConfig(model_runner="v2")
)
deploy = _apply_platform_overrides(deploy, platform="npu")
if stage_override:
assert deploy.stages[0].model_runner == "v2"
else:
assert deploy.model_runner == "v2"


def test_fish_omni_npu_profile_is_mrv2_tp_ep():
deploy = _apply_platform_overrides(load_deploy_config(_DEPLOY_DIR / "fish_omni.yaml"), platform="npu")
stage0, stage1 = deploy.stages
assert stage0.model_runner == "v2"
assert stage0.tensor_parallel_size == 2
assert stage0.enable_expert_parallel is True
assert stage0.enforce_eager is False
assert stage0.gpu_memory_utilization == 0.72
assert stage0.devices == "0,1"
assert stage1.model_runner == "v1"
assert stage1.gpu_memory_utilization == 0.1
assert stage1.devices == "1"


def _qwen3_omni_pipeline() -> PipelineConfig:
Expand Down
19 changes: 19 additions & 0 deletions tests/engine/test_stage_engine_core_proc.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,3 +144,22 @@ def test_handshake_wait_is_extended_but_never_shortened(monkeypatch, timeout_s,
monkeypatch.setattr(engine_core_module, "HANDSHAKE_TIMEOUT_MINS", 5)
_extend_handshake_timeout(timeout_s)
assert engine_core_module.HANDSHAKE_TIMEOUT_MINS == expected_minutes


def test_platform_compat_runs_before_engine_construction(monkeypatch):
from vllm_omni.engine import stage_engine_core_proc as module

calls = []

class ConstructionStoppedError(Exception):
pass

def construct(self, *args, **kwargs):
calls.append("engine")
raise ConstructionStoppedError

monkeypatch.setattr(module.current_omni_platform, "prepare_stage_engine", lambda: calls.append("platform"))
monkeypatch.setattr(EngineCoreProc, "__init__", construct)
with pytest.raises(ConstructionStoppedError):
StageEngineCoreProc()
assert calls == ["platform", "engine"]
45 changes: 45 additions & 0 deletions tests/model_executor/models/fish_omni/test_fish_omni_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,3 +146,48 @@ def test_rejects_unsupported_text_values(key, value):
def test_rejects_dense_backbone_layer():
with pytest.raises(ValueError, match="every backbone layer must be MoE"):
_config(mlp_layer_types=["moe"] * 39 + ["dense"])


def test_npu_fused_qk_rope_is_rejected_after_construction():
import vllm_omni.platforms.npu.models.fish_omni as fish_model

class _Eager:
use_fused_qk_norm_rope_gate = False

class _Fused:
use_fused_qk_norm_rope_gate = True

class _Root:
def __init__(self, children: list[object]) -> None:
self._children = children

def modules(self) -> list[object]:
return self._children

fish_model._require_npu_eager_qk_rope(_Root([_Eager()]))
with pytest.raises(RuntimeError, match="fused QK-norm RoPE"):
fish_model._require_npu_eager_qk_rope(_Root([_Eager(), _Fused()]))
for children in ([], [object()]):
with pytest.raises(RuntimeError, match="no attention modules expose use_fused_qk_norm_rope_gate"):
fish_model._require_npu_eager_qk_rope(_Root(children))


def test_tensor_parallel_is_allowed_on_npu_only(monkeypatch):
from types import SimpleNamespace

import vllm_omni.model_executor.models.fish_omni.fish_omni_model as fish_model

parallel = SimpleNamespace(pipeline_parallel_size=1, prefill_context_parallel_size=1, tensor_parallel_size=2)
monkeypatch.setattr(fish_model, "current_platform", SimpleNamespace(device_type="npu"))
fish_model._reject_unsupported_fish_parallel(parallel)
monkeypatch.setattr(fish_model, "current_platform", SimpleNamespace(device_type="cuda"))
with pytest.raises(NotImplementedError, match="tensor parallel"):
fish_model._reject_unsupported_fish_parallel(parallel)
with pytest.raises(NotImplementedError, match="one pipeline rank"):
fish_model._reject_unsupported_fish_parallel(
SimpleNamespace(pipeline_parallel_size=2, prefill_context_parallel_size=1)
)
with pytest.raises(NotImplementedError, match="prefill context"):
fish_model._reject_unsupported_fish_parallel(
SimpleNamespace(pipeline_parallel_size=1, prefill_context_parallel_size=2)
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,170 @@
# SPDX-License-Identifier: Apache-2.0
# SPDX-FileCopyrightText: Copyright contributors to the vLLM-Omni project
"""CPU references for the Drama 3 tower and sampling kernels used on NPU."""

import pytest
import torch

from vllm_omni.model_executor.models.fish_omni.kernels import (
draw_top_k_top_p,
gemma_rms_norm,
gemma_rms_norm_table,
sigmoid_gate,
tower_mix_norm,
)

pytestmark = [pytest.mark.core_model, pytest.mark.cpu]

EPS = 1e-6


def _gemma(values: torch.Tensor, weight: torch.Tensor) -> torch.Tensor:
"""vLLM's zero-centered Gemma RMSNorm, the reference these kernels follow."""
return values * torch.rsqrt(values.pow(2).mean(-1, keepdim=True) + EPS) * (weight + 1)


def test_gemma_rms_norm_matches_zero_centered_reference():
x = torch.tensor([[1.0, 3.0, 0.0, 2.0], [0.5, -0.5, 0.25, 0.0]])
weight = torch.tensor([0.0, 1.0, -0.5, 0.25])
residual = torch.tensor([[0.5, 0.0, 1.0, -1.0], [0.0, 0.25, 0.0, 0.5]])
out, summed = gemma_rms_norm(x, weight, EPS, residual)
total = x + residual
expected = _gemma(total, weight)
torch.testing.assert_close(summed, total)
torch.testing.assert_close(out, expected)


def test_gemma_rms_norm_without_residual_returns_only_the_norm():
x = torch.tensor([[1.0, 3.0, 0.0, 2.0]])
weight = torch.tensor([0.0, 1.0, -0.5, 0.25])
torch.testing.assert_close(gemma_rms_norm(x, weight, EPS), _gemma(x, weight))


@pytest.mark.parametrize("with_extra", [False, True])
def test_tower_mix_norm_concatenates_code_and_hidden(with_extra):
hidden = torch.tensor([[1.0, 0.0], [0.0, 2.0]])
code = torch.tensor([1, 0])
mask = torch.tensor([1.0, 0.0])
table = torch.tensor([[3.0, 1.0], [0.0, 4.0]])
extra = torch.tensor([[0.5, -1.5], [2.0, 0.25]]) if with_extra else None
enorm = torch.tensor([0.5, -0.25])
hnorm = torch.tensor([0.0, 1.0])

out = tower_mix_norm(hidden, code, mask, table, extra, enorm, hnorm, EPS)

embedded = table[code] * mask.unsqueeze(-1)
if extra is not None:
embedded = embedded + extra
torch.testing.assert_close(out, torch.cat([_gemma(embedded, enorm), _gemma(hidden, hnorm)], dim=-1))


def test_gemma_rms_norm_table_adds_the_code_embedding_to_the_residual():
x = torch.tensor([[1.0, 3.0, 0.0, 2.0], [0.5, -0.5, 0.25, 0.0]])
code = torch.tensor([1, 0])
mask = torch.tensor([1.0, 0.0])
table = torch.tensor([[3.0, 1.0, 0.0, 2.0], [0.0, 4.0, -1.0, 0.5]])
weight = torch.tensor([0.0, 1.0, -0.5, 0.25])

out, summed = gemma_rms_norm_table(x, code, mask, table, weight, EPS)

total = x + table[code] * mask.unsqueeze(-1)
torch.testing.assert_close(summed, total)
torch.testing.assert_close(out, _gemma(total, weight))


def test_sigmoid_gate_matches_fp32_product():
x = torch.tensor([0.0, 1.0, -2.0])
gate = torch.tensor([0.0, 2.0, -1.0])
torch.testing.assert_close(sigmoid_gate(x, gate), x * torch.sigmoid(gate))


def test_draw_keeps_rank_zero_when_temperature_collapses():
logits = torch.tensor([[0.0, 5.0, 1.0, -3.0], [2.0, 2.0, 9.0, 0.0]])
rows = logits.shape[0]
drawn = draw_top_k_top_p(
logits,
temperature=torch.zeros(rows),
top_k=torch.ones(rows, dtype=torch.int64),
top_p=torch.ones(rows),
uniform=torch.rand(rows, 2),
max_top_k=2,
)
assert drawn.tolist() == [1, 2]


def test_draw_maps_column_indices_through_id_map():
logits = torch.tensor([[0.0, 5.0, 1.0, -3.0], [2.0, 2.0, 9.0, 0.0]])
rows = logits.shape[0]
id_map = torch.tensor([70, 71, 72, 73], dtype=torch.int64)
drawn = draw_top_k_top_p(
logits,
temperature=torch.zeros(rows),
top_k=torch.ones(rows, dtype=torch.int64),
top_p=torch.ones(rows),
uniform=torch.rand(rows, 2),
max_top_k=2,
id_map=id_map,
)
assert drawn.tolist() == [71, 72]


def test_draw_reuses_a_shared_topk_result():
logits = torch.tensor([[0.0, 5.0, 1.0, -3.0], [2.0, 2.0, 9.0, 0.0]])
rows = logits.shape[0]
shared = torch.topk(logits, 2, dim=-1)
drawn = draw_top_k_top_p(
logits,
temperature=torch.zeros(rows),
top_k=torch.ones(rows, dtype=torch.int64),
top_p=torch.ones(rows),
uniform=torch.rand(rows, 2),
max_top_k=2,
top=shared,
)
assert drawn.tolist() == [1, 2]


def test_eager_qk_rope_splits_gate_and_rotates_the_first_half():
from vllm_omni.model_executor.models.fish_omni.kernels import eager_qk_rmsnorm_rope_gate

head_dim, rotary_dim, heads = 4, 4, 1
q_gate = torch.tensor([[1.0, 0.0, 0.0, 0.0, 3.0, 4.0, 5.0, 6.0]])
k = torch.tensor([[0.0, 1.0, 0.0, 0.0]])
weight = torch.zeros(head_dim)
cos_sin = torch.tensor([[1.0, 0.0, 0.0, 1.0]])
positions = torch.zeros(1, dtype=torch.long)
q, k_out, gate = eager_qk_rmsnorm_rope_gate(
q_gate,
k,
weight,
weight,
cos_sin,
positions,
EPS,
heads,
heads,
head_dim,
rotary_dim,
norm_beta=1.0,
)
torch.testing.assert_close(gate, torch.tensor([[3.0, 4.0, 5.0, 6.0]]))
assert q.shape == (1, head_dim)
assert k_out.shape == (1, head_dim)
# Identity rotation (cos=1, sin=0) leaves the normalized q direction.
assert q[0, 0] > 0 and torch.count_nonzero(q) >= 1


def test_draw_restricts_to_top_p_mass():
# Column 0 holds almost all the mass, so top_p 0.5 keeps rank 0 only and
# every draw returns it whatever the noise says.
logits = torch.tensor([[20.0, 1.0, 0.0, -1.0]])
for _ in range(8):
drawn = draw_top_k_top_p(
logits,
temperature=torch.ones(1),
top_k=torch.full((1,), 4, dtype=torch.int64),
top_p=torch.full((1,), 0.5),
uniform=torch.rand(1, 4),
max_top_k=4,
)
assert drawn.tolist() == [0]
Loading
Loading