Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
00d6984660 |
No files matched your search
@@ -14,8 +14,6 @@ set -euo pipefail
|
||||
# shellcheck disable=SC1091
|
||||
source .buildkite/common/scripts/resolve_skip_ci.sh
|
||||
|
||||
AMD_SUITE_SELECTOR=".buildkite/amd/scripts/select_test_suites.py"
|
||||
|
||||
if [[ -z "${RUN_ALL:-}" ]]; then
|
||||
RUN_ALL=0
|
||||
fi
|
||||
@@ -32,20 +30,31 @@ if [[ -z "${AMD_MIRROR_HW:-}" ]]; then
|
||||
AMD_MIRROR_HW="amdproduction"
|
||||
fi
|
||||
|
||||
PR_LABELS=""
|
||||
# Explicit debug suites do not depend on PR labels.
|
||||
if [[ "${BUILDKITE_PULL_REQUEST:-false}" != "false" && -z "${DEBUG_TEST_YAML:-}" ]]; then
|
||||
if ! PR_LABELS=$(curl -fsSL \
|
||||
"https://api.github.com/repos/vllm-project/vllm-omni/pulls/$BUILDKITE_PULL_REQUEST" \
|
||||
| jq -r '.labels[].name'); then
|
||||
echo "ERROR: Could not read PR labels; refusing to select an incorrect AMD test tier." >&2
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
fail_fast() {
|
||||
if [[ "${BUILDKITE_PULL_REQUEST:-false}" != "false" ]]; then
|
||||
echo true
|
||||
DISABLE_LABEL="ci-no-fail-fast"
|
||||
# If BUILDKITE_PULL_REQUEST != "false", then we check the PR labels using curl and jq
|
||||
if [ "$BUILDKITE_PULL_REQUEST" != "false" ]; then
|
||||
PR_LABELS=$(curl -s "https://api.github.com/repos/vllm-project/vllm-omni/pulls/$BUILDKITE_PULL_REQUEST" | jq -r '.labels[].name')
|
||||
if [[ $PR_LABELS == *"$DISABLE_LABEL"* ]]; then
|
||||
echo false
|
||||
else
|
||||
echo true
|
||||
fi
|
||||
else
|
||||
echo false # not a PR or BUILDKITE_PULL_REQUEST not set
|
||||
fi
|
||||
}
|
||||
|
||||
check_run_all_label() {
|
||||
RUN_ALL_LABEL="ready-run-all-tests"
|
||||
# If BUILDKITE_PULL_REQUEST != "false", then we check the PR labels using curl and jq
|
||||
if [ "$BUILDKITE_PULL_REQUEST" != "false" ]; then
|
||||
PR_LABELS=$(curl -s "https://api.github.com/repos/vllm-project/vllm-omni/pulls/$BUILDKITE_PULL_REQUEST" | jq -r '.labels[].name')
|
||||
if [[ $PR_LABELS == *"$RUN_ALL_LABEL"* ]]; then
|
||||
echo true
|
||||
else
|
||||
echo false
|
||||
fi
|
||||
else
|
||||
echo false # not a PR or BUILDKITE_PULL_REQUEST not set
|
||||
fi
|
||||
@@ -55,57 +64,6 @@ if [[ -z "${COV_ENABLED:-}" ]]; then
|
||||
COV_ENABLED=0
|
||||
fi
|
||||
|
||||
resolve_test_specs() {
|
||||
local selected_specs
|
||||
if ! selected_specs=$(python3 "$AMD_SUITE_SELECTOR" \
|
||||
--branch "$BUILDKITE_BRANCH" \
|
||||
--labels "$PR_LABELS" \
|
||||
--debug-test-yaml "${DEBUG_TEST_YAML:-}"); then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
TEST_SPECS=()
|
||||
while IFS= read -r suite_spec; do
|
||||
[[ -z "$suite_spec" ]] && continue
|
||||
TEST_SPECS+=("$suite_spec")
|
||||
done <<< "$selected_specs"
|
||||
}
|
||||
|
||||
filter_test_specs_by_skip_ci() {
|
||||
local suite_spec level decision
|
||||
local skip_all=0
|
||||
local -a runnable_specs=()
|
||||
|
||||
for suite_spec in "${TEST_SPECS[@]}"; do
|
||||
case "$suite_spec" in
|
||||
READY_TESTS:*) level="l2" ;;
|
||||
MERGE_TESTS:*) level="l3" ;;
|
||||
*)
|
||||
echo "ERROR: unknown AMD test suite spec '$suite_spec'" >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
if decision=$(python3 "$SKIP_CI_PY" gate amd "$level"); then
|
||||
echo "Skipping AMD $level suite due to $decision decision."
|
||||
[[ "$decision" == "skip-all" ]] && skip_all=1
|
||||
else
|
||||
runnable_specs+=("$suite_spec")
|
||||
fi
|
||||
done
|
||||
|
||||
TEST_SPECS=("${runnable_specs[@]}")
|
||||
if [[ ${#TEST_SPECS[@]} -eq 0 ]]; then
|
||||
if [[ $skip_all -eq 1 ]]; then
|
||||
buildkite-agent annotate \
|
||||
":memo: CI skipped — docs or pytest skip-mark changes only" \
|
||||
--style "info" 2>/dev/null || true
|
||||
fi
|
||||
echo "No AMD L2/L3 suites remain after skip-ci filtering."
|
||||
exit 0
|
||||
fi
|
||||
}
|
||||
|
||||
upload_pipeline() {
|
||||
echo "Uploading pipeline..."
|
||||
# Install minijinja
|
||||
@@ -126,7 +84,7 @@ upload_pipeline() {
|
||||
# (WIP) Use pipeline generator instead of jinja template
|
||||
if [ -e ".buildkite/amd/pipeline_generator/pipeline_generator.py" ]; then
|
||||
python -m pip install click pydantic
|
||||
python .buildkite/amd/pipeline_generator/pipeline_generator.py --run_all="$RUN_ALL" --list_file_diff="$LIST_FILE_DIFF" --nightly="$NIGHTLY" --mirror_hw="$AMD_MIRROR_HW"
|
||||
python .buildkite/amd/pipeline_generator/pipeline_generator.py --run_all=$RUN_ALL --list_file_diff="$LIST_FILE_DIFF" --nightly="$NIGHTLY" --mirror_hw="$AMD_MIRROR_HW"
|
||||
buildkite-agent pipeline upload .buildkite/amd/pipeline.yaml
|
||||
exit 0
|
||||
fi
|
||||
@@ -139,12 +97,49 @@ upload_pipeline() {
|
||||
|
||||
cd .buildkite/amd
|
||||
|
||||
# Multiple label-selected or debug-selected suites share one image build.
|
||||
if [[ ${#TEST_SPECS[@]} -eq 1 ]]; then
|
||||
TEST_YAML="${TEST_SPECS[0]#*:}"
|
||||
else
|
||||
TEST_YAML=$(mktemp "${TMPDIR:-/tmp}/amd-selected-tests.XXXXXX.yml")
|
||||
python - "$TEST_YAML" "${TEST_SPECS[@]}" <<'PY'
|
||||
# Select test definition file: merge suite for main, ready suite for PRs.
|
||||
# For debugging, DEBUG_TEST_YAML accepts a comma-separated list containing
|
||||
# "merge" and/or "ready" (case-insensitive). Multiple suites are combined
|
||||
# before rendering so they share one amd-build step.
|
||||
if [[ -n "${DEBUG_TEST_YAML:-}" ]]; then
|
||||
declare -a DEBUG_TEST_SPECS=()
|
||||
declare -A SEEN_DEBUG_TESTS=()
|
||||
IFS=',' read -ra REQUESTED_DEBUG_TESTS <<< "${DEBUG_TEST_YAML,,}"
|
||||
|
||||
for requested_test in "${REQUESTED_DEBUG_TESTS[@]}"; do
|
||||
# Permit readable values such as "ready, merge," and ignore the
|
||||
# empty item produced by a trailing comma.
|
||||
requested_test="${requested_test//[[:space:]]/}"
|
||||
[[ -z "$requested_test" ]] && continue
|
||||
|
||||
if [[ -n "${SEEN_DEBUG_TESTS[$requested_test]:-}" ]]; then
|
||||
echo "ERROR: duplicate DEBUG_TEST_YAML suite '$requested_test'" >&2
|
||||
exit 1
|
||||
fi
|
||||
SEEN_DEBUG_TESTS[$requested_test]=1
|
||||
|
||||
case "$requested_test" in
|
||||
ready)
|
||||
DEBUG_TEST_SPECS+=("READY_TESTS:test-amd-ready.yml")
|
||||
;;
|
||||
merge)
|
||||
DEBUG_TEST_SPECS+=("MERGE_TESTS:test-amd-merge.yml")
|
||||
;;
|
||||
*)
|
||||
echo "ERROR: DEBUG_TEST_YAML entries must be 'merge' or 'ready', got '$requested_test'" >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
if [[ ${#DEBUG_TEST_SPECS[@]} -eq 0 ]]; then
|
||||
echo "ERROR: DEBUG_TEST_YAML did not contain a test suite" >&2
|
||||
exit 1
|
||||
elif [[ ${#DEBUG_TEST_SPECS[@]} -eq 1 ]]; then
|
||||
TEST_YAML="${DEBUG_TEST_SPECS[0]#*:}"
|
||||
else
|
||||
TEST_YAML=$(mktemp "${TMPDIR:-/tmp}/amd-debug-tests.XXXXXX.yml")
|
||||
python - "$TEST_YAML" "${DEBUG_TEST_SPECS[@]}" <<'PY'
|
||||
import sys
|
||||
|
||||
import yaml
|
||||
@@ -177,8 +172,13 @@ for suite_spec in suite_specs:
|
||||
with open(output_path, "w", encoding="utf-8") as output_file:
|
||||
yaml.safe_dump(combined, output_file, sort_keys=False)
|
||||
PY
|
||||
fi
|
||||
echo "DEBUG_TEST_YAML override: using ${DEBUG_TEST_SPECS[*]}"
|
||||
elif [[ $BUILDKITE_BRANCH == "main" ]]; then
|
||||
TEST_YAML="test-amd-merge.yml"
|
||||
else
|
||||
TEST_YAML="test-amd-ready.yml"
|
||||
fi
|
||||
echo "AMD test suites: ${TEST_SPECS[*]}"
|
||||
|
||||
(
|
||||
set -x
|
||||
@@ -198,7 +198,7 @@ PY
|
||||
> pipeline.yaml
|
||||
)
|
||||
cat pipeline.yaml
|
||||
if [[ "$TEST_YAML" == "${TMPDIR:-/tmp}/amd-selected-tests."*.yml ]]; then
|
||||
if [[ "$TEST_YAML" == "${TMPDIR:-/tmp}/amd-debug-tests."*.yml ]]; then
|
||||
rm -f -- "$TEST_YAML"
|
||||
fi
|
||||
buildkite-agent artifact upload pipeline.yaml
|
||||
@@ -219,10 +219,12 @@ if [[ $BUILDKITE_BRANCH == "main" ]]; then
|
||||
file_diff=$(get_diff_main)
|
||||
fi
|
||||
|
||||
# Resolve PR tier labels before skip-ci so ready and merge suites can be
|
||||
# filtered independently for CI-YAML-only changes.
|
||||
resolve_test_specs
|
||||
filter_test_specs_by_skip_ci
|
||||
# Early exit: unified skip-ci (docs / skip marks) and CI-yaml-only level targeting.
|
||||
if [[ $BUILDKITE_BRANCH == "main" ]]; then
|
||||
gate_bootstrap_ci amd l3
|
||||
else
|
||||
gate_bootstrap_ci amd l2
|
||||
fi
|
||||
|
||||
patterns=(
|
||||
"docker/Dockerfile"
|
||||
@@ -272,6 +274,14 @@ for file in $file_diff; do
|
||||
fi
|
||||
done
|
||||
|
||||
# Check for ready-run-all-tests label
|
||||
LABEL_RUN_ALL=$(check_run_all_label)
|
||||
if [[ $LABEL_RUN_ALL == true ]]; then
|
||||
RUN_ALL=1
|
||||
NIGHTLY=1
|
||||
echo "Found 'ready-run-all-tests' label. Running all tests including optional tests."
|
||||
fi
|
||||
|
||||
# Decide whether to use precompiled wheels
|
||||
# Relies on existing patterns array as a basis.
|
||||
if [[ -n "${VLLM_USE_PRECOMPILED:-}" ]]; then
|
||||
|
||||
@@ -1,93 +0,0 @@
|
||||
#!/usr/bin/env python3
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
# SPDX-FileCopyrightText: Copyright contributors to the vLLM-Omni project
|
||||
"""Select AMD L2/L3 suites after Buildkite has created an AMD build.
|
||||
|
||||
This repository-side selector does not decide which GitHub label events start
|
||||
the external ``vllm-omni-amd-ci`` pipeline. Its Buildkite PR build condition
|
||||
must admit the relevant label event before this code can inspect the labels.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import argparse
|
||||
import sys
|
||||
from collections.abc import Iterable
|
||||
|
||||
SUITE_SPECS = {
|
||||
"ready": "READY_TESTS:test-amd-ready.yml",
|
||||
"merge": "MERGE_TESTS:test-amd-merge.yml",
|
||||
}
|
||||
|
||||
|
||||
def _parse_debug_suites(value: str) -> tuple[str, ...]:
|
||||
suites = tuple(item.strip().lower() for item in value.split(",") if item.strip())
|
||||
if not suites:
|
||||
raise ValueError("DEBUG_TEST_YAML did not contain a test suite")
|
||||
|
||||
seen: set[str] = set()
|
||||
for suite in suites:
|
||||
if suite not in SUITE_SPECS:
|
||||
raise ValueError(f"DEBUG_TEST_YAML entries must be 'merge' or 'ready', got {suite!r}")
|
||||
if suite in seen:
|
||||
raise ValueError(f"duplicate DEBUG_TEST_YAML suite {suite!r}")
|
||||
seen.add(suite)
|
||||
return suites
|
||||
|
||||
|
||||
def select_amd_test_suites(
|
||||
*,
|
||||
branch: str,
|
||||
labels: Iterable[str],
|
||||
debug_test_yaml: str = "",
|
||||
) -> tuple[str, ...]:
|
||||
"""Return ordered suite names while preserving legacy unlabeled PRs."""
|
||||
|
||||
if debug_test_yaml:
|
||||
return _parse_debug_suites(debug_test_yaml)
|
||||
if branch == "main":
|
||||
return ("merge",)
|
||||
|
||||
label_set = {label.strip() for label in labels if label.strip()}
|
||||
selected = tuple(suite for label, suite in (("ready", "ready"), ("merge-test", "merge")) if label in label_set)
|
||||
# AMD historically uploaded L2 for every PR build. Keep that behavior for
|
||||
# triggers such as amd-test while adding tier selection for ready/merge-test.
|
||||
return selected or ("ready",)
|
||||
|
||||
|
||||
def main() -> int:
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument("--branch", required=True)
|
||||
parser.add_argument("--labels", default="")
|
||||
parser.add_argument("--debug-test-yaml", default="")
|
||||
args = parser.parse_args()
|
||||
|
||||
labels = tuple(args.labels.splitlines())
|
||||
try:
|
||||
suites = select_amd_test_suites(
|
||||
branch=args.branch,
|
||||
labels=labels,
|
||||
debug_test_yaml=args.debug_test_yaml,
|
||||
)
|
||||
except ValueError as exc:
|
||||
parser.error(str(exc))
|
||||
|
||||
label_set = {label.strip() for label in labels if label.strip()}
|
||||
if not args.debug_test_yaml and args.branch != "main" and not ({"ready", "merge-test"} & label_set):
|
||||
print(
|
||||
"No AMD L2/L3 tier label found; preserving the legacy ready-suite fallback.",
|
||||
file=sys.stderr,
|
||||
)
|
||||
if "nightly-test" in label_set:
|
||||
print(
|
||||
"AMD nightly-test has no suite yet and does not affect L2/L3 selection.",
|
||||
file=sys.stderr,
|
||||
)
|
||||
|
||||
for suite in suites:
|
||||
print(SUITE_SPECS[suite])
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
raise SystemExit(main())
|
||||
@@ -107,11 +107,6 @@ steps:
|
||||
- export VLLM_LOGGING_LEVEL=DEBUG
|
||||
- export VLLM_WORKER_MULTIPROC_METHOD=spawn
|
||||
- timeout 20m pytest -s -v tests/diffusion/distributed/test_sequence_parallel.py -m core_model
|
||||
- >-
|
||||
timeout 20m pytest -s -v
|
||||
tests/diffusion/models/ltx2/test_ltx2_transformer_ulysses.py
|
||||
-m 'core_model and rocm and cards_2'
|
||||
--run-level "core_model"
|
||||
|
||||
- label: "Diffusion GPU Worker Test"
|
||||
agent_pool: mi300_2
|
||||
@@ -127,13 +122,7 @@ steps:
|
||||
mirror_hardwares: [amdproduction]
|
||||
grade: Blocking
|
||||
commands:
|
||||
# Preserve legacy one-GPU tests without cards_1 while excluding every
|
||||
# registered multi-GPU marker from this one-GPU job.
|
||||
- >-
|
||||
timeout 15m pytest -sv tests/diffusion/models/
|
||||
-m 'core_model and cuda and not
|
||||
(cards_2 or cards_3 or cards_4 or cards_5 or cards_6 or cards_7 or cards_8)'
|
||||
--run-level "core_model"
|
||||
- timeout 15m pytest -sv tests/diffusion/models/ -m 'core_model and cuda' --run-level "core_model"
|
||||
|
||||
- label: "Diffusion · Wan22 Test"
|
||||
agent_pool: mi300_1
|
||||
|
||||
@@ -26,9 +26,6 @@
|
||||
# packed onto g6.12xlarge L4 nodes (``vllm.ci/gpu-pool=l4x4``). GPU / CPU /
|
||||
# memory / shm requests scale with card count (1 GPU = 10 CPU / 40Gi / 24Gi shm).
|
||||
# Retry covers lost agents / killed pods, not pytest or OOM (exit 1 / 137).
|
||||
# The Kubernetes HF secret deliberately uses VLLM_CI_HF_TOKEN. Scheduled
|
||||
# build-level HF_TOKEN values can override pod env entries with the same name;
|
||||
# upload_pipeline.py restores the secret-backed value inside the job shell.
|
||||
|
||||
x-npu-k8s-plugins: &npu_k8s_plugins
|
||||
- kubernetes:
|
||||
@@ -87,7 +84,7 @@ mirror_hardwares:
|
||||
env:
|
||||
- name: HF_HOME
|
||||
value: /fsx/hf_cache
|
||||
- name: VLLM_CI_HF_TOKEN
|
||||
- name: HF_TOKEN
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: hf-token-secret
|
||||
@@ -138,7 +135,7 @@ mirror_hardwares:
|
||||
env:
|
||||
- name: HF_HOME
|
||||
value: /fsx/hf_cache
|
||||
- name: VLLM_CI_HF_TOKEN
|
||||
- name: HF_TOKEN
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: hf-token-secret
|
||||
@@ -189,7 +186,7 @@ mirror_hardwares:
|
||||
env:
|
||||
- name: HF_HOME
|
||||
value: /fsx/hf_cache
|
||||
- name: VLLM_CI_HF_TOKEN
|
||||
- name: HF_TOKEN
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: hf-token-secret
|
||||
@@ -240,7 +237,7 @@ mirror_hardwares:
|
||||
env:
|
||||
- name: HF_HOME
|
||||
value: /fsx/hf_cache
|
||||
- name: VLLM_CI_HF_TOKEN
|
||||
- name: HF_TOKEN
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: hf-token-secret
|
||||
@@ -274,7 +271,7 @@ mirror_hardwares:
|
||||
env:
|
||||
- name: HF_HOME
|
||||
value: /root/.cache/huggingface
|
||||
- name: VLLM_CI_HF_TOKEN
|
||||
- name: HF_TOKEN
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: hf-token-secret
|
||||
@@ -309,7 +306,7 @@ mirror_hardwares:
|
||||
env:
|
||||
- name: HF_HOME
|
||||
value: /root/.cache/huggingface
|
||||
- name: VLLM_CI_HF_TOKEN
|
||||
- name: HF_TOKEN
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: hf-token-secret
|
||||
@@ -344,7 +341,7 @@ mirror_hardwares:
|
||||
env:
|
||||
- name: HF_HOME
|
||||
value: /root/.cache/huggingface
|
||||
- name: VLLM_CI_HF_TOKEN
|
||||
- name: HF_TOKEN
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: hf-token-secret
|
||||
@@ -379,7 +376,7 @@ mirror_hardwares:
|
||||
env:
|
||||
- name: HF_HOME
|
||||
value: /root/.cache/huggingface
|
||||
- name: VLLM_CI_HF_TOKEN
|
||||
- name: HF_TOKEN
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: hf-token-secret
|
||||
@@ -429,7 +426,7 @@ mirror_hardwares:
|
||||
value: "0"
|
||||
- name: HF_HOME
|
||||
value: /raid/hf_cache
|
||||
- name: VLLM_CI_HF_TOKEN
|
||||
- name: HF_TOKEN
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: hf-token-secret
|
||||
@@ -480,7 +477,7 @@ mirror_hardwares:
|
||||
value: "0"
|
||||
- name: HF_HOME
|
||||
value: /raid/hf_cache
|
||||
- name: VLLM_CI_HF_TOKEN
|
||||
- name: HF_TOKEN
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: hf-token-secret
|
||||
@@ -531,7 +528,7 @@ mirror_hardwares:
|
||||
value: "0"
|
||||
- name: HF_HOME
|
||||
value: /raid/hf_cache
|
||||
- name: VLLM_CI_HF_TOKEN
|
||||
- name: HF_TOKEN
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: hf-token-secret
|
||||
@@ -582,7 +579,7 @@ mirror_hardwares:
|
||||
value: "0"
|
||||
- name: HF_HOME
|
||||
value: /raid/hf_cache
|
||||
- name: VLLM_CI_HF_TOKEN
|
||||
- name: HF_TOKEN
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: hf-token-secret
|
||||
|
||||
@@ -79,8 +79,6 @@ BOOTSTRAP_UPLOAD_IF_KEYS = {
|
||||
}
|
||||
E2E_GROUP_MARKER = "E2E Test"
|
||||
CI_MIRROR_HARDWARES_PATH = ROOT / ".buildkite/common/ci_mirror_hardwares.yml"
|
||||
CUDA_HF_TOKEN_ENV = "VLLM_CI_HF_TOKEN"
|
||||
CUDA_HF_TOKEN_EXPORT = f'if [ -n "$${{{CUDA_HF_TOKEN_ENV}:-}}" ]; then export HF_TOKEN="$${{{CUDA_HF_TOKEN_ENV}}}"; fi'
|
||||
|
||||
# Bootstrap Buildkite ``if`` expressions.
|
||||
# ``*_MAIN_IF``: main + env schedule. ``*_LABEL_IF``: PR label (and/or composed with MAIN).
|
||||
@@ -503,17 +501,6 @@ def _expand_mirror_hardwares(step: dict[str, Any]) -> dict[str, Any] | None:
|
||||
|
||||
expanded = copy.deepcopy(preset)
|
||||
merged = {key: value for key, value in step.items() if key != "mirror_hardwares"} | expanded
|
||||
# A scheduled build's HF_TOKEN may override a pod env entry with the same
|
||||
# name. The preset injects the Kubernetes secret under a collision-proof
|
||||
# alias; restore the conventional name after Buildkite has merged env.
|
||||
if any(preset_name == chip or preset_name.startswith(f"{chip}_") for chip in _cuda_mirror_chips()):
|
||||
commands = merged.get("commands")
|
||||
if isinstance(commands, list):
|
||||
merged["commands"] = [CUDA_HF_TOKEN_EXPORT, *commands]
|
||||
elif commands is None:
|
||||
merged["commands"] = [CUDA_HF_TOKEN_EXPORT]
|
||||
else:
|
||||
merged["commands"] = [CUDA_HF_TOKEN_EXPORT, commands]
|
||||
# Preset retry (K8S_RETRY on l4_*) must not clobber a step that opted out.
|
||||
if "retry" in step:
|
||||
merged["retry"] = step["retry"]
|
||||
|
||||
@@ -79,8 +79,6 @@ steps:
|
||||
steps:
|
||||
- label: "TTS · Qwen3-TTS CustomVoice Test"
|
||||
source_file_dependencies:
|
||||
- tests/e2e/features/prefill_phase/
|
||||
- vllm_omni/worker/gpu_model_runner.py
|
||||
- tests/helpers/media.py
|
||||
- tests/e2e/online_serving/test_qwen3_tts_customvoice.py
|
||||
- tests/e2e/offline_inference/test_qwen3_tts_customvoice.py
|
||||
@@ -98,7 +96,7 @@ steps:
|
||||
timeout 40m bash -c "
|
||||
export VLLM_LOGGING_LEVEL=DEBUG
|
||||
export VLLM_ALLOW_LONG_MAX_MODEL_LEN=1
|
||||
pytest -s -v tests/e2e/online_serving/test_qwen3_tts_customvoice.py tests/e2e/offline_inference/test_qwen3_tts_customvoice.py tests/e2e/features/prefill_phase/test_chunked_prefill_tail.py -m 'advanced_model and cuda' --run-level 'advanced_model'
|
||||
pytest -s -v tests/e2e/online_serving/test_qwen3_tts_customvoice.py tests/e2e/offline_inference/test_qwen3_tts_customvoice.py -m 'advanced_model and cuda' --run-level 'advanced_model'
|
||||
"
|
||||
mirror_hardwares: l4_1
|
||||
|
||||
|
||||
@@ -76,7 +76,7 @@ steps:
|
||||
|
||||
- label: "Diffusion · Other Test"
|
||||
commands:
|
||||
- timeout 15m pytest -sv tests/diffusion/*.py tests/diffusion/ar_diffusion -m 'core_model and cuda' --run-level "core_model"
|
||||
- timeout 15m pytest -sv tests/diffusion/*.py -m 'core_model and cuda' --run-level "core_model"
|
||||
mirror_hardwares: l4_1
|
||||
|
||||
- group: ":card_index_dividers: Tiny Model Tests [Single GPU]"
|
||||
|
||||
@@ -19,8 +19,6 @@ steps:
|
||||
pytest -s -v
|
||||
tests/diffusion/layers/test_activation.py
|
||||
tests/diffusion/layers/test_fused_qk_norm_rope_npu.py
|
||||
tests/diffusion/models/minimax_h3/test_minimax_h3_qwen3vl_swiglu.py
|
||||
tests/diffusion/models/minimax_h3/test_minimax_h3_modulation.py
|
||||
-m 'core_model and npu and A3'
|
||||
--run-level 'core_model'
|
||||
|
||||
|
||||
@@ -2,8 +2,6 @@
|
||||
|
||||
You may find information about contributing to vLLM-Omni on [Contributing](https://vllm-omni.readthedocs.io/en/latest/contributing/).
|
||||
|
||||
AI-assisted contributions must follow the [AI Usage Policy](docs/contributing/README.md#ai-usage-policy), including disclosure, human review, and validation requirements.
|
||||
|
||||
Local `pre-commit` gates (SPDX, forbidden imports, `torch.cuda`, shellcheck,
|
||||
mypy, test marks, TTS adapter ratchet, markdownlint, Buildkite schema, and
|
||||
how to extend allowlists) are documented in the
|
||||
|
||||
@@ -17,18 +17,18 @@ The main entrypoint is:
|
||||
vllm serve Qwen/Qwen-Image --omni --port 8099
|
||||
```
|
||||
|
||||
1. Run a minimal benchmark:
|
||||
2. Run a minimal benchmark:
|
||||
|
||||
```bash
|
||||
python3 benchmarks/diffusion/diffusion_benchmark_serving.py \
|
||||
--base-url http://localhost:8099 \
|
||||
--model Qwen/Qwen-Image \
|
||||
--task t2i \
|
||||
--dataset vbench \
|
||||
--num-prompts 5
|
||||
--base-url http://localhost:8099 \
|
||||
--model Qwen/Qwen-Image \
|
||||
--task t2i \
|
||||
--dataset vbench \
|
||||
--num-prompts 5
|
||||
```
|
||||
|
||||
### Notes
|
||||
**Notes**
|
||||
|
||||
- By default, image tasks talk to `http://<host>:<port>/v1/chat/completions`; video tasks talk to `/v1/videos`.
|
||||
- If you run the server on another host or port, pass `--base-url` accordingly.
|
||||
@@ -52,14 +52,14 @@ Example (`t2v`):
|
||||
|
||||
```bash
|
||||
python3 benchmarks/diffusion/diffusion_benchmark_serving.py \
|
||||
--base-url http://localhost:8099 \
|
||||
--model Wan-AI/Wan2.2-T2V-A14B-Diffusers \
|
||||
--task t2v \
|
||||
--dataset vbench \
|
||||
--num-prompts 50 \
|
||||
--width 640 --height 480 \
|
||||
--num-frames 81 --fps 16 \
|
||||
--num-inference-steps 40
|
||||
--base-url http://localhost:8099 \
|
||||
--model Wan-AI/Wan2.2-T2V-A14B-Diffusers \
|
||||
--task t2v \
|
||||
--dataset vbench \
|
||||
--num-prompts 50 \
|
||||
--width 640 --height 480 \
|
||||
--num-frames 81 --fps 16 \
|
||||
--num-inference-steps 40
|
||||
```
|
||||
|
||||
Note: `vbench` can also be used for other tasks such as `t2i` / `i2v` (and `i2i`). For `t2i`, the loader reuses VBench t2v text prompts; for `i2v` / `i2i`, it loads the VBench i2v dataset (with image paths).
|
||||
@@ -140,21 +140,6 @@ Traffic / concurrency flags:
|
||||
- `--request-rate`: Target request rate (requests/second). If set to `inf`, the script sends all requests immediately.
|
||||
- `--max-concurrency`: Max number of in-flight requests (default: `1`). This can hard-cap the achieved QPS: if it is too small, requests will queue behind the semaphore, and both achieved throughput and observed SLO attainment can be skewed.
|
||||
|
||||
### Video job timeout and failures
|
||||
|
||||
`--video-job-timeout` controls how long each `/v1/videos` job may be polled,
|
||||
including time queued on the server (default: `900` seconds). For long video
|
||||
jobs at high concurrency, use a larger budget, for example
|
||||
`--video-job-timeout 1800`. This also applies to warmup jobs. The polling budget
|
||||
starts after job creation; it excludes time waiting for the client concurrency
|
||||
semaphore. Individual HTTP calls still use the aiohttp session timeout.
|
||||
|
||||
An expired job is counted as failed and deleted, which cancels queued or running
|
||||
server generation. The benchmark continues processing the remaining requests.
|
||||
The progress bar counts both successful and failed requests. The final report
|
||||
shows the failure count and the first 10 errors; `--output-file` saves all errors
|
||||
with their request IDs in `request_errors`.
|
||||
|
||||
### Batched warmup note
|
||||
|
||||
For batched serving runs, warm the same in-flight shape you plan to measure.
|
||||
|
||||
@@ -1,6 +1,3 @@
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
# SPDX-FileCopyrightText: Copyright contributors to the vLLM-Omni project
|
||||
|
||||
import asyncio
|
||||
import base64
|
||||
import json
|
||||
@@ -46,7 +43,6 @@ class RequestFuncInput:
|
||||
video_paths: list[str] | None = None
|
||||
request_id: str = field(default_factory=lambda: str(uuid.uuid4()))
|
||||
default_bot_task: str | None = DEFAULT_EDITS_BOT_TASK
|
||||
video_job_timeout: float = 900.0
|
||||
|
||||
|
||||
@dataclass
|
||||
@@ -335,64 +331,64 @@ async def async_request_v1_videos(
|
||||
output = RequestFuncOutput()
|
||||
output.start_time = time.perf_counter()
|
||||
|
||||
files = dict(input.extra_body)
|
||||
if input.prompt:
|
||||
files.setdefault("prompt", input.prompt)
|
||||
if input.width and input.height:
|
||||
files.setdefault("height", input.height)
|
||||
files.setdefault("width", input.width)
|
||||
if input.num_frames:
|
||||
files.setdefault("num_frames", input.num_frames)
|
||||
if input.num_inference_steps:
|
||||
files.setdefault("num_inference_steps", input.num_inference_steps)
|
||||
if input.seed is not None:
|
||||
files.setdefault("seed", input.seed)
|
||||
if input.fps:
|
||||
files.setdefault("fps", input.fps)
|
||||
|
||||
form = aiohttp.FormData()
|
||||
for k, v in files.items():
|
||||
form.add_field(k, str(v))
|
||||
|
||||
image_file = None
|
||||
job_id = None
|
||||
try:
|
||||
files = dict(input.extra_body)
|
||||
if input.prompt:
|
||||
files.setdefault("prompt", input.prompt)
|
||||
if input.width and input.height:
|
||||
files.setdefault("height", input.height)
|
||||
files.setdefault("width", input.width)
|
||||
if input.num_frames:
|
||||
files.setdefault("num_frames", input.num_frames)
|
||||
if input.num_inference_steps:
|
||||
files.setdefault("num_inference_steps", input.num_inference_steps)
|
||||
if input.seed is not None:
|
||||
files.setdefault("seed", input.seed)
|
||||
if input.fps:
|
||||
files.setdefault("fps", input.fps)
|
||||
if input.image_paths and input.video_paths:
|
||||
output.error = "Only one of image_paths or video_paths can be provided"
|
||||
output.success = False
|
||||
return output
|
||||
|
||||
form = aiohttp.FormData()
|
||||
for k, v in files.items():
|
||||
form.add_field(k, str(v))
|
||||
|
||||
if input.image_paths and input.video_paths:
|
||||
output.error = "Only one of image_paths or video_paths can be provided"
|
||||
output.success = False
|
||||
return output
|
||||
|
||||
if input.image_paths and len(input.image_paths) > 0:
|
||||
image_path = input.image_paths[0]
|
||||
image_file = open(image_path, "rb")
|
||||
if input.image_paths and len(input.image_paths) > 0:
|
||||
image_path = input.image_paths[0]
|
||||
image_file = open(image_path, "rb")
|
||||
form.add_field(
|
||||
"input_reference",
|
||||
image_file,
|
||||
filename=os.path.basename(image_path),
|
||||
content_type=_guess_mime_type(image_path),
|
||||
)
|
||||
elif input.video_paths and len(input.video_paths) > 0:
|
||||
video_path = input.video_paths[0]
|
||||
if _is_minimax_h3_mixed_reference(input.model):
|
||||
with open(video_path, "rb") as reference_file:
|
||||
video_b64 = base64.b64encode(reference_file.read()).decode("ascii")
|
||||
form.add_field(
|
||||
"video_reference",
|
||||
json.dumps([{"video_url": f"data:video/mp4;base64,{video_b64}"}]),
|
||||
)
|
||||
else:
|
||||
image_file = open(video_path, "rb")
|
||||
form.add_field(
|
||||
"input_reference",
|
||||
image_file,
|
||||
filename=os.path.basename(image_path),
|
||||
content_type=_guess_mime_type(image_path),
|
||||
filename=os.path.basename(video_path),
|
||||
content_type=_guess_mime_type(video_path),
|
||||
)
|
||||
elif input.video_paths and len(input.video_paths) > 0:
|
||||
video_path = input.video_paths[0]
|
||||
if _is_minimax_h3_mixed_reference(input.model):
|
||||
with open(video_path, "rb") as reference_file:
|
||||
video_b64 = base64.b64encode(reference_file.read()).decode("ascii")
|
||||
form.add_field(
|
||||
"video_reference",
|
||||
json.dumps([{"video_url": f"data:video/mp4;base64,{video_b64}"}]),
|
||||
)
|
||||
else:
|
||||
image_file = open(video_path, "rb")
|
||||
form.add_field(
|
||||
"input_reference",
|
||||
image_file,
|
||||
filename=os.path.basename(video_path),
|
||||
content_type=_guess_mime_type(video_path),
|
||||
)
|
||||
|
||||
job_status = None
|
||||
poll_json = {}
|
||||
resp_json = {}
|
||||
job_id = None
|
||||
job_status = None
|
||||
poll_json = {}
|
||||
resp_json = {}
|
||||
|
||||
try:
|
||||
# invoke a post request (POST /v1/videos)
|
||||
async with session.post(input.api_url, data=form) as response:
|
||||
if response.status == 200:
|
||||
@@ -410,7 +406,7 @@ async def async_request_v1_videos(
|
||||
|
||||
# invoke a poll request (GET /v1/videos/{video_id})
|
||||
poll_interval = 2.0 # Unit(s)
|
||||
timeout_seconds = input.video_job_timeout
|
||||
timeout_seconds = 600.0
|
||||
deadline = time.perf_counter() + timeout_seconds
|
||||
job_url = f"{input.api_url}/{job_id}"
|
||||
|
||||
@@ -426,11 +422,8 @@ async def async_request_v1_videos(
|
||||
poll_json = await poll_response.json()
|
||||
job_status = poll_json.get("status")
|
||||
|
||||
if job_status not in {"completed", "failed"} and time.perf_counter() >= deadline:
|
||||
output.error = (
|
||||
f"Timed out after {timeout_seconds:g}s waiting for video job {job_id} to complete. "
|
||||
"Increase --video-job-timeout for long-running or queued video jobs."
|
||||
)
|
||||
if time.perf_counter() >= deadline:
|
||||
output.error = f"Timed out waiting for video job {job_id} to complete."
|
||||
output.success = False
|
||||
return output
|
||||
|
||||
@@ -459,7 +452,7 @@ async def async_request_v1_videos(
|
||||
elif "peak_memory_mb" in resp_json:
|
||||
output.peak_memory_mb = resp_json["peak_memory_mb"]
|
||||
except Exception as e:
|
||||
output.error = f"{type(e).__name__}: {e}"
|
||||
output.error = str(e)
|
||||
output.success = False
|
||||
finally:
|
||||
if image_file is not None:
|
||||
@@ -472,13 +465,13 @@ async def async_request_v1_videos(
|
||||
except Exception as e:
|
||||
print(f"Failed to clean up video job {job_id}: {e}")
|
||||
|
||||
output.latency = time.perf_counter() - output.start_time
|
||||
if pbar is not None:
|
||||
pbar.update(1)
|
||||
output.latency = time.perf_counter() - output.start_time
|
||||
|
||||
if output.success and input.slo_ms is not None:
|
||||
output.slo_achieved = (output.latency * 1000.0) <= float(input.slo_ms)
|
||||
|
||||
if pbar:
|
||||
pbar.update(1)
|
||||
return output
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# adapted from fastvideo
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
# SPDX-FileCopyrightText: Copyright contributors to the vLLM-Omni project
|
||||
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
|
||||
|
||||
"""
|
||||
Benchmark online serving for diffusion models (Image/Video Generation).
|
||||
@@ -87,7 +87,6 @@ import base64
|
||||
import glob
|
||||
import json
|
||||
import logging
|
||||
import math
|
||||
import os
|
||||
import random
|
||||
import tempfile
|
||||
@@ -1117,11 +1116,6 @@ def calculate_metrics(
|
||||
"duration": total_duration,
|
||||
"completed_requests": num_success,
|
||||
"failed_requests": len(error_outputs),
|
||||
"request_errors": [
|
||||
{"request_id": req.request_id, "error": out.error}
|
||||
for req, out in zip(requests_list, outputs)
|
||||
if not out.success
|
||||
],
|
||||
"throughput_qps": num_success / total_duration if total_duration > 0 else 0,
|
||||
"latency_mean": np.mean(latencies) if latencies else 0,
|
||||
"latency_median": np.median(latencies) if latencies else 0,
|
||||
@@ -1267,9 +1261,6 @@ def _default_endpoint_for_task(task: str) -> str:
|
||||
|
||||
|
||||
async def benchmark(args):
|
||||
if not math.isfinite(args.video_job_timeout) or args.video_job_timeout <= 0:
|
||||
raise ValueError("--video-job-timeout must be a positive finite number of seconds.")
|
||||
|
||||
# Construct base_url if not provided
|
||||
if args.base_url is None:
|
||||
args.base_url = f"http://{args.host}:{args.port}"
|
||||
@@ -1321,8 +1312,6 @@ async def benchmark(args):
|
||||
print("Loading requests...")
|
||||
requests_list = dataset.get_requests()
|
||||
print(f"Prepared {len(requests_list)} requests from {args.dataset} dataset.")
|
||||
for req in requests_list:
|
||||
req.video_job_timeout = args.video_job_timeout
|
||||
|
||||
if args.return_stage_metrics and args.endpoint in _STAGE_METRICS_ENDPOINTS:
|
||||
for req in requests_list:
|
||||
@@ -1387,8 +1376,6 @@ async def benchmark(args):
|
||||
metrics["model"] = args.model
|
||||
metrics["dataset"] = args.dataset
|
||||
metrics["task"] = args.task
|
||||
if args.endpoint == "/v1/videos":
|
||||
metrics["video_job_timeout"] = args.video_job_timeout
|
||||
if args.endpoint == "/v1/images/edits":
|
||||
metrics["bot_task"] = args.bot_task
|
||||
|
||||
@@ -1411,11 +1398,6 @@ async def benchmark(args):
|
||||
)
|
||||
)
|
||||
print("{:<40} {}/{:<15}".format("Successful requests:", metrics["completed_requests"], len(requests_list)))
|
||||
print("{:<40} {:<15}".format("Failed requests:", metrics["failed_requests"]))
|
||||
for failure in metrics["request_errors"][:10]:
|
||||
print(f"Request {failure['request_id']} failed: {failure['error']}")
|
||||
if metrics["failed_requests"] > 10:
|
||||
print("Showing first 10 failures; use --output-file to save all request errors.")
|
||||
|
||||
# Section 3: Performance Metrics
|
||||
print(f"{'-' * 50}")
|
||||
@@ -1499,13 +1481,6 @@ if __name__ == "__main__":
|
||||
help="Path to local dataset file (optional).",
|
||||
)
|
||||
parser.add_argument("--num-prompts", type=int, default=10, help="Number of prompts to benchmark.")
|
||||
parser.add_argument(
|
||||
"--video-job-timeout",
|
||||
type=float,
|
||||
default=900.0,
|
||||
help="Maximum polling time in seconds per video job, including server queue time (default: 900). "
|
||||
"Increase this for long-running video generation or high concurrency.",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--max-concurrency",
|
||||
type=int,
|
||||
|
||||
@@ -85,25 +85,6 @@ vllm bench serve --omni \
|
||||
--save-result --result-dir ./results
|
||||
```
|
||||
|
||||
#### Set the sample rate for models that are not 24 kHz
|
||||
|
||||
Streamed PCM carries no header, so the harness derives `audio_duration` from the
|
||||
byte count and a **default 24000 Hz** assumption
|
||||
(`vllm_omni/metrics/definitions.py:DEFAULT_AUDIO_SAMPLE_RATE`). For a model that
|
||||
emits another rate, export the real one or every duration-derived metric is
|
||||
wrong by `real_sr / 24000`:
|
||||
|
||||
```bash
|
||||
# Audio8 TTS, Fish Speech S2 Pro, Ming-omni-tts, ... all decode at 44.1 kHz
|
||||
export VLLM_OMNI_BENCH_AUDIO_SAMPLE_RATE=44100
|
||||
```
|
||||
|
||||
Without it, a 44.1 kHz model reports `audio_duration` 1.84x too long, so
|
||||
`audio_rtf` looks 1.84x *better* than reality and `audio_underrun` /
|
||||
`Streaming continuity OK rate` are measured against inflated chunk budgets.
|
||||
A quick sanity check: compare `Mean AUDIO_DURATION (s)` against the actual
|
||||
length of a saved WAV for the same prompt.
|
||||
|
||||
#### Streaming continuity (`audio_underrun`)
|
||||
|
||||
`audio_underrun` (seconds) is the per-request worst-case buffer deficit
|
||||
|
||||
@@ -17,17 +17,6 @@ models:
|
||||
extra_params:
|
||||
lang: en
|
||||
text_normalization: true
|
||||
# Audio8 TTS Preview: DualAR, 44.1 kHz. trust_remote_code stays false.
|
||||
# Bench at 44.1 kHz: export VLLM_OMNI_BENCH_AUDIO_SAMPLE_RATE=44100, otherwise
|
||||
# the streamed-PCM duration defaults to 24 kHz and RTF looks 1.84x too good.
|
||||
Audio8/Audio8-TTS-Preview-0.6b:
|
||||
supported_tasks: [default_voice, voice_clone]
|
||||
backend: openai-audio-speech
|
||||
endpoint: /v1/audio/speech
|
||||
trust_remote_code: false
|
||||
task_extra_body:
|
||||
default_voice: {}
|
||||
voice_clone: {}
|
||||
|
||||
# -CustomVoice checkpoints lack speaker_encoder weights, so voice_clone is
|
||||
# NOT supported (an attempt raises ValueError from _extract_speaker_embedding
|
||||
|
||||
+20
-104
@@ -1,17 +1,25 @@
|
||||
# Target vllm version: releases/v0.29.0 @ 98dff2a81d74, installed on top of
|
||||
# the v0.28.0 base image via the precompiled wheel pinned below. The pin and
|
||||
# base intentionally differ until an official v0.29.0 base image is published.
|
||||
# Target vllm version: v0.28.0 (tag v0.28.0 @ 2cf0a6915ce5).
|
||||
# Keep VLLM_BASE_TAG aligned with the target vLLM release on every rebase.
|
||||
#
|
||||
# Pinned form: VLLM_PRECOMPILED_WHEEL_COMMIT is the rebase baseline — the rebase
|
||||
# repo-rebase-v3 advances it on each run. Keep the torch/flashinfer/numpy pins
|
||||
# aligned with that commit's requirements/cuda.txt and generated test lock.
|
||||
# VLLM_BASE_TAG stays at the newest official vLLM release below the pin; the
|
||||
# exact vLLM comes from the wheel, not the image.
|
||||
# Release-boundary form: there is no precompiled-wheel pin here, because the
|
||||
# base image already ships exactly the target vLLM. Everything the runtime
|
||||
# needs — torch, flashinfer, nvJitLink, numpy — comes from that image as one
|
||||
# self-consistent set.
|
||||
#
|
||||
# This block is required whenever the target has no matching official base
|
||||
# image, including release candidates. Drop back to the release-boundary form
|
||||
# (no wheel pin, no reinstalls, everything from the base image as one
|
||||
# self-consistent set) only after the exact tagged image is published.
|
||||
# This block reappears only when the rebase targets a vLLM commit that is NOT a
|
||||
# released tag. During the 0.27 rebase, targeting v0.27.0rc1 on top of the
|
||||
# v0.26.0 base image required reinstalling vLLM from wheels.vllm.ai and then
|
||||
# hand-repairing the fallout: pinning torch ahead of flashinfer (installing it
|
||||
# after bound flashinfer's TVM FFI runtime to the old torch and aborted engine
|
||||
# core init), registering libnvJitLink.so.13 with ldconfig, and re-pinning numpy
|
||||
# under numba's ceiling. All of it was compensation for a base image and a vLLM
|
||||
# that disagreed. At a real release boundary they agree, so none of it is
|
||||
# needed. The 0.28 rebase repeated the cycle: the v0.28.0rc / final-tag wheels
|
||||
# rode on the v0.27.0 base image with the full reinstall block until the
|
||||
# official v0.28.0 image shipped, at which point this file dropped back to the
|
||||
# form you are reading. If you pin an untagged commit again, restore the
|
||||
# reinstall block — agent/tasks/20_update_wheel_url.sh fails the run rather
|
||||
# than letting the Dockerfile silently ship the wrong vLLM.
|
||||
ARG VLLM_BASE_IMAGE=vllm/vllm-openai
|
||||
ARG VLLM_BASE_TAG=v0.28.0
|
||||
|
||||
@@ -52,98 +60,6 @@ ENV SETUPTOOLS_SCM_PRETEND_VERSION=0.0.0
|
||||
# site-packages and breaks ``import vllm_omni.entrypoints``.
|
||||
RUN uv pip install --system -e ".[dev]"
|
||||
|
||||
# Install vLLM (CUDA 13.0 build) from precompiled wheel at the selected commit.
|
||||
# Must use direct URL because the wheel has a PEP 440 local version identifier
|
||||
# (e.g. +gaeee7ef93.cu130) which pip/uv refuse to install from a PEP 503 package index.
|
||||
# The cu130 wheel index lives at /<commit>/cu130/vllm/ but the actual wheel files
|
||||
# are stored at the top level /<commit>/<wheel>.
|
||||
ENV VLLM_PRECOMPILED_WHEEL_COMMIT=98dff2a81d747d1dba01a47f939f48c3526d4206
|
||||
# Keep the base image's CUDA toolkit libs on the loader path. This does NOT by
|
||||
# itself guarantee libnvJitLink.so.13 resolves — the .so.13 JIT linker is
|
||||
# handled separately via ldconfig after the cu130 wheels are installed (see the
|
||||
# nvidia-nvjitlink-cu13 step below), which is a no-op when the base image
|
||||
# already provides it.
|
||||
ENV LD_LIBRARY_PATH=/usr/local/cuda/targets/x86_64-linux/lib:${LD_LIBRARY_PATH}
|
||||
RUN VLLM_WHEEL_URL=$(python3 -c "import urllib.request,re; \
|
||||
from urllib.parse import urljoin, quote; \
|
||||
index_url='https://wheels.vllm.ai/${VLLM_PRECOMPILED_WHEEL_COMMIT}/cu130/vllm/'; \
|
||||
html=urllib.request.urlopen(index_url).read().decode(); \
|
||||
m=re.search(r'href=\"([^\"]*x86_64\.whl)\"',html); \
|
||||
assert m, f'No x86_64 vLLM wheel found at {index_url}'; \
|
||||
print(quote(urljoin(index_url,m.group(1)), safe=':/+%'))") && \
|
||||
echo "Installing vLLM from: ${VLLM_WHEEL_URL}" && \
|
||||
uv pip install --system --force-reinstall "${VLLM_WHEEL_URL}"
|
||||
|
||||
|
||||
# Pin torch BEFORE flashinfer. Versions mirror vLLM requirements/cuda.txt at
|
||||
# VLLM_PRECOMPILED_WHEEL_COMMIT.
|
||||
#
|
||||
# The ordering is the load-bearing part, not the version. When the base image
|
||||
# and the pinned wheel agree on torch this pin is a no-op guard; when they
|
||||
# diverge it is what keeps flashinfer from resolving against a torch that the
|
||||
# vLLM reinstall then removes. That failure mode is not hypothetical: during the
|
||||
# 0.27 rebase (v0.27.0rc1 wheel on a v0.26.0 base, torch 2.11.0 -> 2.13.0),
|
||||
# installing flashinfer first bound its compiled artifacts — and its bundled TVM
|
||||
# FFI runtime — to the old torch, producing a C++ abort during engine-core init:
|
||||
#
|
||||
# terminate called after throwing an instance of 'tvm::ffi::Error'
|
||||
# what(): TypeAttr `__ffi_repr__` is already registered for type index 132
|
||||
#
|
||||
# plus `from deep_ep_cpp import EventHandle` -> ImportError, which together took
|
||||
# out 21 CI jobs on build #2947 that pass on main.
|
||||
#
|
||||
# Installing torch first means FlashInfer resolves against the final runtime.
|
||||
RUN uv pip install --system --force-reinstall \
|
||||
"torch==2.13.0" "torchaudio==2.11.0" "torchvision==0.28.0" \
|
||||
--torch-backend cu130
|
||||
|
||||
# No --upgrade here: with torch already at its pinned version, --upgrade is what
|
||||
# would drag it forward again and reintroduce the mismatch this ordering fixes.
|
||||
RUN uv pip install --system \
|
||||
"flashinfer-python==0.6.18" \
|
||||
"flashinfer-cubin==0.6.18" \
|
||||
--extra-index-url https://flashinfer.ai/whl/
|
||||
|
||||
RUN uv pip install --system \
|
||||
"flashinfer-jit-cache==0.6.18" \
|
||||
--index-url https://flashinfer.ai/whl/cu130
|
||||
|
||||
# Fail the build here rather than at engine-core init if anything above moved
|
||||
# torch off its pin. The previous failure mode was a C++ terminate inside a
|
||||
# worker subprocess, which surfaced only as "Failed core proc(s): {}" — an
|
||||
# empty set, hours into the test run.
|
||||
RUN python3 -c "import torch, sys; \
|
||||
want='2.13.0'; got=torch.__version__.split('+')[0]; \
|
||||
sys.exit(0) if got==want else sys.exit(f'torch pin drifted: want {want}, got {torch.__version__}')" && \
|
||||
python3 -c "import deep_ep_cpp" 2>/dev/null \
|
||||
&& echo 'deep_ep_cpp imports cleanly' \
|
||||
|| echo 'WARNING: deep_ep_cpp not importable (non-fatal; vLLM treats deep_ep as optional)'
|
||||
|
||||
# CUDA 13 JIT linker: libnvJitLink.so.13 is provided by the nvidia-nvjitlink
|
||||
# package that the cu130 torch/vllm wheels above pull into site-packages. When
|
||||
# the base image ships a CUDA-12 toolkit, /usr/local/cuda never resolves the
|
||||
# .so.13 and the LD_LIBRARY_PATH above is not enough. Even when it is present,
|
||||
# its lib dir is not on the dynamic-loader path, so bitsandbytes / torch.compile
|
||||
# worker subprocesses fail to dlopen it. Locate the already-installed lib and
|
||||
# register its dir with ldconfig (system-wide, survives subprocess env resets).
|
||||
# Only fall back to the pip wheel (correct name: nvidia-nvjitlink-cu13, NOT
|
||||
# nvidia-cuda-nvjitlink-cu13, which does not exist) if the torch deps did not
|
||||
# bring it in.
|
||||
RUN NVJITLINK_LIB="$(find / -name 'libnvJitLink.so.13*' 2>/dev/null | head -1)" && \
|
||||
if [ -z "$NVJITLINK_LIB" ]; then \
|
||||
uv pip install --system "nvidia-nvjitlink-cu13" && \
|
||||
NVJITLINK_LIB="$(find / -name 'libnvJitLink.so.13*' 2>/dev/null | head -1)"; \
|
||||
fi && \
|
||||
test -n "$NVJITLINK_LIB" && \
|
||||
dirname "$NVJITLINK_LIB" > /etc/ld.so.conf.d/nvjitlink-cu13.conf && \
|
||||
ldconfig && \
|
||||
echo "Registered ${NVJITLINK_LIB} with ldconfig"
|
||||
|
||||
# Re-pin numpy LAST. The v0.29.0rc1 CUDA requirements use numba 0.65.0 and the
|
||||
# generated CUDA test lock resolves numpy 2.2.6. This must be the final
|
||||
# dependency operation so the wheel and FlashInfer installs cannot clobber it.
|
||||
RUN uv pip install --system "numpy==2.2.6"
|
||||
|
||||
# The final stage just copies the working dir on top of the
|
||||
# dependencies image. This uses --link so that we can skip
|
||||
# the image pull in Buildkite when we have a cache hit.
|
||||
|
||||
@@ -127,7 +127,6 @@ nav:
|
||||
- Async Chunk: design/feature/async_chunk.md
|
||||
- Async Diffusion Output: design/feature/async_diffusion_output.md
|
||||
- Async Omni Output Materialization: design/feature/omni_async_output_materialization.md
|
||||
- Prefill/Decode Phase Contract: design/feature/preprocess_phase_contract.md
|
||||
- Automatic Prefix Caching: design/feature/prefix_caching.md
|
||||
- Realtime AR-Diffusion: design/feature/realtime_ar_diffusion.md
|
||||
- Communication:
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 272 KiB After Width: | Height: | Size: 274 KiB |
@@ -436,76 +436,6 @@ This should be seen as an edge case, and if this behavior can be avoided by sett
|
||||
|
||||
</details>
|
||||
|
||||
### Image / video generation
|
||||
|
||||
For `/v1/images/generations`, `/v1/images/edits`, and `/v1/videos`, set `--endpoint` to that path and omit `--backend`. The endpoint path is registered as the bench request adapter, so a separate named backend is not required.
|
||||
|
||||
Example (`/v1/images/generations`):
|
||||
|
||||
```bash
|
||||
vllm bench serve --omni \
|
||||
--endpoint /v1/images/generations \
|
||||
--dataset-name random \
|
||||
--model ~/models/Qwen/Qwen-Image \
|
||||
--tokenizer ~/models/Qwen/Qwen-Image/tokenizer \
|
||||
--max-concurrency 1 \
|
||||
--num-warmups 2 \
|
||||
--num-prompts 10 \
|
||||
--random-input-len 64 \
|
||||
--random-output-len 1 \
|
||||
--ignore-eos \
|
||||
--percentile-metrics e2el \
|
||||
--extra-body '{
|
||||
"num_inference_steps": 20,
|
||||
"seed": 42,
|
||||
"true_cfg_scale": 4.0
|
||||
}'
|
||||
```
|
||||
|
||||
If successful, following output is like:
|
||||
|
||||
```text
|
||||
============ Serving Benchmark Result ============
|
||||
Successful requests: 3
|
||||
Failed requests: 0
|
||||
Maximum request concurrency: 1
|
||||
Benchmark duration (s): 8.42
|
||||
Request throughput (req/s): 0.36
|
||||
Peak concurrent requests: 2.00
|
||||
-------------------Peak Memory--------------------
|
||||
Mean PEAK_MEMORY_MB (MB): 58832.00
|
||||
Median PEAK_MEMORY_MB (MB): 58832.00
|
||||
P99 PEAK_MEMORY_MB (MB): 58832.00
|
||||
----------------End-to-end Latency----------------
|
||||
Mean E2EL (ms): 2798.16
|
||||
Median E2EL (ms): 2799.83
|
||||
P99 E2EL (ms): 2800.03
|
||||
================== Image Result ==================
|
||||
Total images generated: 3
|
||||
Image throughput (img/s): 0.36
|
||||
Average pixels per image: 1048576.00
|
||||
Mean denoise step latency (ms): 136.59
|
||||
---------------- Image Generation ----------------
|
||||
Mean IMAGE_GENERATION (ms): 2731.84
|
||||
Median IMAGE_GENERATION (ms): 2732.02
|
||||
P99 IMAGE_GENERATION (ms): 2734.65
|
||||
==================================================
|
||||
```
|
||||
|
||||
Use the same pattern with `--endpoint /v1/images/edits` or `--endpoint /v1/videos` (and model-specific `--extra-body` as needed). Pure image/video runs omit the Text Result section when there is no generated text.
|
||||
|
||||
`/v1/images/edits` defaults to **non-streaming JSON** (`stream=false`) so single-stage edit models are not rejected by the server. For multi-stage pipelines that need SSE (AR TTFT / image chunks), pass `"stream": true` in `--extra-body`.
|
||||
|
||||
`/v1/videos` is an async job API: the client creates a job, then polls until `completed`/`failed`. Measured **e2el** therefore includes client poll sleep and any overshoot after the job actually finishes. Tune polling via `--extra-body`:
|
||||
|
||||
- `poll_interval_s` (default `2.0`): sleep between status polls
|
||||
- `poll_timeout_s` (default `21600`, i.e. 6 hours): give up waiting for the job
|
||||
|
||||
**VIDEO_RTF** prefers server-reported generation time when available:
|
||||
|
||||
- `video_rtf = video_generation_time_ms / 1000 / video_duration`, where `video_generation_time_ms` comes from response `stage_durations` (or `inference_time_s` as fallback)
|
||||
- If generation time is missing, falls back to `e2el / video_duration` (this fallback *does* include poll overhead)
|
||||
|
||||
### Multi-Stage Benchmark
|
||||
|
||||
<details class="admonition abstract" markdown="1">
|
||||
|
||||
@@ -262,28 +262,6 @@ or serving, explain the required L2/L3 environment and provide the exact command
|
||||
|
||||
Repository skills guide the agent, but they do not replace contributor judgment, the accepted issue or RFC, required test evidence, or maintainer review. Review all generated changes before submitting them.
|
||||
|
||||
## AI Usage Policy
|
||||
|
||||
AI tools are welcome in vLLM-Omni contributions. Contributors, including maintainers, remain responsible for everything they submit. These requirements apply to pull requests, issues, discussions, and review comments:
|
||||
|
||||
- **Disclose AI assistance.** Name the tools used and describe their role in the submission, including assistance with code, tests, documentation, or writing.
|
||||
- **Understand your changes.** Review every generated change and be able to explain its behavior, design choices, and interaction with vLLM-Omni without relying on AI to answer for you.
|
||||
- **Validate before submitting.** Run relevant checks and report actual results. For model, kernel, or performance changes, include the hardware, model, configuration, and commands needed to reproduce accuracy or benchmark evidence. Clearly identify checks you could not run; generated claims are not test results.
|
||||
- **Keep communication useful.** Verify technical claims, search for existing reports, and edit AI-assisted text for accuracy and brevity. Submit only content you have personally reviewed, and take responsibility for responding to review feedback.
|
||||
- **Label generated media.** Model-generated images, video, and audio are valid examples or test artifacts for this multimodal project. Identify them as generated output and provide the model, inputs, and reproduction settings. Do not present them as ground-truth references or independent evidence of correctness.
|
||||
|
||||
For example, a PR description could include:
|
||||
|
||||
```text
|
||||
AI assistance: Used Codex to draft the regression test and PR description.
|
||||
I reviewed the changes and verified the test reproduces the reported failure.
|
||||
Validation: <commands, results, hardware, and any checks not run>.
|
||||
```
|
||||
|
||||
Maintainer review time is limited. Contributions that are unverified, misleading, or beyond the author's understanding may be closed. Repeated violations may lead to contribution restrictions. New contributors are welcome to ask for help and submit small, well-understood changes.
|
||||
|
||||
This policy is adapted from [Ghostty's AI Usage Policy](https://github.com/ghostty-org/ghostty/blob/main/AI_POLICY.md) for vLLM-Omni's contribution and multimodal validation workflows. The [coding-agent workflow](#using-repository-skills-with-coding-agents) provides practical guidance for applying it.
|
||||
|
||||
## Issues
|
||||
|
||||
If you encounter a bug or have a feature request, please search existing issues first to see if it has already been reported. If not, please file a new issue, providing as much relevant information as possible.
|
||||
|
||||
@@ -161,9 +161,7 @@ Canonical layout (prefer these paths for new changes):
|
||||
|
||||
**Bootstrap:** [`amd/scripts/bootstrap-amd-omni.sh`](https://github.com/vllm-project/vllm-omni/blob/main/.buildkite/amd/scripts/bootstrap-amd-omni.sh)—skip-ci, diff filtering, Jinja render, then `buildkite-agent pipeline upload`.
|
||||
|
||||
**Test YAML (data):** `amd/test-amd-ready.yml` (L2 / `ready`), `test-amd-merge.yml` (L3 / `merge-test` and `main`). On a PR carrying both labels, AMD combines both suites behind one image build. PR builds without either tier label retain the legacy L2 fallback for compatibility with the `amd-test` trigger. `DEBUG_TEST_YAML` remains an explicit override. AMD has no L4 file yet, so `nightly-test` does not select an additional suite.
|
||||
|
||||
**Trigger boundary:** AMD label handling has two layers. First, the external `vllm-omni-amd-ci` Buildkite pipeline condition decides whether a GitHub label event creates a build. Only after that build starts does this repository's bootstrap inspect all current PR labels and select L2, L3, or both. Repository-side selection therefore cannot make a `merge-test` event start AMD CI by itself. The external condition must admit both `ready` and `merge-test`, while preserving the legacy `amd-test` trigger and non-PR `main` / scheduled builds. For PR builds without a `DEBUG_TEST_YAML` override, an unreadable label set fails the bootstrap instead of silently selecting the wrong tier. Debug overrides skip label lookup and are validated directly; invalid values, including whitespace-only values, fail the bootstrap. Keep `nightly-test` out of the AMD condition until an AMD L4 suite exists; otherwise it would start a build without providing nightly coverage.
|
||||
**Test YAML (data):** `amd/test-amd-ready.yml` (L2 / PR), `test-amd-merge.yml` (L3 / main).
|
||||
|
||||
**Rendering:** [`test-template-amd-omni.j2`](https://github.com/vllm-project/vllm-omni/blob/main/.buildkite/amd/test-template-amd-omni.j2) wraps data steps with `amd-build` image build and `amd_<agent_pool>` queues. Do **not** hand-edit generated `pipeline.yaml`.
|
||||
|
||||
|
||||
@@ -779,31 +779,6 @@ turning them on. For Qwen-Image-style serving examples, document
|
||||
`--step-execution` as the feature gate and `--max-num-seqs N` as the
|
||||
companion batching knob.
|
||||
|
||||
### Streaming Output and Mid-Stream Interactions
|
||||
|
||||
To add streaming generation with optional mid-stream prompt updates to a new diffusion pipeline (often a video generation pipeline):
|
||||
|
||||
0. **Model should internally support** chunked video emission and bounded VAE decode of a chunk.
|
||||
1. **Implement stepwise execution** so interaction RPCs can be consumed at chunk
|
||||
boundaries (see [Step Execution](#step-execution) above).
|
||||
2. **Mix in** ``InteractionMixin`` on the pipeline class.
|
||||
3. **Implement** ``peek_chunk_media(StepRequestState) -> ChunkMediaSpec`` to offer information
|
||||
about the next chunk to generate.
|
||||
This is called whenever one supported interaction modality needs frame-level calculation,
|
||||
e.g., per-frame camera trajectory. If only chunk-level calculation is involved, peeking is skipped.
|
||||
4. **Optionally implement** ``prepare_next_chunk(StepRequestState)`` if the
|
||||
pipeline must rebuild something (e.g., per-chunk state) after an interaction is applied.
|
||||
This function is called at chunk boundary.
|
||||
5. **Register** supported modalities and handlers in ``vllm_omni/diffusion/interaction/registry.py``
|
||||
(keyed by ``od_config.model_class_name`` → modality key as in ``req["multi_modal_data"]``).
|
||||
|
||||
Serve with ``--diffusion-streaming-output`` (auto-enables step execution). See
|
||||
[Diffusion Execution Modes](../../user_guide/diffusion/execution_modes.md#streaming-output)
|
||||
and the example script at `examples/online_serving/streaming_video_generation/`.
|
||||
|
||||
**Interaction payload contract:** Although ``OmniInteractionPrompt`` type annocation requires ``event_id``,
|
||||
the WebSocket API payload may omit ``event_id`` and let the API layer assigns one.
|
||||
|
||||
### Cache Acceleration
|
||||
|
||||
#### TeaCache
|
||||
|
||||
@@ -222,16 +222,6 @@ __all__ = ["Qwen3OmniMoeForConditionalGeneration"]
|
||||
|
||||
## Key Components
|
||||
|
||||
### Preprocess phase metadata
|
||||
|
||||
Models with `has_preprocess=True`, including out-of-tree plugins, can rely on
|
||||
the runner's stable `_omni_is_prefill`, `_omni_prompt_len`, and
|
||||
`_omni_num_computed_tokens` fields. Use request progress to distinguish prompt
|
||||
prefill from decode: a one-token span can still be a prefill tail. See the
|
||||
[runner-to-model phase contract](../../design/feature/preprocess_phase_contract.md)
|
||||
for types, batched-hook semantics, MTP routing guarantees, and the correctness
|
||||
workaround for vLLM-Omni 0.20.x and earlier.
|
||||
|
||||
### 1. Model Interfaces
|
||||
|
||||
Your model should implement the appropriate interfaces:
|
||||
|
||||
@@ -22,15 +22,11 @@ A pipeline opts in by implementing `SupportsARDiffusionPipeline`. Its immutable
|
||||
- named fixed-length cross-attention KV, model-specific scratch geometry, and
|
||||
the pipeline's requested session-capacity upper bound.
|
||||
|
||||
The runner binds an `ARDiffusionKVState` only around one runner invocation
|
||||
(`execute_model` or `execute_stepwise`). The pipeline may use it during that
|
||||
context but must not retain it. Scratch and committed pages stay on the
|
||||
runner-owned session object, so unbinding does not drop an in-flight stepwise
|
||||
chunk. Tick-mode sessions survive subsequent requests with the same
|
||||
`session_id`. On the stepwise path the session id is the request id and is
|
||||
released when that request finishes or fails. Request reset, explicit close,
|
||||
LRU eviction, and forward exceptions all release runner-owned KV and call the
|
||||
pipeline's reset/close lifecycle hook. Cross-attention KV is allocated lazily
|
||||
The runner binds an `ARDiffusionKVState` only around one `forward()` call. The
|
||||
pipeline may use it during that context but must not retain it. The session
|
||||
survives subsequent requests with the same `session_id`. Request reset, explicit
|
||||
close, LRU eviction, and forward exceptions all release runner-owned KV and call
|
||||
the pipeline's reset/close lifecycle hook. Cross-attention KV is allocated lazily
|
||||
per session and logical KV branch, and is released on the same path. A pipeline
|
||||
publishes one named cache transactionally by yielding exactly one `(k, v)` pair
|
||||
per layer:
|
||||
@@ -52,12 +48,11 @@ successful forward. The runner also exposes `reset_session()` and
|
||||
|
||||
## Current execution limits
|
||||
|
||||
The experimental runner supports `max_num_seqs=1`. Request-batch execution is
|
||||
still rejected. Step execution is allowed only when the loaded pipeline
|
||||
implements `SupportsStepExecution`; other AR-Diffusion pipelines still fail at
|
||||
load if `step_execution=True`. Capable pipelines bind KV around each
|
||||
`execute_stepwise` invocation instead of inheriting the generic runner entry
|
||||
point unwrapped.
|
||||
The experimental runner supports request-mode execution with
|
||||
`max_num_seqs=1`. It rejects step execution and request-batch execution at load
|
||||
time, and its inherited batch/step entry points also fail explicitly. Supporting
|
||||
those paths requires a batch-aware state-binding contract rather than silently
|
||||
bypassing `bind_ar_diffusion_state()`.
|
||||
|
||||
The implementation may retain multiple sessions per model instance. It selects
|
||||
the largest feasible capacity up to the pipeline's `session_capacity`, based on
|
||||
|
||||
@@ -323,24 +323,18 @@ inputs, fields, and ownership rules are described below.
|
||||
```mermaid
|
||||
flowchart TB
|
||||
layer1["Layer 1 · Authoring inputs<br/>PipelineConfig + DeployConfig"]
|
||||
layer2["Layer 2 · Production resolution boundary<br/>resolve_omni_config()<br/>(StageConfigFactory + VllmOmniConfig internally)"]
|
||||
layer3["Layer 3 · Startup hand-off<br/>OmniConfigResolution<br/>PipelineConfig + temporary OmegaConf stage bridge"]
|
||||
layer2["Layer 2 · Resolve once<br/>StageConfigFactory.create_from_model()<br/>VllmOmniConfig.from_pipeline_config()"]
|
||||
layer3["Layer 3 · Transport-safe control plane<br/>VllmOmniConfig"]
|
||||
layer4["Layer 4 · Runtime launch planning<br/>StageRuntime"]
|
||||
layer5["Layer 5 · Engine materialization<br/>VllmConfig / OmniDiffusionConfig"]
|
||||
|
||||
layer1 --> layer2 --> layer3 --> layer4 --> layer5
|
||||
```
|
||||
|
||||
The production resolution boundary is `resolve_omni_config()` in
|
||||
The single resolution boundary is implemented by
|
||||
`StageConfigFactory.create_from_model()` and
|
||||
`VllmOmniConfig.from_pipeline_config()` in
|
||||
[`vllm_omni/config`](https://github.com/vllm-project/vllm-omni/tree/main/vllm_omni/config).
|
||||
It delegates typed construction to `StageConfigFactory.create_from_model()` and
|
||||
`VllmOmniConfig.from_pipeline_config()`, then returns an
|
||||
`OmniConfigResolution` consumed by both `AsyncOmniEngine` and headless startup.
|
||||
Until `StageRuntime` consumes typed stage configs directly, this envelope carries
|
||||
the effective `PipelineConfig` alongside OmegaConf-compatible `stage_configs` as
|
||||
a temporary runtime bridge; both views describe the same resolved topology,
|
||||
including injected stages.
|
||||
|
||||
The legacy `stage_args` YAML path has been removed. Model topology now resolves
|
||||
through `PipelineConfig`, with runtime overrides supplied by `DeployConfig`.
|
||||
|
||||
@@ -360,12 +354,9 @@ The important ownership rules are:
|
||||
deploy-time defaults; it does not redefine the model graph.
|
||||
3. CLI and Python overrides are applied at the resolution boundary, with
|
||||
per-stage overrides taking precedence over global values where supported.
|
||||
4. `OmniConfigResolution` is the sole startup hand-off. Its `pipeline_config`
|
||||
and temporary `stage_configs` compatibility view must describe the same
|
||||
topology.
|
||||
5. `StageRuntime` owns launch planning and replica lifecycle. `ReplicaInitPlan`
|
||||
4. `StageRuntime` owns launch planning and replica lifecycle. `ReplicaInitPlan`
|
||||
is runtime-private state, not a user configuration object.
|
||||
6. `VllmConfig` and the enriched `OmniDiffusionConfig` are materialized in the
|
||||
5. `VllmConfig` and the enriched `OmniDiffusionConfig` are materialized in the
|
||||
process that owns the corresponding engine.
|
||||
|
||||
## Main features
|
||||
|
||||
@@ -53,11 +53,6 @@ must use distinct hook names and remove only hooks they own.
|
||||
|
||||
## Discovery and topology
|
||||
|
||||
`resolve_offload_plan(pipeline, config)` is the single topology entry point.
|
||||
Every backend calls it once when `enable()` starts and then consumes the
|
||||
resolved components, block stacks, resident heads, and staged-residency flags
|
||||
it returns. Backends do not re-read model declarations.
|
||||
|
||||
Pipeline component discovery prefers `SupportsComponentDiscovery` declarations:
|
||||
|
||||
- `_dit_modules`;
|
||||
@@ -66,26 +61,16 @@ Pipeline component discovery prefers `SupportsComponentDiscovery` declarations:
|
||||
- `_resident_modules`.
|
||||
|
||||
Dotted paths are supported. Legacy pipelines may use the fallback scan of
|
||||
well-known attribute names; it now warns once per pipeline class, and new
|
||||
integrations must declare components explicitly.
|
||||
well-known attribute names, but new integrations should declare components
|
||||
explicitly.
|
||||
|
||||
Block topology comes from the pipeline `OffloadPlan` first: `block_attrs` maps
|
||||
each DiT path to its ordered block containers, `encoder_block_attrs` declares
|
||||
streamable encoder stacks, `on_demand_component_paths` marks pipeline-managed
|
||||
residency, `resident_dit_paths` marks the DiTs that may hold resident layers,
|
||||
and `encoder_dlo_weight_replication` marks the encoders whose loader-produced
|
||||
weights are safe for AllGather. DiTs absent from the plan fall back to
|
||||
`_layerwise_offload_blocks_attrs` (including the deprecated singular-name
|
||||
compatibility path).
|
||||
|
||||
The resolver is pure: it moves no tensor, installs no hook, writes no module
|
||||
attribute, and reads no process group — multi-rank facts come from
|
||||
`OffloadConfig`. It owns topology validation, so a configuration the model
|
||||
cannot serve fails before the first component is placed. Explicit component
|
||||
selection turns every declaration problem into an error, while the
|
||||
compatibility topology (no component selector) keeps the historical
|
||||
warn-and-skip behavior. Metadata still describes structure only; the backend
|
||||
remains responsible for transfer, synchronization, and storage ownership.
|
||||
Both layerwise backends first consume pipeline `OffloadPlan` metadata. A
|
||||
plan's `block_attrs` maps each DiT path to its ordered block containers, while
|
||||
`encoder_block_attrs` declares streamable encoder stacks. DiTs absent from the
|
||||
plan fall back to `_layerwise_offload_blocks_attrs` (including the deprecated
|
||||
singular-name compatibility path). Discovery metadata describes structure
|
||||
only; the backend remains responsible for transfer, synchronization, and
|
||||
storage ownership.
|
||||
|
||||
## Cross-strategy invariants
|
||||
|
||||
|
||||
@@ -1,172 +0,0 @@
|
||||
# Runner-to-model prefill/decode phase contract
|
||||
|
||||
## Overview
|
||||
|
||||
Autoregressive models with a custom `preprocess` hook need to distinguish
|
||||
prompt processing from decoding. A one-token span can be either a complete
|
||||
one-token prompt, the last chunk of a longer prompt, or a decode step. Using
|
||||
span length as the phase signal can replace a prompt embedding with a generated
|
||||
audio embedding and advance teacher-forced text too early without an exception.
|
||||
|
||||
[Issue #4382](https://github.com/vllm-project/vllm-omni/issues/4382) requests a
|
||||
stable contract for the metadata and routing guards introduced by
|
||||
[PR #3662](https://github.com/vllm-project/vllm-omni/pull/3662).
|
||||
The shared runner already implements those guards. This design documents the
|
||||
existing interface and adds runner-level regression coverage rather than
|
||||
introducing a second phase detector or changing scheduling policy.
|
||||
|
||||
## Scope and objectives
|
||||
|
||||
- Make the three existing phase keys safe to depend on in out-of-tree models.
|
||||
- Preserve prompt embeddings and model state on a one-token prefill tail.
|
||||
- Keep normal and batched decode routing consistent in mixed batches.
|
||||
- Explain the correctness workaround required on older releases.
|
||||
|
||||
This contract does not enable chunked prefill for models whose other state
|
||||
handling does not support it. It does not change the scheduler, introduce new
|
||||
kwargs, or standardize other `_omni_*` fields. The implementation adds
|
||||
documentation and regression coverage; no hot-path allocation is added.
|
||||
|
||||
## Design
|
||||
|
||||
### Ownership and data flow
|
||||
|
||||
```text
|
||||
Scheduler / current input batch
|
||||
prompt_token_ids + num_computed_tokens_cpu (before this step)
|
||||
|
|
||||
OmniGPUModelRunner._preprocess
|
||||
|
|
||||
per-request phase metadata
|
||||
/ \
|
||||
prefill / other spans single-token decode
|
||||
preprocess preprocess or preprocess_decode_batch
|
||||
| |
|
||||
prompt embedding runner-managed talker_mtp
|
||||
\ /
|
||||
model forward
|
||||
```
|
||||
|
||||
The producer is `OmniGPUModelRunner._preprocess` in
|
||||
`vllm_omni/worker/gpu_model_runner.py`. `GPUARModelRunner` and
|
||||
`GPUGenerationModelRunner` inherit it. The current `OmniNPUModelRunner` also
|
||||
inherits this method; device-specific execution still needs its own hardware
|
||||
validation. A plugin runner that overrides preprocessing is responsible for
|
||||
preserving this interface.
|
||||
|
||||
### Stable model-facing fields
|
||||
|
||||
The following names, types, and meanings are a supported interface for in-tree
|
||||
and out-of-tree model hooks despite the leading underscore. Models should treat
|
||||
them as read-only runner-owned values. Changes to their meanings or removal
|
||||
require an explicit compatibility/migration plan.
|
||||
|
||||
| Key | Python type | Meaning |
|
||||
| --- | --- | --- |
|
||||
| `_omni_prompt_len` | `int` | Length of the current request state's `prompt_token_ids`. This is the stage's prompt length, not the current chunk size or raw text length. |
|
||||
| `_omni_num_computed_tokens` | `int` | The row's `input_batch.num_computed_tokens_cpu` value **before** processing the scheduled span. It includes already-computed/cached progress, not just tokens computed in the current call. |
|
||||
| `_omni_is_prefill` | `bool` | Exactly `_omni_num_computed_tokens < _omni_prompt_len`. Equality and greater progress mean decode. |
|
||||
|
||||
The runner refreshes the fields after current request state has been gathered,
|
||||
immediately before selecting the per-row hook. Existing values in intermediate
|
||||
model state cannot override the current phase. Row indices follow the current
|
||||
input batch (including any reordering), not request arrival order. A resumed
|
||||
or streaming request is classified from its **current** prompt/progress values;
|
||||
the phase is not latched for the lifetime of the request.
|
||||
|
||||
The normal hook receives these fields as keyword arguments:
|
||||
|
||||
```python
|
||||
def preprocess(self, input_ids, input_embeds, **info):
|
||||
if info["_omni_is_prefill"]:
|
||||
offset = info["_omni_num_computed_tokens"]
|
||||
# Select the scheduled slice of the model's prompt embeddings.
|
||||
...
|
||||
else:
|
||||
# Advance decode-only text/audio state.
|
||||
...
|
||||
```
|
||||
|
||||
For `preprocess_decode_batch(input_ids=..., req_infos=...)`, each `req_infos`
|
||||
entry contains the same fields, aligned with its corresponding input row.
|
||||
Every such row has `_omni_is_prefill == False`. The optional earlier
|
||||
`preprocess_batch` hook is a separate whole-batch preparation hook; these freshly
|
||||
computed per-row fields are not promised at that earlier boundary.
|
||||
|
||||
### Routing guarantee
|
||||
|
||||
With `has_preprocess=True`, the batched decode hook is eligible only when it is
|
||||
callable, the runner has `talker_mtp`, the scheduled span is one token, and
|
||||
`_omni_is_prefill` is false. Otherwise the normal `preprocess` hook runs.
|
||||
|
||||
Runner-managed MTP is likewise restricted to single-token decode rows. A prefill
|
||||
row, including a one-token tail, is never added to that MTP batch: the runner
|
||||
does not consume its `mtp_inputs`, generate codes for it, or overwrite its
|
||||
preprocessed embedding with an MTP embedding. Decode rows in the same step
|
||||
continue to receive their MTP outputs at their own token offsets. Models may
|
||||
still implement their own model-specific work inside `preprocess`.
|
||||
|
||||
| Prompt length | Computed before step | Scheduled span | Phase | Runner MTP eligible |
|
||||
| --- | --- | --- | --- | --- |
|
||||
| 5 | 0 | 4 | Prefill | No |
|
||||
| 5 | 4 | 1 | Prefill tail | No |
|
||||
| 5 | 5 | 1 | Decode | Yes |
|
||||
| 5 | 6 | 1 | Decode | Yes |
|
||||
| 1 | 0 | 1 | Prefill | No |
|
||||
| 5 | 5 | 2 | Decode | No (not a single-token span) |
|
||||
|
||||
### Compatibility
|
||||
|
||||
!!! warning "vLLM-Omni 0.20.x and earlier"
|
||||
AR talker models with custom preprocessing that infer phase from span length
|
||||
must use `enable_chunked_prefill: false` for correctness on these releases.
|
||||
They lack the phase metadata and the runner's prefill-tail MTP protection.
|
||||
A model-only heuristic cannot prevent the older runner from overwriting a
|
||||
one-token prompt embedding. Disabling chunking avoids split tails; it does
|
||||
not make span length a reliable phase detector for every possible prompt.
|
||||
|
||||
The mechanism landed in #3662 (v0.21.0rc2 / v0.22.0 and later); this document
|
||||
formalizes that existing behavior. Prefer upgrading the matching vLLM and
|
||||
vLLM-Omni release pair and consuming the explicit phase keys. Do not silently
|
||||
fall back to `input_ids.numel() > 1` when the model requires chunking correctness.
|
||||
For a custom or backported runtime, verify both metadata and MTP guards.
|
||||
|
||||
## Correctness and testing plan
|
||||
|
||||
Runner tests call the production `_preprocess` and `_talker_mtp_forward` methods
|
||||
with CPU buffers and a deterministic MTP model. They inspect kwargs at the model
|
||||
boundary, resulting embeddings, and per-request generated codes. Coverage must
|
||||
include a multi-step prompt split with a one-token tail followed by decode,
|
||||
mixed prefill/decode batches in different orders, normal/batched decode hooks,
|
||||
adjacent decode requests in the same hook call with exact per-request codes,
|
||||
single-token prompts, cached progress, and decode spans longer than one token.
|
||||
No test should pass merely because MTP was disabled for every row.
|
||||
|
||||
Real-weight validation uses Qwen3-TTS CustomVoice through the full talker and
|
||||
code2wav pipeline. Record the actual scheduled prompt progress, assert that at
|
||||
least one one-token prefill tail was observed, check its hook metadata and MTP
|
||||
exclusion, and require finite non-empty output audio. Compare to an unchunked
|
||||
run with the same real input, greedy sampling, and `VLLM_BATCH_INVARIANT=1`.
|
||||
Greedy sampling alone does not guarantee identical codes across different
|
||||
prefill shapes: floating-point reduction differences can change an argmax and
|
||||
diverge in subsequent autoregressive steps. Invariant kernels keep this exact
|
||||
comparison focused on the phase contract. The two engines must be initialized
|
||||
separately because their chunking settings and token budgets differ. GPU tests belong under
|
||||
`tests/e2e/features/`; existing model tests remain useful adjacent regression
|
||||
coverage. Functional audio checks do not establish throughput or all-model
|
||||
semantic parity; this change makes no performance claim.
|
||||
|
||||
## Open questions and discussions
|
||||
|
||||
There are no new field names or execution modes to choose. Future runner
|
||||
implementations, including Model Runner V2, should preserve these semantics or
|
||||
provide an explicit migration path. Hardware validation beyond the tested
|
||||
platform remains separate from the shared Python routing tests.
|
||||
|
||||
## References
|
||||
|
||||
- [Issue #4382](https://github.com/vllm-project/vllm-omni/issues/4382)
|
||||
- [Original metadata and guards, #3662](https://github.com/vllm-project/vllm-omni/pull/3662)
|
||||
- [Qwen2.5-Omni consumer fix, #5019](https://github.com/vllm-project/vllm-omni/pull/5019)
|
||||
- [Adding an Omni model](../../contributing/model/adding_omni_model.md)
|
||||
- [Test writing guide](../../contributing/ci/test_writing_guide.md)
|
||||
@@ -66,8 +66,7 @@ The checkpoint keeps these verified contracts:
|
||||
- scheduler data-plane append over a resumable request;
|
||||
- stale epoch/turn/response fencing;
|
||||
- `/v1/duplex` and OpenAI Realtime projection;
|
||||
- optional OpenAI `server_vad` turn detection backed by a process-shared Silero
|
||||
model and per-session VAD state;
|
||||
- optional OpenAI `server_vad` turn detection backed by per-session Silero VAD;
|
||||
- existing JoyVL behavior.
|
||||
|
||||
The checkpoint does not claim:
|
||||
@@ -653,7 +652,7 @@ EOS decisions advance the model conversation.
|
||||
|
||||
Explicit Realtime clients may still use `input_audio_buffer.commit` to create a
|
||||
conversation item. The translator validates that wire input before producing a
|
||||
commit carrying `item_id`. Native auto-response may already have
|
||||
commit carrying `realtime_item_id`. Native auto-response may already have
|
||||
streamed those PCM samples into the runtime, so the runner accepts a validated
|
||||
commit even when no runtime-side chunk remains. A truly empty explicit buffer
|
||||
continues to return `input_audio_buffer_empty`.
|
||||
@@ -678,7 +677,8 @@ multi-turn runtime evidence.
|
||||
|
||||
During auto-response overlap, `preserve_realtime_input` distinguishes "do not
|
||||
append this silent chunk to the native buffer" from "clear the open Realtime
|
||||
item". Silent overlap no longer discards earlier user PCM.
|
||||
item". Silent overlap no longer discards earlier user PCM. A separate explicit
|
||||
`server_vad` policy is documented in the Realtime contract above.
|
||||
|
||||
The first chunk of one overlapping input item also reserves its target model
|
||||
turn. A later Realtime commit uses that reserved identity even if response EOS
|
||||
|
||||
@@ -24,7 +24,6 @@ implementation contract; it is not, by itself, a general support claim.
|
||||
- [Async Chunk](feature/async_chunk.md)
|
||||
- [Async Diffusion Output](feature/async_diffusion_output.md)
|
||||
- [Async Omni Output Materialization](feature/omni_async_output_materialization.md)
|
||||
- [Runner-to-model Prefill/Decode Phase Contract](feature/preprocess_phase_contract.md)
|
||||
- [Automatic Prefix Caching in Omni Models](feature/prefix_caching.md)
|
||||
- [Realtime AR-Diffusion Sessions](feature/realtime_ar_diffusion.md)
|
||||
|
||||
|
||||
@@ -8,44 +8,22 @@ owners:
|
||||
- "@SamitHuang"
|
||||
- "@fhfuih"
|
||||
primary_code_paths:
|
||||
- vllm_omni/diffusion/diffusion_engine.py
|
||||
- vllm_omni/diffusion/request.py
|
||||
- vllm_omni/diffusion/data.py
|
||||
- vllm_omni/diffusion/sched/**
|
||||
- vllm_omni/diffusion/executor/**
|
||||
- vllm_omni/diffusion/worker/**
|
||||
related_code_paths:
|
||||
- vllm_omni/diffusion/stage_diffusion_client.py
|
||||
- vllm_omni/diffusion/stage_diffusion_proc.py
|
||||
- vllm_omni/diffusion/inline_stage_diffusion_client.py
|
||||
- vllm_omni/diffusion/ipc.py
|
||||
- vllm_omni/diffusion/hooks/**
|
||||
- vllm_omni/diffusion/postprocess/**
|
||||
depends_on:
|
||||
- ../engine_orchestration.md
|
||||
- ../stage_runtime.md
|
||||
- ../input_output_modality_contracts.md
|
||||
- diffusion_model_integration.md
|
||||
validation_paths:
|
||||
- tests/diffusion/test_diffusion_engine.py
|
||||
- tests/diffusion/test_diffusion_engine_cleanup.py
|
||||
- tests/diffusion/test_diffusion_engine_dummy_run.py
|
||||
- tests/diffusion/test_diffusion_engine_rpc_routing.py
|
||||
- tests/diffusion/test_diffusion_scheduler.py
|
||||
- tests/diffusion/test_diffusion_model_runner.py
|
||||
- tests/diffusion/test_diffusion_worker.py
|
||||
- tests/diffusion/test_multiproc_engine_concurrency.py
|
||||
- tests/diffusion/test_uniproc_executor.py
|
||||
- tests/diffusion/test_result_pump.py
|
||||
- tests/diffusion/test_async_output_worker.py
|
||||
- tests/diffusion/test_diffusion_ipc.py
|
||||
- tests/diffusion/test_diffusion_streaming_output.py
|
||||
- tests/diffusion/test_stage_diffusion_proc.py
|
||||
- tests/diffusion/test_inline_stage_diffusion_client.py
|
||||
- tests/diffusion/diffusion_backend/**
|
||||
- tests/diffusion/hooks/**
|
||||
upstream_refs:
|
||||
- diffusers.DiffusionPipeline
|
||||
last_reviewed: 2026-09-02
|
||||
last_verified_commit: e51fe6ec1b9a9a0e14bb1fdb296d61b6593b93c6
|
||||
last_reviewed: 2026-07-16
|
||||
---
|
||||
|
||||
# Diffusion runtime
|
||||
@@ -53,380 +31,6 @@ last_verified_commit: e51fe6ec1b9a9a0e14bb1fdb296d61b6593b93c6
|
||||
The diffusion runtime owns request admission, scheduling, execution, progress,
|
||||
output, cancellation, and cleanup inside a diffusion stage.
|
||||
|
||||
It is easiest to think of the runtime as a small control loop:
|
||||
|
||||
1. the **scheduler** chooses ready requests;
|
||||
2. the **executor** sends that choice to the worker layer;
|
||||
3. each **worker** manages its device and delegates model work to a **runner**;
|
||||
4. the runner calls the model pipeline and returns per-request results; and
|
||||
5. the engine feeds those results back to the scheduler and output streams.
|
||||
|
||||
!!! note
|
||||
|
||||
This page describes the runtime plumbing. Model loading and pipeline
|
||||
contracts belong to [Diffusion model integration](diffusion_model_integration.md).
|
||||
Batch compatibility and step-state details belong to
|
||||
[Diffusion continuous batching](continuous_batching.md).
|
||||
|
||||
## Goals and non-goals
|
||||
|
||||
The runtime aims to keep request policy separate from device execution. It
|
||||
also keeps request identity stable from admission through the final output,
|
||||
including cancellation and failures.
|
||||
|
||||
This module does **not** choose the next Omni stage, place stage replicas, or
|
||||
define a model's denoising algorithm:
|
||||
|
||||
- cross-stage routing belongs to [Engine orchestration](../engine_orchestration.md);
|
||||
- process placement and replica lifecycle belong to
|
||||
[Stage runtime](../stage_runtime.md); and
|
||||
- model-specific work belongs to
|
||||
[Diffusion model integration](diffusion_model_integration.md).
|
||||
|
||||
## Runtime at a glance
|
||||
|
||||
The stage owns `DiffusionEngine` and a `DiffusionExecutor` backend. The inline
|
||||
stage client keeps that stack in the caller process; a process-backed stage
|
||||
runs it inside `StageDiffusionProc`.
|
||||
|
||||
The executor then chooses how the worker runs:
|
||||
|
||||
- **`uni`** (default when `num_gpus == 1`): `UniProcDiffusionExecutor` builds
|
||||
one in-process worker. There is no worker subprocess and no shared-memory
|
||||
RPC.
|
||||
- **`mp`** (default when `num_gpus > 1`, or when set explicitly):
|
||||
`MultiprocDiffusionExecutor` starts one `WorkerProc` per device.
|
||||
|
||||
Either way, each worker owns its device, distributed state,
|
||||
`DiffusionWorker`, `DiffusionModelRunner`, and pipeline instance.
|
||||
|
||||
```mermaid
|
||||
flowchart TB
|
||||
client["Stage client"]
|
||||
|
||||
subgraph stage["Diffusion stage process"]
|
||||
stageProc["StageDiffusionProc<br/>stage transport and lifecycle"]
|
||||
engine["DiffusionEngine<br/>admission and control loop"]
|
||||
scheduler["RequestScheduler or StepScheduler<br/>request state and policy"]
|
||||
executor["DiffusionExecutor<br/>uni or mp backend"]
|
||||
streams["Per-request output streams"]
|
||||
|
||||
stageProc --> engine
|
||||
engine --> scheduler
|
||||
scheduler -->|"DiffusionSchedulerOutput"| engine
|
||||
engine --> executor
|
||||
engine --> streams
|
||||
end
|
||||
|
||||
subgraph workers["Worker layer"]
|
||||
workerProc["WorkerProc<br/>mp IPC loop only"]
|
||||
worker["DiffusionWorker<br/>device and distributed setup"]
|
||||
runner["DiffusionModelRunner<br/>model state and execution"]
|
||||
pipeline["Diffusion pipeline<br/>model-specific computation"]
|
||||
|
||||
workerProc --> worker
|
||||
worker --> runner --> pipeline
|
||||
end
|
||||
|
||||
client -->|"process-backed: ZMQ"| stageProc
|
||||
client -.->|"inline: direct call"| engine
|
||||
executor -->|"mp: broadcast / result queues"| workerProc
|
||||
executor -.->|"uni: in-process call"| worker
|
||||
streams -->|"process-backed"| stageProc
|
||||
stageProc -->|"ZMQ results"| client
|
||||
streams -.->|"inline"| client
|
||||
```
|
||||
|
||||
!!! info "Stage process vs worker process"
|
||||
|
||||
A deployed stage may already run in a `StageDiffusionProc` child process.
|
||||
That is separate from the optional `mp` worker processes. With `uni`, the
|
||||
worker lives in the same process as the engine.
|
||||
|
||||
## Component responsibilities
|
||||
|
||||
| Component | Owns | Does not own |
|
||||
| --- | --- | --- |
|
||||
| `DiffusionEngine` | Admission, the busy loop, scheduler/executor coordination, RPC ordering, output streams, warmup, abort routing | Batch policy details, device setup, model computation |
|
||||
| `BaseScheduler` | Request states, waiting/running sets, capacity, compatibility, terminal transitions | IPC, worker calls, output formatting |
|
||||
| `RequestScheduler` | Complete-request waves and optional admission delay for request-level batching | Denoising-step progress |
|
||||
| `StepScheduler` | Per-request denoising progress and step-wise completion | Pipeline tensors and model state |
|
||||
| `DiffusionExecutor` | Execution backend contract, worker RPC, health, shutdown | Admission and request-state transitions |
|
||||
| `UniProcDiffusionExecutor` | Single in-process worker for `num_gpus == 1`; no IPC or async output pump | Multi-GPU execution |
|
||||
| `MultiprocDiffusionExecutor` | Worker processes, shared-memory message queues, result dispatch, worker monitoring | In-process single-GPU path |
|
||||
| `WorkerProc` | One `mp` worker process's IPC loop and reply rules | Scheduling policy; unused by `uni` |
|
||||
| `DiffusionWorker` | Device/distributed setup, LoRA activation, profiling, sleep/wake, runner delegation | Request admission |
|
||||
| `DiffusionModelRunner` | Pipeline loading, request-local model state, cache/compile setup, request or step execution | Queueing and cross-stage routing |
|
||||
|
||||
The boundary between policy and execution is
|
||||
`DiffusionSchedulerOutput`. It contains newly admitted request payloads,
|
||||
IDs for requests whose runner state is already cached, finished IDs,
|
||||
optional KV-prefetch work, and per-request `diffusion_kv_metadata` on
|
||||
`NewRequestData` envelopes when paged Diffusion KV is enabled. Executors and
|
||||
workers consume this output; they do not decide what should run next.
|
||||
|
||||
`BaseScheduler.initialize()` sets `max_num_running_reqs` from
|
||||
`od_config.max_num_seqs` (default 1). The engine may override that capacity
|
||||
for distributed layerwise offload with AllGather DP concurrency.
|
||||
|
||||
## One scheduling tick
|
||||
|
||||
Async requests share one engine busy loop. Worker calls and control RPCs pass
|
||||
through that loop, so they cannot race on the executor transport.
|
||||
|
||||
```mermaid
|
||||
sequenceDiagram
|
||||
participant Caller
|
||||
participant Engine as DiffusionEngine
|
||||
participant Scheduler
|
||||
participant Executor
|
||||
participant Worker
|
||||
participant Runner
|
||||
|
||||
Caller->>Engine: add request
|
||||
Engine->>Scheduler: add_request(request)
|
||||
Engine->>Scheduler: schedule()
|
||||
Scheduler-->>Engine: DiffusionSchedulerOutput
|
||||
Engine->>Executor: execute_batch() or execute_step()
|
||||
Executor->>Worker: run worker method
|
||||
Worker->>Runner: execute model or one step
|
||||
Runner-->>Worker: RunnerOutput(s)
|
||||
Worker-->>Executor: result
|
||||
Executor-->>Engine: BaseRunnerOutput
|
||||
Engine->>Scheduler: update_from_output(...)
|
||||
Scheduler-->>Engine: finished request IDs
|
||||
Engine-->>Caller: chunk or final output
|
||||
```
|
||||
|
||||
The engine catches request execution errors and turns them into per-request
|
||||
error outputs. A dead worker group is different: the executor marks itself
|
||||
failed, health checks raise `EngineDeadError`, and the owning stage client
|
||||
handles the stage-level failure.
|
||||
|
||||
## Execution modes
|
||||
|
||||
The engine resolves one mode at startup and binds the matching scheduler and
|
||||
executor call.
|
||||
|
||||
| Mode | Scheduler | Executor call | Runner path |
|
||||
| --- | --- | --- | --- |
|
||||
| Request batch | `RequestScheduler` | `execute_batch()` | `execute_model()` for one request, or `execute_model_batch()` for a fused batch |
|
||||
| Step batch | `StepScheduler` | `execute_step()` | `execute_stepwise()` |
|
||||
|
||||
**Request mode** runs a complete pipeline forward for each scheduled wave. A
|
||||
single-request wave is the conservative path. A multi-request wave usually
|
||||
uses fused `execute_model_batch()` and requires the pipeline to declare
|
||||
request-batch support.
|
||||
|
||||
**Distributed layerwise offload with AllGather (DLO DP concurrency)** is a
|
||||
separate multiproc dispatch path. It activates when
|
||||
`data_parallel_size > 1`, `enable_distributed_layerwise_offload` is set, and
|
||||
`dlo_use_allgather` is true. The engine then sets `dp_concurrent = True` and
|
||||
raises `scheduler.max_num_running_reqs` to `dp_size`, overriding the
|
||||
`max_num_seqs` value from `initialize()`. The scheduler still emits a
|
||||
multi-request `DiffusionSchedulerOutput`; the multiproc executor routes that
|
||||
wave through `execute_request()` instead of fused `execute_model_batch()`.
|
||||
|
||||
Optional admission coalescing can fill a `dp_size` wave: when
|
||||
`request_batch_max_wait_ms > 0`, `RequestScheduler` may wait briefly before
|
||||
the first schedule of a wave (under `dp_concurrent`, the stable window is
|
||||
`min(0.3s, wait/2)`). With the default `request_batch_max_wait_ms == 0`,
|
||||
there is no wait.
|
||||
|
||||
Before dispatch, `MultiprocDiffusionExecutor.execute_request()` rejects waves
|
||||
whose requests differ in sampling-parameter compatibility or `extra_args`
|
||||
(AllGather requires every DP rank to follow the same forward schedule). Each
|
||||
worker rank then picks one envelope from the wave:
|
||||
`req[dp_rank % len(req)]`, so every rank enters the same collective while
|
||||
computing different requests.
|
||||
|
||||
**Step mode** keeps `StepRequestState` in the runner. New requests run
|
||||
`prepare_encode()` once; every tick runs `denoise_step()` and
|
||||
`step_scheduler()`; completed requests run `post_decode()`. The scheduler keeps
|
||||
only lifecycle and progress metadata—it does not hold model tensors.
|
||||
|
||||
**Step mode is also the path for streaming diffusion output**. Enabling
|
||||
`streaming_output` turns on step execution if needed. Chunk-capable pipelines
|
||||
can emit intermediate outputs through the same request stream; final-only step
|
||||
pipelines still emit only the final result. If the pipeline does not implement
|
||||
step execution, initialization fails.
|
||||
|
||||
!!! tip
|
||||
|
||||
For user-facing flags and examples, see
|
||||
[Diffusion execution modes](../../../user_guide/diffusion/execution_modes.md).
|
||||
That guide explains how to select a mode; this page explains what happens
|
||||
after the choice is made.
|
||||
|
||||
## Request state and identity
|
||||
|
||||
The scheduler is the source of truth for an admitted request. Its normal state
|
||||
flow is:
|
||||
|
||||
```mermaid
|
||||
stateDiagram-v2
|
||||
[*] --> WAITING: add_request
|
||||
WAITING --> RUNNING: schedule
|
||||
WAITING --> FINISHED_ABORTED: abort
|
||||
RUNNING --> FINISHED_ABORTED: abort
|
||||
RUNNING --> FINISHED_COMPLETED: successful output
|
||||
RUNNING --> FINISHED_ERROR: failed or missing output
|
||||
FINISHED_COMPLETED --> [*]: deliver and remove state
|
||||
FINISHED_ABORTED --> [*]: deliver and remove state
|
||||
FINISHED_ERROR --> [*]: deliver and remove state
|
||||
```
|
||||
|
||||
`PREEMPTED` and `BaseScheduler.preempt_request()` exist on the scheduler API,
|
||||
but the engine loop does not call them today—only scheduler unit tests do.
|
||||
|
||||
`request_id` ties together scheduler state, runner state, executor results, and
|
||||
the output queue. Batch positions are temporary and must never replace request
|
||||
identity when results are mapped back.
|
||||
|
||||
Only compatible requests enter the same running wave. The scheduler compares a
|
||||
mode-specific sampling-parameter key and stops at the first incompatible
|
||||
waiting request. This is intentionally conservative and can cause
|
||||
head-of-line blocking.
|
||||
|
||||
## Executor and IPC
|
||||
|
||||
`DiffusionExecutor` is the backend interface. Built-in backends are selected by
|
||||
`distributed_executor_backend`:
|
||||
|
||||
| Backend | When chosen | Worker layout |
|
||||
| --- | --- | --- |
|
||||
| `uni` | Default for `num_gpus == 1`, or set explicitly | One in-process worker |
|
||||
| `mp` | Default for `num_gpus > 1`, or set explicitly | One worker process per device |
|
||||
|
||||
Ray and external-launcher diffusion backends are not implemented. A custom
|
||||
`DiffusionExecutor` subclass or import path is also accepted.
|
||||
|
||||
### Uniproc backend
|
||||
|
||||
`UniProcDiffusionExecutor` constructs `WorkerWrapperBase` in the engine process
|
||||
and calls worker methods directly. It avoids a second model load, MessageQueue
|
||||
rings, ZMQ IPC sockets, and `/dev/shm` tensor packing. RPC timeouts are
|
||||
accepted for interface parity but are not enforced: a hung worker blocks the
|
||||
calling thread. Sticky accelerator faults mark the executor dead through
|
||||
failure callbacks; ordinary request errors stay per-request.
|
||||
|
||||
### Multiproc backend
|
||||
|
||||
`MultiprocDiffusionExecutor`:
|
||||
|
||||
1. creates a broadcast queue shared by all workers;
|
||||
2. spawns one worker process per configured device;
|
||||
3. waits until every worker reports ready;
|
||||
4. sends generation and control calls as RPC messages;
|
||||
5. applies rank-aware reply rules so only expected ranks respond; and
|
||||
6. monitors worker process sentinels and fails the executor if a worker dies.
|
||||
|
||||
In request mode on this backend, each async output produces two correlated
|
||||
messages keyed by `async_output_id`:
|
||||
|
||||
- `COMPUTE_DONE` — the forward finished and the device can start the next
|
||||
request.
|
||||
- `OUTPUT_READY` — background D2H/SHM packing finished and the final output
|
||||
is ready.
|
||||
|
||||
The worker queues background packing work before it enqueues `COMPUTE_DONE`,
|
||||
but either message may reach the executor first. The result pump and
|
||||
`execute_batch()` must handle both orderings. Step mode keeps the synchronous
|
||||
result path and does not start those pumps.
|
||||
|
||||
See [Async diffusion output](../../feature/async_diffusion_output.md) for the
|
||||
multiproc request-mode timeline.
|
||||
|
||||
## Worker and runner boundary
|
||||
|
||||
On the `mp` path, `WorkerProc` receives messages and calls methods through
|
||||
`WorkerWrapperBase`. On the `uni` path, the executor owns that wrapper
|
||||
directly. In both cases, `DiffusionWorker` handles the parts tied to a device:
|
||||
distributed initialization, model-runner construction, LoRA activation,
|
||||
profiling, and memory sleep/wake. It delegates actual model work to
|
||||
`DiffusionModelRunner`.
|
||||
|
||||
The runner owns long-lived model-side state:
|
||||
|
||||
- the loaded pipeline and compilation setup;
|
||||
- cache and offload integration;
|
||||
- random-generator setup;
|
||||
- request batches for complete forwards; and
|
||||
- `StepRequestState` plus `InputBatch` for step execution.
|
||||
|
||||
This split keeps infrastructure out of model pipelines. A pipeline receives a
|
||||
request batch or step state and performs model work; it should not inspect
|
||||
engine queues or change scheduler state.
|
||||
|
||||
## Lifecycle and cleanup
|
||||
|
||||
### Startup
|
||||
|
||||
`DiffusionEngine.make_engine()` resolves the engine class, constructs the
|
||||
executor and scheduler, then normally runs a small dummy request to warm up the
|
||||
model.
|
||||
|
||||
Warmup is skipped only when distributed layerwise offload with AllGather
|
||||
is enabled (via `enable_distributed_layerwise_offload` and `dlo_use_allgather`)
|
||||
and `max(data_parallel_size, sequence_parallel_size) > 1`, because
|
||||
the dummy run sends one request while AllGather needs every shard rank to
|
||||
enter the same collective. If initialization or warmup fails, the runtime
|
||||
closes scheduler state and worker resources before returning the error.
|
||||
|
||||
### Cancellation
|
||||
|
||||
`abort()` places request IDs on an abort queue. The busy loop marks those
|
||||
requests `FINISHED_ABORTED`; finalization removes scheduler state and emits an
|
||||
aborted output when a consumer still exists. The runner removes cached
|
||||
step-mode state when it receives a scheduler output that reports the finished
|
||||
request ID.
|
||||
|
||||
On the multiproc request-mode async path, abort or consumer drop while output
|
||||
is still materializing should release the associated async-output bookkeeping
|
||||
so late results are not retained after the request ends
|
||||
*(pending #6253/#6439/#6580)*. Today, an unconsumed `OUTPUT_READY` is cached
|
||||
by design until `wait_output_ready()` or executor teardown. Dropping an
|
||||
output-stream consumer removes that consumer's queue. It does not take
|
||||
ownership of scheduler cleanup.
|
||||
|
||||
### Shutdown and worker failure
|
||||
|
||||
`DiffusionEngine.close()` is idempotent. It stops the busy loop, wakes pending
|
||||
streams with an error, closes scheduler state, and shuts down the executor.
|
||||
|
||||
- **`mp`**: the executor asks workers to stop, waits for them, then terminates
|
||||
workers that miss the grace period. Shutdown marks unfinished RPC and
|
||||
async-output futures as failed, then clears them. Completed async outputs
|
||||
cached for later `wait_output_ready()` calls are dropped with the executor
|
||||
object.
|
||||
- **`uni`**: the executor shuts down the in-process worker, drops the final
|
||||
model reference, and empties the accelerator cache so a later engine can reuse
|
||||
the device.
|
||||
|
||||
!!! warning
|
||||
|
||||
Do not continue using a worker group after a fatal collective timeout or
|
||||
unexpected worker exit. Distributed state may be incomplete. The
|
||||
multiprocess executor deliberately fails closed so the stage can restart.
|
||||
The uniproc executor fails closed when the accelerator context itself is
|
||||
poisoned.
|
||||
|
||||
## Extension boundaries
|
||||
|
||||
- A custom engine may set `default_diffusion_model_runner_cls`; an explicit
|
||||
`diffusion_model_runner_cls` configuration still wins.
|
||||
- Tests and custom engine integrations may inject a `BaseScheduler` subclass.
|
||||
`SchedulerInterface` remains only as a deprecated compatibility name.
|
||||
- `distributed_executor_backend` may be `"uni"`, `"mp"`, a custom `DiffusionExecutor`
|
||||
subclass, or an import path. A backend must preserve scheduler output,
|
||||
request identity, health, and cleanup contracts. Use `"mp"` when you need
|
||||
process isolation or multi-GPU; `"uni"` is the single-GPU default.
|
||||
- Worker extensions go through `WorkerWrapperBase`. They add worker methods;
|
||||
they do not become a second scheduler or request lifecycle.
|
||||
|
||||
These are advanced Python integration points, not stable end-user CLI
|
||||
customization surfaces.
|
||||
|
||||
## Candidate invariants
|
||||
|
||||
### DIFF-RUNTIME-INV-001: One lifecycle owner
|
||||
@@ -437,50 +41,19 @@ until completion, cancellation, or failure.
|
||||
### DIFF-RUNTIME-INV-002: Execution follows scheduler output
|
||||
|
||||
**Rule:** Executors and workers MUST execute scheduler decisions without
|
||||
admitting, reordering, or forwarding requests independently. Distributed
|
||||
layerwise offload with AllGather is an exception at dispatch time: the
|
||||
scheduler may schedule a multi-request wave, but each DP rank executes one
|
||||
envelope from that wave so every rank enters the same collective schedule.
|
||||
admitting, reordering, or forwarding requests independently.
|
||||
|
||||
### DIFF-RUNTIME-INV-003: Terminal cleanup is complete
|
||||
|
||||
**Rule:** Every terminal path MUST release request state, temporary tensors,
|
||||
hooks, and runtime-owned resources. Async-output bookkeeping on abort or
|
||||
consumer drop before consumption is also required *(pending #6253/#6439/#6580)*.
|
||||
hooks, and runtime-owned resources.
|
||||
|
||||
### DIFF-RUNTIME-INV-004: Optional features use runtime hooks
|
||||
|
||||
**Rule:** Cache, profiling, offload, and parallel features SHOULD integrate at
|
||||
defined hooks instead of creating another request lifecycle.
|
||||
|
||||
### DIFF-RUNTIME-INV-005: Results keep request identity
|
||||
|
||||
**Rule:** Batched and asynchronous results MUST be mapped by stable request ID,
|
||||
not by assumed completion order.
|
||||
|
||||
## Safe-change guide
|
||||
|
||||
Test the smallest affected slice, then cover its neighboring boundary:
|
||||
|
||||
| Change area | Minimum evidence |
|
||||
| --- | --- |
|
||||
| Admission or state transitions | `test_diffusion_scheduler.py`, including duplicate IDs, compatibility, abort, and missing output |
|
||||
| Engine loop or output delivery | `test_diffusion_engine.py`, `test_diffusion_engine_cleanup.py`, `test_diffusion_engine_rpc_routing.py` |
|
||||
| Executor or IPC | `test_multiproc_engine_concurrency.py`, `test_uniproc_executor.py`, `test_result_pump.py`, `test_diffusion_ipc.py`, `test_async_output_worker.py` |
|
||||
| Worker or runner | `test_diffusion_worker.py`, `test_diffusion_model_runner.py` |
|
||||
| Stage boundary | `test_stage_diffusion_proc.py`, `test_inline_stage_diffusion_client.py` |
|
||||
| Warmup or streaming | `test_diffusion_engine_dummy_run.py`, `test_diffusion_streaming_output.py` |
|
||||
|
||||
Always exercise success, cancellation, per-request failure, fatal worker
|
||||
failure, repeated shutdown, one request, and multiple compatible requests.
|
||||
For step-mode changes, also test partial progress and cleanup of runner state.
|
||||
|
||||
## Related documents
|
||||
|
||||
- [Diffusion module overview](index.md)
|
||||
- [Diffusion model integration](diffusion_model_integration.md)
|
||||
- [Diffusion continuous batching](continuous_batching.md)
|
||||
- [Diffusion execution modes](../../../user_guide/diffusion/execution_modes.md)
|
||||
- [Async diffusion output](../../feature/async_diffusion_output.md)
|
||||
- [Engine orchestration](../engine_orchestration.md)
|
||||
- [Stage runtime](../stage_runtime.md)
|
||||
Test success, cancellation, failure, shutdown, multiple requests, and resource
|
||||
cleanup.
|
||||
@@ -124,7 +124,6 @@ def extract_omni_serve_subparser_init():
|
||||
"make_arg_parser": lambda parser: parser, # no-op for doc
|
||||
"_ensure_vllm_platform": lambda: None, # no-op for doc
|
||||
"_nonneg_finite_float": float,
|
||||
"_parse_stage_overrides": __import__("json").loads,
|
||||
"VLLM_SUBCMD_PARSER_EPILOG": "",
|
||||
"logger": logger,
|
||||
"DummySubparsers": DummySubparsers,
|
||||
|
||||
@@ -64,7 +64,6 @@ th {
|
||||
| `LongCatImageEditPipeline` | LongCat-Image-Edit | `meituan-longcat/LongCat-Image-Edit` | ✅︎ | ✅︎ | ✅︎ | ✅︎ | — |
|
||||
| `LongCatVideoAvatarPipeline` | LongCat-Video-Avatar-1.5 A2V/AI2V (native single-speaker and multi-speaker AI2V/AVC) | `meituan-longcat/LongCat-Video-Avatar-1.5` | ✅︎ | | | | [Repository](https://github.com/vllm-project/vllm-omni/blob/main/recipes/meituan-longcat/LongCat-Video-Avatar-1.5.md) |
|
||||
| `BooguImagePipeline` | Boogu-Image | `Boogu/Boogu-Image-0.1-Base`, `Boogu/Boogu-Image-0.1-Edit`, `Boogu/Boogu-Image-0.1-Edit-Turbo` | ✅︎ | | | ✅︎ | [Repository](https://github.com/vllm-project/vllm-omni/blob/main/recipes/Boogu/Boogu-Image.md) |
|
||||
| `BooguImageTurboPipeline` | Boogu-Image Turbo distilled T2I | `Boogu/Boogu-Image-0.1-Turbo` | ✅︎ | | | | [Repository](https://github.com/vllm-project/vllm-omni/blob/main/recipes/Boogu/Boogu-Image.md) |
|
||||
| `StableDiffusionXLPipeline` | Stable-Diffusion-XL | `stabilityai/stable-diffusion-xl-base-1.0` | ✅︎ | ✅︎ | ✅︎ | ✅︎ | — |
|
||||
| `StableDiffusion3Pipeline` | Stable-Diffusion-3 | `stabilityai/stable-diffusion-3.5-medium` | ✅︎ | ✅︎ | | ✅︎ | — |
|
||||
| `CosyVoice3Model` | CosyVoice3 | `FunAudioLLM/Fun-CosyVoice3-0.5B-2512` | ✅︎ | ✅︎ | | ✅︎ | — |
|
||||
@@ -97,7 +96,6 @@ th {
|
||||
| `MiMoV2ASRForCausalLM` | MiMo-V2.5-ASR | `XiaomiMiMo/MiMo-V2.5-ASR` | ✅︎ | ✅︎ | | | — |
|
||||
| `Flux2Pipeline` | FLUX.2-dev | `black-forest-labs/FLUX.2-dev` | ✅︎ | ✅︎ | | | — |
|
||||
| `FishSpeechSlowARForConditionalGeneration` | Fish Speech S2 Pro | `fishaudio/s2-pro` | ✅︎ | ✅︎ | | ✅︎ | — |
|
||||
| `Audio8TTSSlowARForConditionalGeneration` | Audio8 TTS Preview | `Audio8/Audio8-TTS-Preview-0.6b` | ✅︎ | | | | — |
|
||||
| `SenseNovaU1Pipeline` | SenseNova-U1 (DiT-only), SenseNova-U1.5 | `SenseNova/SenseNova-U1-8B-MoT`, `sensenova/SenseNova-U1.5-8B-MoT` | ✅︎ | | | | [Repository](https://github.com/vllm-project/vllm-omni/blob/main/recipes/SenseNova/SenseNova-U1.5.md) |
|
||||
| `LancePipeline` | Lance | `bytedance-research/Lance` | ✅︎ | | | | — |
|
||||
| `HunyuanVideo15Pipeline` | HunyuanVideo-1.5-T2V | `hunyuanvideo-community/HunyuanVideo-1.5-Diffusers-480p_t2v`, `hunyuanvideo-community/HunyuanVideo-1.5-Diffusers-720p_t2v` | ✅︎ | ✅︎ | | | — |
|
||||
|
||||
@@ -64,7 +64,7 @@ connect
|
||||
<- msgpack(policy_server_config)
|
||||
|
||||
infer
|
||||
-> msgpack({"endpoint": "infer", "session_id": "...", "seed": <optional int>, ...observation})
|
||||
-> msgpack({"endpoint": "infer", "session_id": "...", ...observation})
|
||||
<- msgpack(ndarray | dict[str, ndarray])
|
||||
|
||||
reset
|
||||
@@ -92,12 +92,6 @@ frames are not observation messages.
|
||||
- The policy pipeline owns observation transforms and persistent model state,
|
||||
normally keyed by `session_id`; the API layer forwards the raw observation
|
||||
dictionary.
|
||||
- An optional integer `seed` in an inference message becomes the engine
|
||||
request's `sampling_params.seed`. A policy whose sampling consumes the
|
||||
request generator (GR00T-N1.7) returns the same action chunk for the same
|
||||
observation and seed. If omitted, the engine assigns a random per-request
|
||||
seed, so unseeded inferences are independent of each other. The API layer
|
||||
consumes `seed`; it is not forwarded inside the observation.
|
||||
|
||||
## Limits and Errors
|
||||
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
# Realtime Duplex API
|
||||
|
||||
vLLM-Omni serves full-duplex speech models over a WebSocket endpoint,
|
||||
`/v1/realtime`, that speaks the OpenAI Realtime vocabulary plus a
|
||||
`/v1/realtime?duplex=1`, that speaks the OpenAI Realtime vocabulary plus a
|
||||
set of duplex extensions: the model decides when to listen and when to speak,
|
||||
the user can talk over the assistant, playback progress is reported back so
|
||||
history stays honest, and a dropped connection can resume the same session.
|
||||
This page covers how to run a duplex deployment, how to drive it from Python
|
||||
with `vllm_omni.clients.duplex.DuplexClient`, and the complete wire contract.
|
||||
|
||||
The handler is enabled by either a model-native `session_mode: duplex`
|
||||
deployment or an explicit `duplex_session` configuration for turn-based
|
||||
Server VAD. The runtime architecture is described in
|
||||
[Full-Duplex Runtime (MiniCPM-o 4.5)](../design/fullduplex.md).
|
||||
The endpoint is served for models that ship a duplex plugin — currently
|
||||
MiniCPM-o 4.5, PersonaPlex, and Nemotron VoiceChat — and only for deploy
|
||||
configurations that declare `session_mode: duplex`. The runtime architecture
|
||||
is described in [Full-Duplex Runtime (MiniCPM-o 4.5)](../design/fullduplex.md).
|
||||
|
||||
## Quick Start
|
||||
|
||||
@@ -27,7 +27,7 @@ vllm-omni serve openbmb/MiniCPM-o-4_5 \
|
||||
|
||||
`vllm_omni/deploy/minicpmo_4_5.yaml` declares `session_mode: duplex` and
|
||||
`duplex_session.max_sessions: 4`, which mounts the WebSocket routes
|
||||
`ws://<host>:8099/v1/realtime` (this page) and `ws://<host>:8099/v1/duplex`
|
||||
`ws://<host>:8099/v1/realtime?duplex=1` (this page) and `ws://<host>:8099/v1/duplex`
|
||||
(the native dialect for raw-protocol clients) next to the usual HTTP API.
|
||||
PersonaPlex and Nemotron VoiceChat use `vllm_omni/deploy/personaplex.yaml` and
|
||||
`vllm_omni/deploy/nemotron_labs_voicechat_duplex.yaml` in the same way.
|
||||
@@ -240,7 +240,7 @@ on the same helpers.
|
||||
|
||||
## API Reference
|
||||
|
||||
This section is the complete wire contract of `/v1/realtime`: how
|
||||
This section is the complete wire contract of `/v1/realtime?duplex=1`: how
|
||||
the dialect relates to the OpenAI Realtime protocol, which surfaces each
|
||||
model's capability flags gate, a catalogue of every client-to-server and
|
||||
server-to-client event, and a JSON example for each. `DuplexClient` speaks
|
||||
@@ -253,11 +253,10 @@ its protocol tests.
|
||||
|
||||
### Endpoint and transport
|
||||
|
||||
The endpoint is `ws(s)://<host>/v1/realtime`. Bare connections select the
|
||||
session handler when the deployment declares either `session_mode: duplex`
|
||||
or `duplex_session`. `?duplex=1` remains a compatibility alias, while
|
||||
`?duplex=0` selects the legacy Realtime handler. Optional query parameters
|
||||
are `model`, `session_id`,
|
||||
The endpoint is `ws(s)://<host>/v1/realtime?duplex=1`; the `duplex` query
|
||||
parameter (`1`, `true`, or `on`) selects the duplex session handler, and the
|
||||
route is mounted only for deployments whose deploy configuration declares
|
||||
`session_mode: duplex`. Optional query parameters are `model`, `session_id`,
|
||||
`autostart` (`0` means resume-only), `resume`, and `native_duplex`
|
||||
(`minicpmo45_native_duplex` is accepted as a deprecated alias and folded
|
||||
into the canonical name). Every message is one JSON object per WebSocket
|
||||
@@ -343,14 +342,9 @@ Semantic divergences hidden behind shared names:
|
||||
before any commit; a commit may end in `response.listen` and no
|
||||
response, and the model may open a response with no commit at all.
|
||||
OpenAI: commit ⇒ item, `response.create` ⇒ exactly one response.
|
||||
- With `turn_detection={"type":"server_vad"}`, omitted `interrupt_response`
|
||||
defaults to `false` on turn-based models such as Qwen3-Omni, enabling
|
||||
endpointing and automatic responses without interruption. Explicit `true`
|
||||
is rejected there. Model-native duplex keeps the `true` default and rejects
|
||||
`false`; its VAD implies `overlap_policy=barge_in_on_speech`.
|
||||
This capability-dependent default differs from OpenAI's `true` default;
|
||||
the effective configuration is returned in `session.created` / `session.updated`.
|
||||
`semantic_vad` is unsupported.
|
||||
- `turn_detection.interrupt_response=false` is rejected;
|
||||
`create_response` is ignored; `semantic_vad` is unsupported; the VAD
|
||||
runs per session (Silero) and implies `overlap_policy=barge_in_on_speech`.
|
||||
- `rate_limits.updated` is always an empty list (compatibility only).
|
||||
- Cancellation never reuses a `response_id`; truncation is driven by
|
||||
`playback.ack` as well as `conversation.item.truncate`.
|
||||
@@ -1207,10 +1201,9 @@ Realtime projector renames and fans out these events before they reach a
|
||||
barge-in, or audio truncation; Nemotron VoiceChat does not support barge-in
|
||||
or audio truncation; camera frames are consumed only by MiniCPM-o 4.5; tool
|
||||
calls are produced only by Nemotron VoiceChat.
|
||||
- `turn_detection` supports `server_vad` or `null`, not `semantic_vad`.
|
||||
Turn-based models support endpointing without interruption, including
|
||||
`create_response=false` for explicit response creation. Model-native duplex
|
||||
requires `interrupt_response=true` and `create_response=true`.
|
||||
- `turn_detection` supports only `server_vad` with `interrupt_response=true`;
|
||||
`semantic_vad`, `interrupt_response=false`, and `create_response` are not
|
||||
supported. Server VAD requires a model-native session.
|
||||
- `input_audio_transcription` and `input_audio_noise_reduction` are accepted
|
||||
and echoed but no separate transcription or noise-reduction stage runs;
|
||||
transcripts come from the model.
|
||||
|
||||
+12
-31
@@ -279,15 +279,10 @@ curl -X POST http://localhost:8091/v1/audio/voices \
|
||||
|
||||
## Streaming Text Input (WebSocket)
|
||||
|
||||
The `/v1/audio/speech/stream` WebSocket endpoint accepts text incrementally.
|
||||
By default (`split_granularity=none`) it buffers until `input.done` and
|
||||
synthesizes that flush as **one** TTS request, which keeps long-form timbre
|
||||
stable. Set `split_granularity` to `sentence` or `clause` to emit a request
|
||||
at each detected boundary (lower time-to-first-audio for STT/LLM pipelines).
|
||||
The `/v1/audio/speech/stream` WebSocket endpoint accepts text incrementally and generates audio per sentence as boundaries are detected.
|
||||
|
||||
> Note: `stream_audio` only changes how **audio bytes** are framed (one WAV/PCM
|
||||
> payload vs chunked PCM). Text segmentation is controlled separately by
|
||||
> `split_granularity`.
|
||||
> Note: text input is always streamed incrementally. Audio output remains sentence-scoped:
|
||||
> use `stream_audio=false` for one binary frame per sentence, or `stream_audio=true` for one or more PCM chunks per sentence.
|
||||
|
||||
### WebSocket Protocol
|
||||
|
||||
@@ -319,16 +314,14 @@ upstream LLM) pays the WebSocket handshake once instead of once per utterance.
|
||||
|
||||
- The session config is sticky. Send `input.text` again straight after
|
||||
`session.done` to reuse it, or send another `session.config` first to change
|
||||
voice, format, or reference audio. A `session.config` sent in the middle of
|
||||
an utterance is rejected so no pending input is silently dropped and so a
|
||||
split utterance cannot end up half in one voice and half in another.
|
||||
- An utterance is the flush unit, not a linguistic one: it is one `input.done`
|
||||
cycle. `utterance_index` counts those flushes across the connection, so it
|
||||
tells you which `input.done` a frame belongs to. `sentence_index` counts the
|
||||
TTS requests inside one flush and so pairs with `total_sentences`: with the
|
||||
default `split_granularity=none` that is always `sentence_index: 0` of
|
||||
`total_sentences: 1` (or `0` for an empty buffer), while `sentence` or
|
||||
`clause` counts the linguistic units actually synthesized.
|
||||
voice, format, or reference audio. A `session.config` sent while text is
|
||||
still buffered is rejected so no pending input is silently dropped.
|
||||
- An utterance is the flush unit, not a linguistic one: it is whatever text was
|
||||
buffered when `input.done` arrived, of any length, synthesized as one request.
|
||||
`utterance_index` counts those flushes across the connection, so it tells you
|
||||
which `input.done` a frame belongs to. `sentence_index` counts within one
|
||||
flush and so pairs with `total_sentences`, which means every utterance reports
|
||||
`sentence_index: 0` of `total_sentences: 1` (or `0` for an empty buffer).
|
||||
- End the connection with `session.close`, or by closing the socket. An idle
|
||||
connection is still closed after the server's idle timeout, which now also
|
||||
applies to the gap between utterances.
|
||||
@@ -339,15 +332,7 @@ All REST API parameters are supported, plus:
|
||||
|
||||
| Parameter | Type | Default | Description |
|
||||
| ----------- | ------ | --------- | ------------- |
|
||||
| `stream_audio` | bool | false | Stream one or more PCM chunks for each TTS request over WebSocket |
|
||||
| `split_granularity` | string | `"none"` | `"none"`: one request per `input.done`. `"sentence"`: split on `.!?` plus CJK `。!?…`, Indic danda `।॥`, and Arabic `؟`. `"clause"`: also split on `,;,;،؛`. |
|
||||
| `seed` | integer | null | Forwarded to the speech engine for this session |
|
||||
|
||||
ASCII punctuation only ends a unit when whitespace or `input.done` follows it,
|
||||
and decimals (`3.14`), thousands separators (`1,000`), abbreviations (`Dr.`,
|
||||
`e.g.`) and initials (`J. R.`) are not treated as boundaries. A punctuation run
|
||||
and any closing quote or bracket stay with the unit they close, so `Wait...`
|
||||
and `He said "Hello."` are one request each.
|
||||
| `stream_audio` | bool | false | Stream one or more PCM chunks for the buffered input over WebSocket |
|
||||
|
||||
```bash
|
||||
DELETE /v1/audio/voices/{name}
|
||||
@@ -767,10 +752,6 @@ Fish Speech uses `ref_audio` and `ref_text` for voice cloning (no `task_type` ne
|
||||
| ------- | ------------- |
|
||||
| `k2-fsa/OmniVoice` | Pure-diffusion TTS. Supports voice cloning via `ref_audio` (with optional `ref_text`); no built-in voice presets. |
|
||||
|
||||
OmniVoice uses packed variable-length attention for batched generator execution. The attention operator accepts FP16 and BF16 inputs, so its query,
|
||||
key, and value tensors are evaluated in BF16 even when the stage is configured with `dtype: float32`; the attention output is converted back to the model's
|
||||
hidden-state dtype before the output projection. Consequently, a float32 stage configuration does not imply FP32 attention arithmetic.
|
||||
|
||||
### VoxCPM2
|
||||
|
||||
| Model | Description |
|
||||
|
||||
@@ -68,8 +68,6 @@ curl -L "http://localhost:8091/v1/videos/${video_id}/content" -o output.mp4
|
||||
| Parameter | Type | Default | Description |
|
||||
| ----------- | ------ | --------- | ------------- |
|
||||
| `input_reference` | file | null | Uploaded reference image or video for image-to-video/video-to-video requests |
|
||||
| `control_reference` | file | null | Optional uploaded image/video control, up to 512 MiB, for models that declare control-upload support |
|
||||
| `control_type` | string | null | Model control name associated with `control_reference`; currently Cosmos3 supports `edge`, `blur`, `depth`, `seg`, and `wsm` |
|
||||
| `image_reference` | string | null | JSON-encoded reference image payload; do not combine with `input_reference` or `video_reference` |
|
||||
| `video_reference` | string | null | JSON-encoded reference video payload; do not combine with `input_reference` or `image_reference` |
|
||||
| `audio_reference` | string | null | JSON-encoded audio reference for speech-to-video: `{"audio_url": "..."}` — supports HTTP(s) URLs or base64 data URLs |
|
||||
@@ -179,23 +177,6 @@ corresponding addition. `negative_metadata_mode` accepts `same`, `inverse`, or
|
||||
`none` and defaults to `same` for transfer. See the Cosmos3 recipe for complete
|
||||
examples.
|
||||
|
||||
A client that cannot place the control on the server filesystem can upload one
|
||||
control with `control_reference` and identify it with `control_type`. The API
|
||||
streams the upload to request-scoped storage, supplies its path to the model,
|
||||
and removes it after synchronous or asynchronous generation completes. Other
|
||||
options for the selected control can remain in `extra_params`; do not also set
|
||||
`control` or `control_path` there. Uploads larger than 512 MiB are rejected.
|
||||
|
||||
```bash
|
||||
curl -s http://localhost:8091/v1/videos/sync \
|
||||
-F "prompt=Preserve the scene while following the world-state control" \
|
||||
-F "input_reference=@input.mp4;type=video/mp4" \
|
||||
-F "control_reference=@wsm.mp4;type=video/mp4" \
|
||||
-F "control_type=wsm" \
|
||||
-F 'extra_params={"wsm":{"control_weight":1.0}}' \
|
||||
-o output.mp4
|
||||
```
|
||||
|
||||
HTTP redirects for `image_reference.image_url` follow vLLM's
|
||||
`VLLM_MEDIA_URL_ALLOW_REDIRECTS` setting. Before starting the server, set it to
|
||||
`1` (the default) to allow redirects or `0` to reject them. A redirect target
|
||||
|
||||
@@ -12,7 +12,7 @@ implementations to reduce numerical drift and sampling divergence.
|
||||
## Installation
|
||||
|
||||
```bash
|
||||
pip install kernels==0.16.1
|
||||
pip install kernels==0.15.2
|
||||
```
|
||||
|
||||
If `kernels` is unavailable, an explicit `FLASH_ATTN_HUB` or
|
||||
|
||||
@@ -8,7 +8,7 @@ are exposed.
|
||||
## Choose a Mode
|
||||
|
||||
| Goal | CLI configuration |
|
||||
| --- | --- |
|
||||
|---|---|
|
||||
| Serial request execution | `--max-num-seqs 1` |
|
||||
| Fused request-level batching | `--max-num-seqs N` |
|
||||
| Single-request step execution | `--step-execution --max-num-seqs 1` |
|
||||
@@ -177,10 +177,8 @@ wait
|
||||
The scheduler may batch these requests when their sampling parameters are
|
||||
compatible. See the
|
||||
[Image Generation API](../../serving/image_generation_api.md) for response
|
||||
formats and additional client examples.
|
||||
|
||||
Streaming models can use model-specific streaming endpoints documented at
|
||||
[Streaming Video Output API](../../serving/streaming_video_output_api.md).
|
||||
formats and additional client examples. Streaming models can use
|
||||
model-specific streaming endpoints documented by their serving guide.
|
||||
|
||||
## Python API
|
||||
|
||||
@@ -243,7 +241,7 @@ For step execution, set `step_execution: true` and remove
|
||||
## CLI Reference
|
||||
|
||||
| Flag | Default | Effect |
|
||||
| --- | ---: | --- |
|
||||
|---|---:|---|
|
||||
| `--step-execution` | disabled | Select step-wise scheduling |
|
||||
| `--max-num-seqs` | `1` for diffusion stages | Set request- or step-scheduler capacity |
|
||||
| `--request-batch-max-wait-ms` | `0` | Wait for burst coalescing in request mode |
|
||||
|
||||
@@ -249,14 +249,8 @@ MiniMax-H3 supports two few-step mechanisms that must not be conflated:
|
||||
- **Checkpoint-pinned schedule**: a merged release writes `base_schedule` into
|
||||
`model_index.json`. Requests must pass `num_inference_steps` as the interval
|
||||
count (for example `4` for `[1.0, 0.7, 0.4, 0.15, 0.0]`).
|
||||
- **Runtime Turbo LoRA**: each LightX2V Turbo artifact carries its own contract,
|
||||
read from its filename. A four-step artifact requests five sigma points and an
|
||||
eight-step one requests nine; the 768p retrains enforce `flow_shift=6` and the
|
||||
544p artifacts `flow_shift=12`. `audio_flow_shift=3` across the family. A
|
||||
request that does not match the loaded artifact is rejected by name. Alpha
|
||||
comes from the artifact's metadata, or 8 when it declares none. `ref2v`
|
||||
artifacts require `--task-type ref2va`; `fl2v` artifacts serve T2VA and FL2VA.
|
||||
The ComfyUI exports use a fused-QKV layout and are not supported.
|
||||
- **Runtime Turbo LoRA**: LightX2V Turbo artifacts request five sigma points and
|
||||
enforce `flow_shift=6`, `audio_flow_shift=3`.
|
||||
- **Runtime native LoRA**: FlashGen-style artifacts declare
|
||||
`key_format=minimax-h3-native` and embed `base_schedule` in safetensors
|
||||
metadata. When active, the adapter schedule overrides the base checkpoint and
|
||||
|
||||
@@ -162,9 +162,9 @@ The following tables show which models support each feature:
|
||||
| **Wan2.2** | ❌ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ (encode/decode) | ❌ | ❌ |
|
||||
| **Wan2.2-S2V** | ❌ | ✅ | ✅ | ✅ | ✅ | ❌ | ✅ | ✅ | ✅ (encode/decode) | ❌ | ❌ |
|
||||
| **Wan2.1-VACE** | ❌ | ✅ | ✅ | ✅ | ✅ | ❌ | ✅ | ✅ | ✅ (decode) | ❌ | ❌ |
|
||||
| **LTX-2** | ❌ | ✅ | ✅ (Ulysses only) | ✅ | ✅ | ❌ | ✅ | ✅ | ✅ (decode) | ❌ | ❌ |
|
||||
| **LTX-2.3** | ❌ | ✅ | ✅ (Ulysses only) | ✅ | ✅ | ❌ | ✅ | ✅ | ✅ (decode) | ❌ | ❌ |
|
||||
| **LTX-2.5** | ❌ | ❓ (one-stage) | ✅* (Ulysses only) | ✅ (Full only) | ❓ | ❌ | ✅ | ✅ | ✅ (decode) | ❓ (FP8) | ❌ |
|
||||
| **LTX-2** | ❌ | ✅ | ✅ | ✅ | ✅ | ❌ | ✅ | ✅ | ✅ (decode) | ❌ | ❌ |
|
||||
| **LTX-2.3** | ❌ | ✅ | ✅ | ✅ | ✅ | ❌ | ✅ | ✅ | ✅ (decode) | ❌ | ❌ |
|
||||
| **LTX-2.5** | ❌ | ❓ (one-stage) | ❓ (Ulysses only) | ✅ (Full only) | ❓ | ❌ | ✅ | ✅ | ✅ (decode) | ❓ (FP8) | ❌ |
|
||||
| **SANA-Video-2B T2V I2V** | ❌ | ❌ | ✅ (`--usp`, frame-sharded) | ✅ | ✅ (TP=2 only) | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ |
|
||||
| **Helios** | ❌ | ✅ | ✅ | ✅ | ✅ | ❌ | ✅ | ✅ | ❌ | ❌ | ✅* |
|
||||
| **HunyuanVideo-1.5 T2V I2V** | ❌ | ✅ | ✅ | ✅ | ✅ | ❌ | ✅ | ✅ | ✅ (encode/decode) | ✅ | ❌ |
|
||||
|
||||
@@ -126,7 +126,11 @@ python examples/offline_inference/text_to_speech/cosyvoice3/end2end.py \
|
||||
## Fish Speech S2 Pro
|
||||
|
||||
4B dual-AR text-to-speech model from FishAudio with the DAC codec at 44.1 kHz.
|
||||
No extra packages are required; the DAC codec is vendored in vLLM-Omni.
|
||||
|
||||
### Prerequisites
|
||||
```bash
|
||||
pip install fish-speech
|
||||
```
|
||||
|
||||
### Quick start
|
||||
```bash
|
||||
|
||||
@@ -155,8 +155,13 @@ The client supports `--api-base`, `--model`, `--text`, `--ref-audio`, `--ref-tex
|
||||
|
||||
## Fish Speech S2 Pro
|
||||
|
||||
4B dual-AR TTS at 44.1 kHz. Server uses the DAC codec, which is vendored in
|
||||
vLLM-Omni (no extra packages required).
|
||||
4B dual-AR TTS at 44.1 kHz. Server uses the DAC codec.
|
||||
|
||||
### Prerequisites
|
||||
|
||||
```bash
|
||||
pip install fish-speech
|
||||
```
|
||||
|
||||
### Launch
|
||||
|
||||
|
||||
@@ -30,6 +30,7 @@ from typing import Any
|
||||
import numpy as np
|
||||
|
||||
_MODEL = "robbyant/lingbot-world-v2-14b-causal-fast-diffusers"
|
||||
_NUM_INFERENCE_STEPS = 4
|
||||
_MAX_SEQUENCE_LENGTH = 512
|
||||
_MAX_PIXEL_AREA = 480 * 832
|
||||
_MAX_RAW_FRAMES = 117
|
||||
@@ -208,6 +209,7 @@ def build_request(
|
||||
"height": args.height,
|
||||
"width": args.width,
|
||||
"num_frames": args.num_frames,
|
||||
"num_inference_steps": _NUM_INFERENCE_STEPS,
|
||||
"max_sequence_length": _MAX_SEQUENCE_LENGTH,
|
||||
"seed": args.seed,
|
||||
"fps": args.fps,
|
||||
|
||||
@@ -155,6 +155,7 @@ async def run(argv: Sequence[str] | None = None) -> Path:
|
||||
height=args.height,
|
||||
width=args.width,
|
||||
num_frames=9,
|
||||
num_inference_steps=4,
|
||||
max_sequence_length=512,
|
||||
seed=args.seed,
|
||||
output_type="latent",
|
||||
|
||||
@@ -5,12 +5,10 @@ This example shows how to use vLLM-Omni for running offline inference
|
||||
with the correct prompt format on Qwen2.5-Omni
|
||||
"""
|
||||
|
||||
import argparse
|
||||
import functools
|
||||
import json
|
||||
import os
|
||||
import time
|
||||
from typing import Any, NamedTuple
|
||||
from typing import NamedTuple
|
||||
|
||||
import numpy as np
|
||||
import soundfile as sf
|
||||
@@ -28,20 +26,6 @@ from vllm_omni.utils.tracking_parser import TrackingArgumentParser
|
||||
SEED = 42
|
||||
|
||||
|
||||
def parse_json_object(value: str, flag_name: str = "argument") -> dict[str, Any]:
|
||||
"""Parse a CLI value as a JSON object, attributing errors to ``flag_name``."""
|
||||
try:
|
||||
config = json.loads(value)
|
||||
except json.JSONDecodeError as e:
|
||||
raise argparse.ArgumentTypeError(f"{flag_name} must be valid JSON: {e}") from e
|
||||
if not isinstance(config, dict):
|
||||
raise argparse.ArgumentTypeError(f"{flag_name} must be a JSON object")
|
||||
return config
|
||||
|
||||
|
||||
parse_profiler_config = functools.partial(parse_json_object, flag_name="--profiler-config")
|
||||
|
||||
|
||||
class QueryResult(NamedTuple):
|
||||
inputs: dict
|
||||
limit_mm_per_prompt: dict[str, int]
|
||||
@@ -394,10 +378,11 @@ def main(args):
|
||||
for i, prompt in enumerate(prompts):
|
||||
prompt["modalities"] = output_modalities
|
||||
|
||||
profiler_enabled = args.profiler_config is not None
|
||||
if profiler_enabled:
|
||||
print("[Profiler] Starting profiling...")
|
||||
profiler_enabled = bool(os.getenv("VLLM_TORCH_PROFILER_DIR"))
|
||||
if profiler_enabled and hasattr(omni, "start_profile"):
|
||||
omni.start_profile(stages=[0])
|
||||
elif profiler_enabled:
|
||||
print("[Warn] VLLM_TORCH_PROFILER_DIR is set, but current engine does not support profiler controls.")
|
||||
omni_generator = omni.generate(prompts, sampling_params_list, py_generator=args.py_generator)
|
||||
|
||||
# Determine output directory: prefer --output-dir; fallback to --output-wav
|
||||
@@ -433,7 +418,7 @@ def main(args):
|
||||
print(f"Request ID: {request_id}, Saved audio to {output_wav}")
|
||||
|
||||
processed_count += 1
|
||||
if profiler_enabled and processed_count >= total_requests:
|
||||
if profiler_enabled and hasattr(omni, "stop_profile") and processed_count >= total_requests:
|
||||
print(f"[Info] Processed {processed_count}/{total_requests}. Stopping profiler inside active loop...")
|
||||
# Stop the profiler while workers are still alive
|
||||
omni.stop_profile()
|
||||
@@ -491,12 +476,6 @@ def parse_args():
|
||||
default=300,
|
||||
help="Timeout for initializing stages in seconds (default: 300)",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--profiler-config",
|
||||
type=parse_profiler_config,
|
||||
default=None,
|
||||
help='JSON profiler config for torch/cuda profiling, e.g. \'{"profiler":"torch","torch_profiler_dir":"./perf"}\'.',
|
||||
)
|
||||
parser.add_argument(
|
||||
"--shm-threshold-bytes",
|
||||
type=int,
|
||||
|
||||
@@ -14,7 +14,6 @@ list of supported architectures across all modalities, see
|
||||
|
||||
| Model | HuggingFace repo | Stages | Voice cloning | Streaming | Special modes | Sample rate |
|
||||
|---|---|---|---|---|---|---|
|
||||
| Audio8 TTS Preview | `Audio8/Audio8-TTS-Preview-0.6b` | dual-AR | ✓ | ✓ | 11 languages | 44.1 kHz |
|
||||
| CosyVoice3 | `FunAudioLLM/Fun-CosyVoice3-0.5B-2512` | 2 (talker + code2wav) | ✓ | ✓ | — | 24 kHz |
|
||||
| Fish Speech S2 Pro | `fishaudio/s2-pro` | dual-AR | ✓ | ✓ | — | 44.1 kHz |
|
||||
| Gepard-1.0 | `nineninesix/gepard-1.0` | single (native AR + NanoCodec) | — (zero-shot; cloning WIP) | — (serving WIP) | zero-shot | 22.05 kHz |
|
||||
@@ -45,57 +44,6 @@ python examples/offline_inference/text_to_speech/<model>/end2end.py \
|
||||
|
||||
---
|
||||
|
||||
## Audio8 TTS Preview
|
||||
|
||||
0.6B DualAR text-to-speech model (Audio8) with its own 44.1 kHz neural audio
|
||||
codec: a slow AR transformer predicts one semantic token per codec frame, and a
|
||||
4-layer fast AR predicts that frame's remaining 9 codebooks.
|
||||
|
||||
### Prerequisites
|
||||
No extra packages: the codec architecture ships in tree and its weights
|
||||
(`codec.pth`) come with the checkpoint.
|
||||
|
||||
### Quick start
|
||||
```bash
|
||||
python examples/offline_inference/text_to_speech/audio8_tts/end2end.py \
|
||||
--text "Welcome to Audio8 TTS, a compact multilingual text to speech model."
|
||||
```
|
||||
|
||||
### Voice cloning
|
||||
```bash
|
||||
python examples/offline_inference/text_to_speech/audio8_tts/end2end.py \
|
||||
--text "Welcome to Audio8 TTS." \
|
||||
--ref-audio /path/to/reference.wav \
|
||||
--ref-text "The exact transcript of the reference recording."
|
||||
```
|
||||
The reference transcript must match what is actually spoken in the clip;
|
||||
a mismatch degrades both stability and speaker similarity.
|
||||
|
||||
### Streaming
|
||||
```bash
|
||||
python examples/offline_inference/text_to_speech/audio8_tts/end2end.py \
|
||||
--text "Welcome to Audio8 TTS." --streaming
|
||||
```
|
||||
|
||||
### Notes
|
||||
- Output: 44.1 kHz mono WAV; the codec emits ~21.5 frames/s (2048 samples per frame).
|
||||
- Context is 2048 packed text+audio positions, so `max_model_len` is 2048.
|
||||
- Greedy decoding (`temperature: 0`) is degenerate for this checkpoint — it
|
||||
ends the utterance almost immediately. Keep the deploy defaults
|
||||
(`temperature 0.7`, `top_k 50`, `top_p 0.9`), which also match
|
||||
`generation_config.json`.
|
||||
- Repetition-Aware Sampling is applied to the semantic token: a repeat inside
|
||||
the last 10 frames is re-drawn from a flatter distribution instead of being
|
||||
masked out.
|
||||
- `--num-prompts 4` smoke-tests concurrency (stage 0 runs `max_num_seqs: 4`).
|
||||
|
||||
### Measured behaviour (1x H20, shared GPU)
|
||||
`--streaming` on a 58-character English sentence: TTFA ~0.74 s (4-frame first
|
||||
chunk), 7 chunks, 1.55 s wall for 3.16 s of audio (RTF ~0.49). Treat these as
|
||||
smoke-test magnitudes, not a benchmark.
|
||||
|
||||
---
|
||||
|
||||
## CosyVoice3
|
||||
|
||||
2-stage TTS pipeline (`talker` + `code2wav`) at 24 kHz.
|
||||
@@ -182,7 +130,11 @@ Text → [Stage 0: AR] → Speech Tokens → [Stage 1: DiT + HiFT] → Audio (24
|
||||
## Fish Speech S2 Pro
|
||||
|
||||
4B dual-AR text-to-speech model from FishAudio with the DAC codec at 44.1 kHz.
|
||||
No extra packages are required; the DAC codec is vendored in vLLM-Omni.
|
||||
|
||||
### Prerequisites
|
||||
```bash
|
||||
pip install fish-speech
|
||||
```
|
||||
|
||||
### Quick start
|
||||
```bash
|
||||
|
||||
@@ -1,237 +0,0 @@
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
# SPDX-FileCopyrightText: Copyright contributors to the vLLM-Omni project
|
||||
|
||||
"""Offline inference demo for Audio8 TTS Preview 0.6B via vLLM Omni.
|
||||
|
||||
Usage:
|
||||
# Text-only synthesis
|
||||
python end2end.py --text "Welcome to Audio8 TTS."
|
||||
|
||||
# Zero-shot voice cloning (the transcript must match the reference audio)
|
||||
python end2end.py --text "Welcome to Audio8 TTS." \
|
||||
--ref-audio reference.wav --ref-text "The exact transcript of the reference recording."
|
||||
|
||||
# Streaming (per-chunk TTFA / inter-chunk timings)
|
||||
python end2end.py --text "Welcome to Audio8 TTS." --streaming
|
||||
"""
|
||||
|
||||
import asyncio
|
||||
import os
|
||||
import time
|
||||
|
||||
import numpy as np
|
||||
import soundfile as sf
|
||||
import torch
|
||||
|
||||
os.environ["VLLM_WORKER_MULTIPROC_METHOD"] = "spawn"
|
||||
|
||||
from vllm_omni import AsyncOmni, Omni
|
||||
from vllm_omni.model_executor.models.audio8_tts.codec_utils import estimate_reference_code_frames
|
||||
from vllm_omni.model_executor.models.audio8_tts.prompt_utils import (
|
||||
build_text_only_prompt_ids,
|
||||
estimate_voice_clone_prompt_len,
|
||||
normalize_text,
|
||||
)
|
||||
from vllm_omni.utils.tracking_parser import TrackingArgumentParser
|
||||
|
||||
DEFAULT_MODEL = "Audio8/Audio8-TTS-Preview-0.6b"
|
||||
|
||||
|
||||
def build_prompt(
|
||||
text: str,
|
||||
ref_audio_path: str | None = None,
|
||||
ref_text: str | None = None,
|
||||
model_name: str = DEFAULT_MODEL,
|
||||
) -> dict:
|
||||
"""Build an engine prompt, using the same protocol as online serving."""
|
||||
from transformers import AutoTokenizer
|
||||
|
||||
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
||||
if ref_audio_path is None and ref_text is None:
|
||||
prompt_ids, normalized_text = build_text_only_prompt_ids(tokenizer, text)
|
||||
return {
|
||||
"prompt_token_ids": prompt_ids,
|
||||
"additional_information": {"text": [normalized_text]},
|
||||
}
|
||||
|
||||
if not ref_audio_path or not ref_text:
|
||||
raise ValueError("Audio8 TTS voice cloning requires both --ref-audio and --ref-text")
|
||||
|
||||
normalized_text = normalize_text(text)
|
||||
normalized_ref_text = normalize_text(ref_text, add_default_speaker=True)
|
||||
ref_audio_wav, ref_audio_sr = sf.read(ref_audio_path, dtype="float32", always_2d=False)
|
||||
if ref_audio_wav.ndim > 1:
|
||||
ref_audio_wav = ref_audio_wav.mean(axis=-1)
|
||||
ref_frames = estimate_reference_code_frames(int(ref_audio_wav.shape[0]), int(ref_audio_sr))
|
||||
placeholder_len = estimate_voice_clone_prompt_len(tokenizer, normalized_text, normalized_ref_text, ref_frames)
|
||||
|
||||
# The clone prompt embeds the reference audio's own codec codes, so the
|
||||
# model builds it in preprocess(); we only reserve the exact length here.
|
||||
return {
|
||||
"prompt_token_ids": [1] * placeholder_len,
|
||||
"additional_information": {
|
||||
"text": normalized_text,
|
||||
"ref_text": normalized_ref_text,
|
||||
"ref_audio_wav": torch.from_numpy(np.asarray(ref_audio_wav, dtype=np.float32)),
|
||||
"ref_audio_sr": int(ref_audio_sr),
|
||||
"audio8_structured_voice_clone": True,
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
def extract_audio(multimodal_output: dict) -> tuple[torch.Tensor, int]:
|
||||
"""Pull the waveform and sample rate out of a multimodal output.
|
||||
|
||||
The output processor concatenates the per-step delta tensors under
|
||||
``model_outputs``; ``audio`` is the older alias. Never use ``a or b`` on
|
||||
these values -- truthiness on a tensor raises.
|
||||
"""
|
||||
audio = multimodal_output.get("model_outputs")
|
||||
if audio is None:
|
||||
audio = multimodal_output.get("audio")
|
||||
if audio is None:
|
||||
raise ValueError(f"No audio in multimodal_output: {sorted(multimodal_output)}")
|
||||
if isinstance(audio, list):
|
||||
audio = torch.cat([torch.as_tensor(chunk).reshape(-1) for chunk in audio], dim=0)
|
||||
audio = torch.as_tensor(audio).reshape(-1)
|
||||
|
||||
sr_raw = multimodal_output.get("sr")
|
||||
if isinstance(sr_raw, list):
|
||||
sr_raw = sr_raw[-1] if sr_raw else None
|
||||
if sr_raw is None:
|
||||
raise ValueError("Missing sample rate in multimodal_output")
|
||||
sample_rate = int(sr_raw.item()) if hasattr(sr_raw, "item") else int(sr_raw)
|
||||
return audio, sample_rate
|
||||
|
||||
|
||||
def _save_wav(output_dir: str, request_id: str, audio: torch.Tensor, sample_rate: int) -> None:
|
||||
out_wav = os.path.join(output_dir, f"output_{request_id}.wav")
|
||||
sf.write(out_wav, audio.float().cpu().numpy(), samplerate=sample_rate, format="WAV")
|
||||
duration = audio.numel() / sample_rate
|
||||
# print(), not logging: vLLM reconfigures logging on engine start and
|
||||
# disables loggers created before that, which would swallow these lines.
|
||||
print(f"Request {request_id}: saved {out_wav} (sr={sample_rate}, {duration:.2f}s)")
|
||||
|
||||
|
||||
def _omni_kwargs(args, model_name: str) -> dict:
|
||||
kwargs = {
|
||||
"model": model_name,
|
||||
"log_stats": args.log_stats,
|
||||
"stage_init_timeout": args.stage_init_timeout,
|
||||
}
|
||||
if args.deploy_config:
|
||||
kwargs["deploy_config"] = args.deploy_config
|
||||
return kwargs
|
||||
|
||||
|
||||
def main(args) -> None:
|
||||
os.makedirs(args.output_dir, exist_ok=True)
|
||||
model_name = args.model or DEFAULT_MODEL
|
||||
prompts = [
|
||||
build_prompt(text, args.ref_audio, args.ref_text, model_name) for text in ([args.text] * args.num_prompts)
|
||||
]
|
||||
|
||||
omni = Omni(**_omni_kwargs(args, model_name))
|
||||
t_start = time.perf_counter()
|
||||
total_audio_seconds = 0.0
|
||||
for stage_outputs in omni.generate(prompts):
|
||||
request_output = stage_outputs
|
||||
if request_output is None or not request_output.outputs:
|
||||
continue
|
||||
audio, sample_rate = extract_audio(request_output.outputs[0].multimodal_output)
|
||||
assert audio.numel() > 0, "Audio8 TTS produced an empty waveform"
|
||||
total_audio_seconds += audio.numel() / sample_rate
|
||||
_save_wav(args.output_dir, request_output.request_id, audio, sample_rate)
|
||||
elapsed = time.perf_counter() - t_start
|
||||
rtf = elapsed / max(total_audio_seconds, 1e-6)
|
||||
print(f"Total {elapsed * 1000:.1f} ms for {total_audio_seconds:.2f} s of audio (RTF={rtf:.3f})")
|
||||
|
||||
|
||||
async def main_streaming(args) -> None:
|
||||
os.makedirs(args.output_dir, exist_ok=True)
|
||||
model_name = args.model or DEFAULT_MODEL
|
||||
prompt = build_prompt(args.text, args.ref_audio, args.ref_text, model_name)
|
||||
|
||||
omni = AsyncOmni(**_omni_kwargs(args, model_name))
|
||||
request_id = "0"
|
||||
chunks: list[torch.Tensor] = []
|
||||
sample_rate = None
|
||||
t_start = time.perf_counter()
|
||||
t_prev = t_start
|
||||
chunk_index = 0
|
||||
|
||||
async for stage_output in omni.generate(prompt, request_id=request_id):
|
||||
multimodal_output = stage_output.outputs[0].multimodal_output
|
||||
if not multimodal_output:
|
||||
continue
|
||||
audio = multimodal_output.get("model_outputs")
|
||||
if audio is None:
|
||||
audio = multimodal_output.get("audio")
|
||||
if audio is not None:
|
||||
if isinstance(audio, list):
|
||||
chunks.extend(torch.as_tensor(chunk).reshape(-1) for chunk in audio)
|
||||
else:
|
||||
chunks.append(torch.as_tensor(audio).reshape(-1))
|
||||
sr_raw = multimodal_output.get("sr")
|
||||
if isinstance(sr_raw, list):
|
||||
sr_raw = sr_raw[-1] if sr_raw else None
|
||||
if sr_raw is not None:
|
||||
sample_rate = int(sr_raw.item()) if hasattr(sr_raw, "item") else int(sr_raw)
|
||||
|
||||
if stage_output.finished:
|
||||
break
|
||||
now = time.perf_counter()
|
||||
if chunk_index == 0:
|
||||
print(f"chunk 0: TTFA={(now - t_start) * 1000:.1f} ms")
|
||||
else:
|
||||
print(f"chunk {chunk_index}: inter_chunk={(now - t_prev) * 1000:.1f} ms")
|
||||
t_prev = now
|
||||
chunk_index += 1
|
||||
|
||||
if not chunks or sample_rate is None:
|
||||
raise RuntimeError("Audio8 TTS streaming produced no audio")
|
||||
_save_wav(args.output_dir, request_id, torch.cat(chunks, dim=0), sample_rate)
|
||||
print(f"Streaming done: total={(time.perf_counter() - t_start) * 1000:.1f} ms chunks={chunk_index}")
|
||||
|
||||
|
||||
def parse_args():
|
||||
parser = TrackingArgumentParser(description="Audio8 TTS Preview offline inference with vLLM Omni")
|
||||
parser.add_argument("--model", type=str, default=DEFAULT_MODEL, help="Model path or HuggingFace repo ID.")
|
||||
parser.add_argument(
|
||||
"--text",
|
||||
type=str,
|
||||
default="Welcome to Audio8 TTS, a compact multilingual text to speech model.",
|
||||
help="Text to synthesize.",
|
||||
)
|
||||
parser.add_argument("--ref-audio", type=str, default=None, help="Reference audio path for voice cloning.")
|
||||
parser.add_argument(
|
||||
"--ref-text",
|
||||
type=str,
|
||||
default=None,
|
||||
help="Transcript of --ref-audio; required for voice cloning and must match the recording.",
|
||||
)
|
||||
parser.add_argument("--output-dir", type=str, default="output_audio", help="Directory for output WAV files.")
|
||||
parser.add_argument(
|
||||
"--num-prompts",
|
||||
type=int,
|
||||
default=1,
|
||||
help="Duplicate the prompt N times to smoke-test concurrent requests.",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--deploy-config",
|
||||
type=str,
|
||||
default=None,
|
||||
help="Override the deploy config path; defaults to vllm_omni/deploy/audio8_tts.yaml via model_type.",
|
||||
)
|
||||
parser.add_argument("--streaming", action="store_true", help="Use AsyncOmni and report per-chunk latency.")
|
||||
parser.add_argument("--log-stats", action="store_true", help="Enable engine stats logging.")
|
||||
parser.add_argument("--stage-init-timeout", type=int, default=600, help="Per-stage init timeout in seconds.")
|
||||
return parser.parse_args()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
parsed_args = parse_args()
|
||||
if parsed_args.streaming:
|
||||
asyncio.run(main_streaming(parsed_args))
|
||||
else:
|
||||
main(parsed_args)
|
||||
@@ -1,12 +1,9 @@
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
|
||||
import argparse
|
||||
import functools
|
||||
import json
|
||||
import os
|
||||
import urllib.request
|
||||
from pathlib import Path
|
||||
from typing import Any
|
||||
|
||||
import numpy as np
|
||||
import soundfile as sf
|
||||
@@ -32,20 +29,6 @@ def _default_ref_audio() -> str:
|
||||
return str(dest)
|
||||
|
||||
|
||||
def parse_json_object(value: str, flag_name: str = "argument") -> dict[str, Any]:
|
||||
"""Parse a CLI value as a JSON object, attributing errors to ``flag_name``."""
|
||||
try:
|
||||
config = json.loads(value)
|
||||
except json.JSONDecodeError as e:
|
||||
raise argparse.ArgumentTypeError(f"{flag_name} must be valid JSON: {e}") from e
|
||||
if not isinstance(config, dict):
|
||||
raise argparse.ArgumentTypeError(f"{flag_name} must be a JSON object")
|
||||
return config
|
||||
|
||||
|
||||
parse_profiler_config = functools.partial(parse_json_object, flag_name="--profiler-config")
|
||||
|
||||
|
||||
def run_e2e():
|
||||
parser = argparse.ArgumentParser()
|
||||
# ""FunAudioLLM/Fun-CosyVoice3-0.5B-2512
|
||||
@@ -81,12 +64,6 @@ def run_e2e():
|
||||
required=True,
|
||||
help="Path to tokenizer directory (e.g., <model_path>/CosyVoice-BlankEN).",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--profiler-config",
|
||||
type=parse_profiler_config,
|
||||
default=None,
|
||||
help='JSON profiler config for torch/cuda profiling, e.g. \'{"profiler":"torch","torch_profiler_dir":"./perf"}\'.',
|
||||
)
|
||||
args = parser.parse_args()
|
||||
# Ensure tokenizer directory exists
|
||||
if not os.path.exists(args.tokenizer):
|
||||
@@ -102,7 +79,6 @@ def run_e2e():
|
||||
deploy_config=args.deploy_config,
|
||||
tokenizer=args.tokenizer,
|
||||
log_stats=True,
|
||||
profiler_config=args.profiler_config,
|
||||
)
|
||||
|
||||
sampling_cfg = {"top_p": 0.8, "top_k": 25, "eos_token_id": 6561 + 1}
|
||||
@@ -173,8 +149,8 @@ def run_e2e():
|
||||
|
||||
sampling_params_list = [gpt_sampling, s2mel_sampling]
|
||||
|
||||
profiler_enabled = args.profiler_config is not None
|
||||
if profiler_enabled:
|
||||
# Start profiling (requires VLLM_TORCH_PROFILER_DIR env var)
|
||||
if os.environ.get("VLLM_TORCH_PROFILER_DIR"):
|
||||
print("Starting profiler...")
|
||||
omni.start_profile()
|
||||
|
||||
@@ -182,7 +158,7 @@ def run_e2e():
|
||||
outputs = list(omni.generate(prompts, sampling_params_list=sampling_params_list[:2]))
|
||||
|
||||
# Stop profiling and get results
|
||||
if profiler_enabled:
|
||||
if os.environ.get("VLLM_TORCH_PROFILER_DIR"):
|
||||
print("Stopping profiler...")
|
||||
profile_results = omni.stop_profile()
|
||||
print(f"Profile traces saved to: {profile_results}")
|
||||
|
||||
@@ -264,7 +264,7 @@ python examples/online_serving/openai_chat_completion_client_for_multimodal_gene
|
||||
|
||||
#### Realtime WebSocket client (`openai_realtime_client.py`)
|
||||
|
||||
[`openai_realtime_client.py`](./openai_realtime_client.py) connects to **`ws://<host>:<port>/v1/realtime`**, streams a local WAV as **PCM16 mono @ 16 kHz** in fixed-size chunks, and receives **`response.audio.*`**, **`response.output_text.*`**, and transcript events. By default it uses explicit `input_audio_buffer.commit`; pass **`--server-vad`** to let the server detect speech endpoints and commit the turn automatically. The client concatenates audio deltas and writes **`--output-wav`** (model output is typically **24 kHz**). Optional **`--delta-dump-dir`** saves each delta as `delta_000001.wav`, … for debugging.
|
||||
[`openai_realtime_client.py`](./openai_realtime_client.py) connects to **`ws://<host>:<port>/v1/realtime`**, streams a local WAV as **PCM16 mono @ 16 kHz** in fixed-size chunks (OpenAI-style `input_audio_buffer.append` / `commit`), and receives **`response.audio.delta`** (incremental PCM for the reply) plus **`transcription.*`** events. By default it concatenates audio deltas and writes **`--output-wav`** (model output is typically **24 kHz**). Optional **`--delta-dump-dir`** saves each delta as `delta_000001.wav`, … for debugging.
|
||||
|
||||
Streaming input works well for translation-style use cases; if the Thinker runs while input is still incomplete, consider limiting **`max_tokens`** in your session / server defaults to avoid over-generation.
|
||||
|
||||
@@ -282,7 +282,6 @@ python openai_realtime_client.py \
|
||||
--model Qwen/Qwen3-Omni-30B-A3B-Instruct \
|
||||
--input-wav /path/to/input_16k_mono.wav \
|
||||
--output-wav realtime_output.wav \
|
||||
--server-vad \
|
||||
--delta-dump-dir ./rt_delta_wavs
|
||||
```
|
||||
|
||||
@@ -298,32 +297,15 @@ python openai_realtime_client.py \
|
||||
| `--chunk-ms` | `200` | Size of each uploaded audio chunk (milliseconds of audio) |
|
||||
| `--send-delay-ms` | `0` | Delay between chunk sends (simulate realtime upload) |
|
||||
| `--delta-dump-dir` | *(optional)* | Directory to write per-`response.audio.delta` WAV files |
|
||||
| `--server-vad` | disabled | Enable server-side Silero VAD instead of sending explicit commits |
|
||||
| `--num-requests` | `1` | Number of sequential sessions (see `--concurrency`) |
|
||||
| `--concurrency` | `1` | Max concurrent WebSocket sessions when `--num-requests` > 1 |
|
||||
|
||||
Server VAD uses the pinned Silero v6.2 ONNX artifact from `istupakov/silero-vad-onnx` and never downloads model files while processing a session. Make the artifact available in the Hugging Face cache before startup, or configure a local artifact in the deployment YAML:
|
||||
|
||||
```yaml
|
||||
duplex_session:
|
||||
server_vad_model_path: /models/silero_vad.onnx
|
||||
```
|
||||
|
||||
Start from the bundled Qwen3-Omni deployment YAML, add the fields above at the top level, and serve that complete configuration:
|
||||
Ensure the server is running, for example:
|
||||
|
||||
```bash
|
||||
cp vllm_omni/deploy/qwen3_omni_moe.yaml /path/to/qwen3_omni_server_vad.yaml
|
||||
# Edit /path/to/qwen3_omni_server_vad.yaml and add duplex_session.
|
||||
vllm serve Qwen/Qwen3-Omni-30B-A3B-Instruct \
|
||||
--omni \
|
||||
--port 8091 \
|
||||
--deploy-config /path/to/qwen3_omni_server_vad.yaml
|
||||
vllm serve Qwen/Qwen3-Omni-30B-A3B-Instruct --omni --port 8091
|
||||
```
|
||||
|
||||
Keep Qwen's default `session_mode: turn`; `duplex_session` enables the Realtime handler without changing scheduler
|
||||
semantics. Bare `/v1/realtime` selects that handler. The client uses `?duplex=0` only for the existing non-Server-VAD
|
||||
wire flow; `?duplex=1` remains a supported compatibility alias.
|
||||
|
||||
The Python client supports the following command-line arguments:
|
||||
|
||||
- `--query-type` (or `-q`): Query type (default: `use_video`). Options: `text`, `use_audio`, `use_image`, `use_video`
|
||||
|
||||
@@ -1,12 +1,9 @@
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
# SPDX-FileCopyrightText: Copyright contributors to the vLLM-Omni project
|
||||
|
||||
"""Realtime client for vLLM-Omni /v1/realtime (audio + text events).
|
||||
|
||||
This client:
|
||||
1) Reads a local WAV file (must be mono, 16-bit PCM, 16kHz),
|
||||
2) Streams PCM16 chunks to /v1/realtime with OpenAI-style events,
|
||||
3) Receives response.audio.*, response.output_text.*, and transcript events,
|
||||
3) Receives response.audio.* and transcription.* events,
|
||||
4) Saves synthesized audio to an output WAV file and optional text file.
|
||||
|
||||
By default each ``response.audio.delta`` is treated as an **incremental PCM**
|
||||
@@ -21,7 +18,6 @@ Usage:
|
||||
--model Qwen/Qwen3-Omni-30B-A3B-Instruct \
|
||||
--input-wav input_16k_mono.wav \
|
||||
--output-wav realtime_output.wav \
|
||||
--server-vad \
|
||||
--delta-dump-dir ./rt_delta_wavs
|
||||
|
||||
Dependencies:
|
||||
@@ -36,7 +32,6 @@ import base64
|
||||
import json
|
||||
import wave
|
||||
from pathlib import Path
|
||||
from urllib.parse import parse_qsl, urlencode, urlsplit, urlunsplit
|
||||
|
||||
try:
|
||||
import websockets
|
||||
@@ -75,14 +70,6 @@ def _write_wav_pcm16(path: Path, pcm16_bytes: bytes, sample_rate_hz: int) -> Non
|
||||
wf.writeframes(pcm16_bytes)
|
||||
|
||||
|
||||
def _with_realtime_route(url: str, *, server_vad: bool) -> str:
|
||||
parts = urlsplit(url)
|
||||
query = [(key, value) for key, value in parse_qsl(parts.query, keep_blank_values=True) if key != "duplex"]
|
||||
if not server_vad:
|
||||
query.append(("duplex", "0"))
|
||||
return urlunsplit(parts._replace(query=urlencode(query)))
|
||||
|
||||
|
||||
async def run_client(
|
||||
url: str,
|
||||
model: str,
|
||||
@@ -92,7 +79,6 @@ async def run_client(
|
||||
chunk_ms: int,
|
||||
send_delay_ms: int,
|
||||
delta_dump_dir: Path | None,
|
||||
server_vad: bool,
|
||||
request_idx: int = 1,
|
||||
total_requests: int = 1,
|
||||
) -> None:
|
||||
@@ -106,44 +92,23 @@ async def run_client(
|
||||
delta_index = 0
|
||||
text_chunks: list[str] = []
|
||||
final_text: str = ""
|
||||
final_audio_transcript: str = ""
|
||||
|
||||
if delta_dump_dir is not None:
|
||||
delta_dump_dir.mkdir(parents=True, exist_ok=True)
|
||||
|
||||
# Keep the CLI mode authoritative even if the input URL already contains
|
||||
# an explicit duplex query parameter.
|
||||
url = _with_realtime_route(url, server_vad=server_vad)
|
||||
async with websockets.connect(url, max_size=64 * 1024 * 1024) as ws:
|
||||
# 1) Validate model.
|
||||
if server_vad:
|
||||
session_update = {
|
||||
"type": "session.update",
|
||||
"session": {
|
||||
await ws.send(
|
||||
json.dumps(
|
||||
{
|
||||
"type": "session.update",
|
||||
"model": model,
|
||||
"audio": {
|
||||
"input": {
|
||||
"format": {"type": "audio/pcm", "rate": 16_000},
|
||||
"turn_detection": {
|
||||
"type": "server_vad",
|
||||
"threshold": 0.5,
|
||||
"prefix_padding_ms": 300,
|
||||
"silence_duration_ms": 500,
|
||||
"create_response": True,
|
||||
"interrupt_response": False,
|
||||
},
|
||||
}
|
||||
},
|
||||
},
|
||||
}
|
||||
else:
|
||||
# Preserve the existing non-duplex wire format.
|
||||
session_update = {"type": "session.update", "model": model}
|
||||
await ws.send(json.dumps(session_update))
|
||||
}
|
||||
)
|
||||
)
|
||||
|
||||
# 2) Preserve the legacy explicit-commit flow unless Server VAD owns endpointing.
|
||||
if not server_vad:
|
||||
await ws.send(json.dumps({"type": "input_audio_buffer.commit", "final": False}))
|
||||
# 2) Start generation once (non-final commit).
|
||||
await ws.send(json.dumps({"type": "input_audio_buffer.commit", "final": False}))
|
||||
|
||||
# 3) Stream audio chunks.
|
||||
for i in range(0, len(pcm16), chunk_bytes):
|
||||
@@ -159,20 +124,8 @@ async def run_client(
|
||||
if send_delay_ms > 0:
|
||||
await asyncio.sleep(send_delay_ms / 1000.0)
|
||||
|
||||
# 4) Finalize the turn explicitly, or append silence for Server VAD endpointing.
|
||||
if server_vad:
|
||||
trailing_silence = bytes(16_000 * 2)
|
||||
for i in range(0, len(trailing_silence), chunk_bytes):
|
||||
await ws.send(
|
||||
json.dumps(
|
||||
{
|
||||
"type": "input_audio_buffer.append",
|
||||
"audio": base64.b64encode(trailing_silence[i : i + chunk_bytes]).decode("utf-8"),
|
||||
}
|
||||
)
|
||||
)
|
||||
else:
|
||||
await ws.send(json.dumps({"type": "input_audio_buffer.commit", "final": True}))
|
||||
# 4) Final commit closes input stream.
|
||||
await ws.send(json.dumps({"type": "input_audio_buffer.commit", "final": True}))
|
||||
|
||||
# 5) Receive server events until audio done.
|
||||
while True:
|
||||
@@ -191,7 +144,7 @@ async def run_client(
|
||||
sr = event.get("sample_rate_hz")
|
||||
if isinstance(sr, int) and sr > 0:
|
||||
output_sample_rate = sr
|
||||
audio_b64 = event.get("delta" if server_vad else "audio", "")
|
||||
audio_b64 = event.get("audio", "")
|
||||
if audio_b64:
|
||||
pcm_delta = base64.b64decode(audio_b64)
|
||||
incremental_pcm_parts.append(pcm_delta)
|
||||
@@ -205,14 +158,14 @@ async def run_client(
|
||||
)
|
||||
continue
|
||||
|
||||
if event_type in {"response.output_text.delta", "transcription.delta"}:
|
||||
if event_type == "transcription.delta":
|
||||
delta = event.get("delta", "")
|
||||
if delta:
|
||||
text_chunks.append(delta)
|
||||
print(delta, end="", flush=True)
|
||||
continue
|
||||
|
||||
if event_type in {"response.output_text.done", "transcription.done"}:
|
||||
if event_type == "transcription.done":
|
||||
final_text = event.get("text", "") or "".join(text_chunks)
|
||||
usage = event.get("usage")
|
||||
final_text_with_tag = f"Final transcription: {final_text}"
|
||||
@@ -223,16 +176,7 @@ async def run_client(
|
||||
print(f"{log_prefix}text usage: {usage}")
|
||||
continue
|
||||
|
||||
if event_type == "response.audio_transcript.done":
|
||||
final_audio_transcript = event.get("transcript", "")
|
||||
continue
|
||||
|
||||
if event_type == "response.audio.done":
|
||||
if not server_vad:
|
||||
break
|
||||
continue
|
||||
|
||||
if event_type == "response.done" and server_vad:
|
||||
break
|
||||
|
||||
if event_type == "error":
|
||||
@@ -247,7 +191,7 @@ async def run_client(
|
||||
print(f"{log_prefix}Saved realtime audio to: {output_wav} (incremental chunks joined)")
|
||||
|
||||
if output_text is not None:
|
||||
text_to_save = final_text or "".join(text_chunks) or final_audio_transcript
|
||||
text_to_save = final_text if final_text else "".join(text_chunks)
|
||||
output_text.parent.mkdir(parents=True, exist_ok=True)
|
||||
output_text.write_text(text_to_save, encoding="utf-8")
|
||||
print(f"{log_prefix}Saved realtime text to: {output_text}")
|
||||
@@ -269,7 +213,6 @@ async def run_clients_concurrent(
|
||||
chunk_ms: int,
|
||||
send_delay_ms: int,
|
||||
delta_dump_dir: Path | None,
|
||||
server_vad: bool,
|
||||
num_requests: int,
|
||||
concurrency: int,
|
||||
) -> None:
|
||||
@@ -292,7 +235,6 @@ async def run_clients_concurrent(
|
||||
chunk_ms=chunk_ms,
|
||||
send_delay_ms=send_delay_ms,
|
||||
delta_dump_dir=per_delta_dir,
|
||||
server_vad=server_vad,
|
||||
request_idx=index,
|
||||
total_requests=num_requests,
|
||||
)
|
||||
@@ -341,11 +283,6 @@ def main() -> None:
|
||||
default=None,
|
||||
help="If set, each response.audio.delta is saved as delta_NNNNNN.wav under this directory",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--server-vad",
|
||||
action="store_true",
|
||||
help="Let the server detect speech endpoints instead of sending input_audio_buffer.commit",
|
||||
)
|
||||
parser.add_argument("--num-requests", type=int, default=1, help="Total number of requests to send")
|
||||
parser.add_argument(
|
||||
"--concurrency",
|
||||
@@ -372,7 +309,6 @@ def main() -> None:
|
||||
chunk_ms=args.chunk_ms,
|
||||
send_delay_ms=args.send_delay_ms,
|
||||
delta_dump_dir=args.delta_dump_dir,
|
||||
server_vad=args.server_vad,
|
||||
)
|
||||
)
|
||||
else:
|
||||
@@ -386,7 +322,6 @@ def main() -> None:
|
||||
chunk_ms=args.chunk_ms,
|
||||
send_delay_ms=args.send_delay_ms,
|
||||
delta_dump_dir=args.delta_dump_dir,
|
||||
server_vad=args.server_vad,
|
||||
num_requests=args.num_requests,
|
||||
concurrency=concurrency,
|
||||
)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
# Streaming Video Generation
|
||||
|
||||
This example uses the custom WebSocket endpoint `WS /v1/realtime/video` to receive a video byte stream as chunks are produced.
|
||||
It covers text-to-video, and image-conditioned models through `--image-reference`.
|
||||
It covers text-only video generation. Image/reference input is intentionally not included for now.
|
||||
|
||||
## Start The Server
|
||||
|
||||
@@ -20,7 +20,7 @@ The `--diffusion-streaming-output` CLI flag is forwarded as `streaming_output=Tr
|
||||
|
||||
| Direction | Message | Format | Description |
|
||||
| --- | --- | --- | --- |
|
||||
| Client to server | `session.start` | JSON text: `{"type":"session.start","model":"...","prompt":"...","format":"m4s"}` | Starts generation. `format` is optional and accepts `m4s` (default). Sampling fields such as `width`, `height`, `fps`, `num_frames`, and `extra_params` may be included. Image-conditioned models take a first frame as `image_reference`: `{"image_url":"https://..."}` or a `data:` URL. |
|
||||
| Client to server | `session.start` | JSON text: `{"type":"session.start","model":"...","prompt":"...","format":"m4s"}` | Starts generation. `format` is optional and accepts `m4s` (default). Sampling fields such as `width`, `height`, `fps`, `num_frames`, and `extra_params` may be included. |
|
||||
| Client to server | `session.interaction` | JSON text: `{"type":"session.interaction","interaction":{"event_id":"xxx","event":{"prompt":"..."},"transition_chunks":3}}` | Updates the active prompt midway through generation. `event_id` is optional and `transition_chunks` defaults to the model setting. |
|
||||
| Server to client | `video.start` | JSON text: `{"type":"video.start","request_id":"...","format":"m4s","config":{...}}` | Confirms the session and mirrors the accepted `format`. |
|
||||
| Server to client | `video.chunk_metadata` | JSON text: `{"type":"video.chunk_metadata","request_id":"...","kind":"media","transport_chunk_index":0,"generation_chunk_index":0,"num_frames":9,"byte_length":1234,"started_event_ids":[],"active_event_ids":[],"completed_event_ids":[]}` | Precedes each binary frame and describes the immediately following payload. |
|
||||
@@ -62,7 +62,7 @@ python streaming_video_client.py \
|
||||
The client sends one `session.start` message, prints each received binary video chunk with its byte size and elapsed time, and saves the received bytes to `--output` after `session.done`.
|
||||
The client remuxes the gathered stream to a regular progressive MP4 file so that local playback knows the video duration.
|
||||
|
||||
Schedule midway prompt updates with `--prompt-updates`. None are sent unless you ask for them, and only pipelines that implement midway prompt updates accept them (LingBot-World, for one, does not, and rejects the whole session). Each entry uses `"at"` as seconds on the client clock after the server sends `video.start`:
|
||||
Schedule midway prompt updates with `--prompt-updates`. Each entry uses `"at"` as seconds on the client clock after the server sends `video.start`:
|
||||
|
||||
```bash
|
||||
python streaming_video_client.py \
|
||||
@@ -73,19 +73,6 @@ python streaming_video_client.py \
|
||||
]'
|
||||
```
|
||||
|
||||
The Helios demo continues the default prompt into an underwater storm:
|
||||
|
||||
```bash
|
||||
python streaming_video_client.py \
|
||||
--model BestWishYsh/Helios-Distilled \
|
||||
--prompt-updates '[
|
||||
{"at": 4,
|
||||
"prompt": "An underwater tornado appears and affects the ocean floor in a dramatic and chaotic scene. The water is murky, swirling violently, carrying debris and marine life into the vortex. The tropical fish on the scene all swim in panic, trying to avoid the powerful currents. The camera remains stationary, capturing the intensity of the underwater tornado as it disrupts the serene ocean floor. Close-up shot emphasizing the turbulent motion and destruction."},
|
||||
{"at": 11,
|
||||
"prompt": "The swirling underwater vortex now seizes a heavy, encrusted treasure chest, its lid flapping open as it is smashed onto the ocean floor. Gold coins and silver trinkets spill out, glittering briefly in the murky water before being swept instantly into the violent funnel. The heavy wooden box tumbles end over end, colliding with floating rocks and adding to the debris field. Swirling sediment and bubbles surround the spilling fortune, highlighting the chaotic power of the storm as it ravages the seabed. Close-up shot emphasizing the turbulent motion and destruction."}
|
||||
]'
|
||||
```
|
||||
|
||||
## Run The Gradio Demo
|
||||
|
||||
```bash
|
||||
@@ -119,31 +106,3 @@ Disable it in the CLI example with `--no-helios-distilled-preset`, or override/e
|
||||
python streaming_video_client.py \
|
||||
--extra-params '{"pyramid_num_inference_steps_list":[2, 2, 2]}'
|
||||
```
|
||||
|
||||
### LingBot-World 2.0
|
||||
|
||||
`robbyant/lingbot-world-v2-14b-causal-fast-diffusers` is image-conditioned and runs on the
|
||||
AR-Diffusion engine, so it needs the stepwise deploy config and a first frame. See
|
||||
[the recipe](../../../recipes/Robbyant/LingBot-World-2.0.md) for the constraints on
|
||||
`width`/`height` and `num_frames`.
|
||||
|
||||
```bash
|
||||
vllm serve robbyant/lingbot-world-v2-14b-causal-fast-diffusers \
|
||||
--omni \
|
||||
--deploy-config vllm_omni/deploy/lingbot_world_v2_stepwise.yaml \
|
||||
--port 8000
|
||||
```
|
||||
|
||||
```bash
|
||||
python streaming_video_client.py \
|
||||
--model robbyant/lingbot-world-v2-14b-causal-fast-diffusers \
|
||||
--prompt "The camera moves slowly forward through the scene." \
|
||||
--image-reference /path/to/first_frame.png \
|
||||
--width 832 --height 480 --num-frames 33 --fps 16 --seed 42 \
|
||||
--extra-params '{"camera_action_script":[[["w"],["w"],["w"]],[["a"],[],[]],[[],[],[]]]}' \
|
||||
--output lingbot_world_v2_stream.mp4
|
||||
```
|
||||
|
||||
`camera_action_script` carries one three-latent-frame WASD action list per generated
|
||||
chunk. Mid-session `session.interaction` only updates the prompt, so a LingBot rollout
|
||||
follows the camera script it started with.
|
||||
@@ -1,12 +1,11 @@
|
||||
#!/usr/bin/env python3
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
# SPDX-FileCopyrightText: Copyright contributors to the vLLM-Omni project
|
||||
"""WebSocket client for `/v1/realtime/video`.
|
||||
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
|
||||
"""Text-only WebSocket client for `/v1/realtime/video`.
|
||||
|
||||
The client prints a line for every binary video chunk it receives and writes
|
||||
the received bytes to disk when the session finishes or is interrupted.
|
||||
``--image-reference`` sends a first frame for image-conditioned models such as
|
||||
LingBot-World 2.0; text-only models need no image.
|
||||
Image/reference input is intentionally not supported in this example yet.
|
||||
|
||||
Requirements:
|
||||
pip install av websockets
|
||||
@@ -14,11 +13,9 @@ Requirements:
|
||||
|
||||
import argparse
|
||||
import asyncio
|
||||
import base64
|
||||
import contextlib
|
||||
import io
|
||||
import json
|
||||
import mimetypes
|
||||
import os
|
||||
import time
|
||||
from dataclasses import dataclass
|
||||
@@ -56,18 +53,6 @@ class ScheduledPromptUpdate:
|
||||
transition_chunks: int
|
||||
|
||||
|
||||
def _image_reference(value: str) -> dict[str, Any]:
|
||||
"""Accept an http(s) URL as-is, or inline a local image as a data URL."""
|
||||
if value.startswith(("http://", "https://", "data:")):
|
||||
return {"image_url": value}
|
||||
path = Path(value)
|
||||
if not path.is_file():
|
||||
raise argparse.ArgumentTypeError(f"--image-reference is neither a URL nor a readable file: {value}")
|
||||
media_type = mimetypes.guess_type(path.name)[0] or "image/png"
|
||||
encoded = base64.b64encode(path.read_bytes()).decode()
|
||||
return {"image_url": f"data:{media_type};base64,{encoded}"}
|
||||
|
||||
|
||||
def _parse_extra_params(value: str) -> dict[str, Any]:
|
||||
try:
|
||||
parsed = json.loads(value)
|
||||
@@ -131,7 +116,6 @@ def build_session_start(args: argparse.Namespace) -> dict[str, Any]:
|
||||
"prompt": args.prompt,
|
||||
}
|
||||
|
||||
_maybe_set(payload, "image_reference", args.image_reference)
|
||||
_maybe_set(payload, "negative_prompt", args.negative_prompt)
|
||||
_maybe_set(payload, "width", args.width)
|
||||
_maybe_set(payload, "height", args.height)
|
||||
@@ -378,12 +362,6 @@ def parse_args() -> argparse.Namespace:
|
||||
parser.add_argument("--fps", type=int, default=16, help="Frames per second")
|
||||
parser.add_argument("--num-frames", type=int, default=429, help="Number of generated frames")
|
||||
|
||||
parser.add_argument(
|
||||
"--image-reference",
|
||||
type=_image_reference,
|
||||
default=None,
|
||||
help="First frame for image-conditioned models: a local image path or an http(s) URL.",
|
||||
)
|
||||
parser.add_argument("--negative-prompt", default=None, help="Negative prompt")
|
||||
parser.add_argument("--num-inference-steps", type=int, default=None, help="Number of diffusion steps")
|
||||
parser.add_argument("--guidance-scale", type=float, default=1.0, help="Classifier-free guidance scale")
|
||||
@@ -405,16 +383,36 @@ def parse_args() -> argparse.Namespace:
|
||||
default=None,
|
||||
help="JSON object merged into extra_params; overrides preset keys on conflict.",
|
||||
)
|
||||
# Midway prompt updates are pipeline-specific: a model that does not implement
|
||||
# them (LingBot-World, for one) rejects the whole session on the first one, so
|
||||
# nothing is scheduled unless the caller asks for it.
|
||||
parser.add_argument(
|
||||
"--prompt-updates",
|
||||
type=_parse_prompt_updates,
|
||||
default=[],
|
||||
default=json.dumps(
|
||||
[
|
||||
{
|
||||
"at": 4,
|
||||
"prompt": (
|
||||
"An underwater tornado appears and affects the ocean floor in a dramatic and chaotic scene. "
|
||||
"The water is murky, swirling violently, carrying debris and marine life into the vortex. "
|
||||
"The tropical fish on the scene all swim in panic, trying to avoid the powerful currents. "
|
||||
"The camera remains stationary, capturing the intensity of the underwater tornado as it disrupts the serene ocean floor. "
|
||||
"Close-up shot emphasizing the turbulent motion and destruction."
|
||||
),
|
||||
},
|
||||
{
|
||||
"at": 11,
|
||||
"prompt": (
|
||||
"The swirling underwater vortex now seizes a heavy, encrusted treasure chest, its lid flapping open as it is smashed onto the ocean floor. "
|
||||
"Gold coins and silver trinkets spill out, glittering briefly in the murky water before being swept instantly into the violent funnel. "
|
||||
"The heavy wooden box tumbles end over end, colliding with floating rocks and adding to the debris field. "
|
||||
"Swirling sediment and bubbles surround the spilling fortune, highlighting the chaotic power of the storm as it ravages the seabed. "
|
||||
"Close-up shot emphasizing the turbulent motion and destruction."
|
||||
),
|
||||
# "transition_chunks": 3,
|
||||
},
|
||||
]
|
||||
),
|
||||
help=(
|
||||
"JSON array of scheduled prompt updates; none are sent by default. "
|
||||
"Each object requires "
|
||||
"JSON array of scheduled prompt updates. Each object requires "
|
||||
"'at' (seconds after video.start) and 'prompt'. Optional "
|
||||
f"'transition_chunks' defaults to {DEFAULT_TRANSITION_CHUNKS}."
|
||||
),
|
||||
|
||||
@@ -14,7 +14,6 @@ For the full list of supported architectures across all modalities, see
|
||||
|
||||
| Model | HuggingFace repo | Voice cloning | Streaming | Voice presets / upload | Gradio demo |
|
||||
| --- | --- | --- | --- | --- | --- |
|
||||
| Audio8 TTS Preview | `Audio8/Audio8-TTS-Preview-0.6b` | ✓ (`ref_audio`+`ref_text`) | ✓ (PCM stream) | uploaded audio voice only; no presets | ✓ |
|
||||
| Fish Speech S2 Pro | `fishaudio/s2-pro` | ✓ (`ref_audio`+`ref_text`) | ✓ (PCM stream) | — | ✓ |
|
||||
| GLM-TTS | `zai-org/GLM-TTS` | ✓ (`ref_audio`+`ref_text`, required) | ✓ (PCM stream) | — | ✓ |
|
||||
| IndexTTS-2 | `IndexTeam/IndexTTS-2` | ✓ (`ref_audio` or uploaded `voice`) | `stream=true` response, non-chunk | uploaded audio voice only; no presets | — |
|
||||
@@ -254,142 +253,15 @@ python examples/online_serving/text_to_speech/indextts2/speech_client.py \
|
||||
|
||||
---
|
||||
|
||||
## Audio8 TTS Preview
|
||||
|
||||
0.6B DualAR TTS at 44.1 kHz, 11 languages, zero-shot voice cloning.
|
||||
|
||||
### Prerequisites
|
||||
None beyond the base install: the neural audio codec is implemented in tree and
|
||||
its weights (`codec.pth`) ship with the checkpoint.
|
||||
|
||||
### Launch
|
||||
```bash
|
||||
vllm serve Audio8/Audio8-TTS-Preview-0.6b --omni --port 8092
|
||||
# or:
|
||||
./audio8_tts/run_server.sh
|
||||
```
|
||||
The deploy config auto-loads from `vllm_omni/deploy/audio8_tts.yaml` (HF
|
||||
`model_type` is `arktts`). Do **not** pass `--trust-remote-code`: vllm-omni
|
||||
registers its own `arktts` config, and transformers would otherwise prefer the
|
||||
checkpoint's remote code and bypass it.
|
||||
|
||||
### Text-only synthesis
|
||||
```bash
|
||||
curl -X POST http://localhost:8092/v1/audio/speech \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{
|
||||
"input": "Welcome to Audio8 TTS.",
|
||||
"response_format": "wav"
|
||||
}' --output output.wav
|
||||
```
|
||||
|
||||
### Voice cloning
|
||||
```bash
|
||||
curl -X POST http://localhost:8092/v1/audio/speech \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{
|
||||
"input": "Welcome to Audio8 TTS.",
|
||||
"ref_audio": "https://example.com/reference.wav",
|
||||
"ref_text": "The exact transcript of the reference recording."
|
||||
}' --output cloned.wav
|
||||
```
|
||||
`ref_audio` also accepts a `data:audio/wav;base64,...` URL. `ref_text` is
|
||||
mandatory whenever `ref_audio` is present and must match the recording.
|
||||
Uploading a voice via `POST /v1/audio/voices` lets the server reuse the encoded
|
||||
reference codes across requests (`voice: "<name>"`).
|
||||
|
||||
### Streaming
|
||||
```bash
|
||||
python audio8_tts/speech_client.py --text "Welcome to Audio8 TTS." --stream --output out.pcm
|
||||
ffplay -f s16le -ar 44100 -ac 1 out.pcm
|
||||
```
|
||||
|
||||
### Gradio demo
|
||||
```bash
|
||||
./audio8_tts/run_gradio_demo.sh # server + demo
|
||||
python audio8_tts/gradio_demo.py --api-base http://localhost:8092 # demo only
|
||||
```
|
||||
|
||||
### Benchmark
|
||||
|
||||
```bash
|
||||
export VLLM_OMNI_BENCH_AUDIO_SAMPLE_RATE=44100 # required: harness defaults to 24 kHz
|
||||
vllm bench serve --omni --host 127.0.0.1 --port 8092 \
|
||||
--model Audio8/Audio8-TTS-Preview-0.6b \
|
||||
--backend openai-audio-speech --endpoint /v1/audio/speech \
|
||||
--dataset-name seed-tts-text --dataset-path benchmarks/build_dataset/seed_tts_smoke \
|
||||
--seed-tts-locale en --num-prompts 20 --num-warmups 2 \
|
||||
--max-concurrency 1 --request-rate inf \
|
||||
--percentile-metrics ttft,e2el,audio_rtf,audio_ttfp,audio_duration,audio_underrun
|
||||
```
|
||||
|
||||
Measured on 1x H20 **shared with an unrelated job holding ~80% SM**, so treat
|
||||
these as a lower bound. 20 prompts from `seed_tts_smoke/en`, mean audio 4.5 s,
|
||||
deploy defaults:
|
||||
|
||||
| | HF reference (batch=1) | vllm-omni c=1 | c=4 | c=8 |
|
||||
|---|---|---|---|---|
|
||||
| RTF (mean) | 1.008 | **0.19** | 0.30 | 0.54 |
|
||||
| Throughput (req/s) | 0.23 | 1.18 | 2.84 | **2.93** |
|
||||
| E2E latency (mean, ms) | 4375 | 850 | 1349 | 2361 |
|
||||
| Time to first packet (mean, ms) | n/a (no streaming) | 63 | 105 | 1124 |
|
||||
| Underrun p99 / continuity OK | n/a | 0 s / 100% | 0 s / 100% | 0 s / 100% |
|
||||
|
||||
~5.3x lower per-request RTF than the upstream reference implementation at
|
||||
concurrency 1, ~12.8x aggregate throughput at concurrency 8.
|
||||
|
||||
#### Stage-0 `max_num_seqs`: first-packet vs throughput
|
||||
|
||||
This subsection is operator tuning guidance, not a claim this PR optimizes
|
||||
anything: the shipped deploy default is unchanged (`max_num_seqs: 4`). The
|
||||
numbers below are a single run on the same contended H20 as above (one unrelated
|
||||
job holding ~80% SM, no repeats), so read them as directional, not as measured
|
||||
speedups. Same setup, varying stage 0's `max_num_seqs` (stage 1 stays at 1):
|
||||
|
||||
| stage-0 `max_num_seqs` | client concurrency | req/s | RTF | TTFP mean / p99 (ms) | underrun p99 (s) |
|
||||
|---|---|---|---|---|---|
|
||||
| 4 (default) | 1 | 1.18 | 0.19 | 63 / 67 | 0.00 |
|
||||
| 4 | 4 | 2.84 | 0.30 | 105 / 148 | 0.00 |
|
||||
| 4 | 8 | 2.93 | 0.54 | 1124 / 1642 | 0.00 |
|
||||
| 8 | 1 | 1.16 | 0.19 | 64 / 70 | 0.00 |
|
||||
| 8 | 4 | 2.88 | 0.30 | 107 / 148 | 0.00 |
|
||||
| 8 | 8 | **3.72** | 0.40 | **247** / 733 | 0.22 |
|
||||
| 8 | 16 | 3.91 | 0.65 | 1366 / 2530 | 0.29 |
|
||||
|
||||
Reading of this:
|
||||
|
||||
- Below the limit (`concurrency <= max_num_seqs`) the setting is irrelevant, as
|
||||
expected — c=1 and c=4 are identical for both.
|
||||
- At c=8, raising the limit to 8 admits every request instead of queueing half
|
||||
of them: in this single run, roughly +27% throughput and ~4.5x lower
|
||||
first-packet latency.
|
||||
- Throughput saturates around 3.7-3.9 req/s (~17 s of audio per second). Past
|
||||
c=8 you only buy queueing delay.
|
||||
- The cost of admitting more streams is a 0.22-0.29 s worst-case buffer deficit
|
||||
in 1 of 20 requests (`Streaming continuity OK rate` 95%), because stage 1 runs
|
||||
`max_num_seqs: 1` and the codec window round-robins across streams. Client-side
|
||||
prebuffering (the bundled Gradio demo holds 2 chunks) absorbs that; raising
|
||||
stage 1's `max_num_seqs` is the untested knob if you need both.
|
||||
|
||||
The shipped default stays at 4 because every measured point there had zero
|
||||
underrun. Raise it to 8 if first-packet latency under load matters more than a
|
||||
rare sub-300 ms gap.
|
||||
|
||||
### Notes
|
||||
- Output: 44.1 kHz mono; ~21.5 codec frames per second.
|
||||
- No built-in speaker presets. Omit `voice` for a random timbre, or clone one.
|
||||
- `max_new_tokens` caps generated codec frames (1 frame ~= 46 ms).
|
||||
- Context is 2048 packed text+audio positions (`max_model_len: 2048`).
|
||||
- Do not send `temperature: 0`: greedy decoding is degenerate for this
|
||||
checkpoint and truncates the utterance. The deploy defaults
|
||||
(0.7 / top_k 50 / top_p 0.9) mirror `generation_config.json`.
|
||||
|
||||
---
|
||||
|
||||
## Fish Speech S2 Pro
|
||||
|
||||
4B dual-AR TTS at 44.1 kHz. Server uses the DAC codec, which is vendored in
|
||||
vLLM-Omni (no extra packages required).
|
||||
4B dual-AR TTS at 44.1 kHz. Server uses the DAC codec.
|
||||
|
||||
### Prerequisites
|
||||
|
||||
```bash
|
||||
pip install fish-speech
|
||||
```
|
||||
|
||||
### Kvcache attention fast path
|
||||
|
||||
@@ -796,21 +668,13 @@ Raw PCM streaming requires `stream_format="audio"`, `response_format="pcm"`, and
|
||||
|
||||
### Streaming WebSocket
|
||||
|
||||
The `/v1/audio/speech/stream` endpoint accepts text incrementally and, by default, synthesizes the buffered text as one continuous request on `input.done`:
|
||||
The `/v1/audio/speech/stream` endpoint accepts text incrementally and synthesizes the buffered text as one continuous request on `input.done`:
|
||||
|
||||
```bash
|
||||
python qwen3_tts/streaming_speech_client.py --text "Hello world. How are you? I am fine."
|
||||
python qwen3_tts/streaming_speech_client.py --text "..." --simulate-stt --stt-delay 0.1
|
||||
```
|
||||
|
||||
For per-sentence audio (including Indic danda `।`) before `input.done`:
|
||||
|
||||
```bash
|
||||
python qwen3_tts/streaming_speech_client.py \
|
||||
--text "नमस्ते। कैसे हो?" \
|
||||
--split-granularity sentence
|
||||
```
|
||||
|
||||
`input.done` flushes without closing, so repeating `--text` synthesizes several utterances over one connection:
|
||||
|
||||
```bash
|
||||
|
||||
@@ -1,258 +0,0 @@
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
# SPDX-FileCopyrightText: Copyright contributors to the vLLM-Omni project
|
||||
|
||||
"""Gradio demo for Audio8 TTS Preview via the /v1/audio/speech API.
|
||||
|
||||
Supports:
|
||||
- text-to-speech synthesis in 11 languages
|
||||
- zero-shot voice cloning from reference audio (upload, microphone, or URL)
|
||||
- streaming (progressive PCM chunks) and non-streaming modes
|
||||
|
||||
Usage:
|
||||
# Start the server first (see run_server.sh), then:
|
||||
python gradio_demo.py --api-base http://localhost:8092
|
||||
"""
|
||||
|
||||
import argparse
|
||||
import base64
|
||||
import io
|
||||
|
||||
try:
|
||||
import gradio as gr
|
||||
except ImportError:
|
||||
raise ImportError("gradio is required to run this demo. Install it with: pip install 'vllm-omni[demo]'") from None
|
||||
import httpx
|
||||
import numpy as np
|
||||
import soundfile as sf
|
||||
|
||||
#: Audio8 TTS decodes at 44.1 kHz; raw PCM must be interpreted at that rate.
|
||||
PCM_SAMPLE_RATE = 44100
|
||||
DEFAULT_API_BASE = "http://localhost:8092"
|
||||
|
||||
|
||||
def encode_audio_to_base64(audio_data: tuple) -> str:
|
||||
"""Encode a Gradio ``(sample_rate, numpy_array)`` input as a data URL."""
|
||||
sample_rate, audio_np = audio_data
|
||||
if audio_np.dtype != np.int16:
|
||||
if audio_np.dtype in (np.float32, np.float64):
|
||||
audio_np = (np.clip(audio_np, -1.0, 1.0) * 32767).astype(np.int16)
|
||||
else:
|
||||
audio_np = audio_np.astype(np.int16)
|
||||
buf = io.BytesIO()
|
||||
sf.write(buf, audio_np, sample_rate, format="WAV")
|
||||
return f"data:audio/wav;base64,{base64.b64encode(buf.getvalue()).decode('utf-8')}"
|
||||
|
||||
|
||||
def build_payload(
|
||||
text: str,
|
||||
ref_audio: tuple | None,
|
||||
ref_audio_url: str,
|
||||
ref_text: str,
|
||||
response_format: str = "wav",
|
||||
stream: bool = False,
|
||||
) -> dict:
|
||||
"""Build the ``/v1/audio/speech`` payload.
|
||||
|
||||
Audio8 TTS has no built-in speakers: omit ``voice`` for a random timbre, or
|
||||
supply ``ref_audio`` + ``ref_text`` to clone a voice.
|
||||
"""
|
||||
if not text or not text.strip():
|
||||
raise gr.Error("Please enter text to synthesize.")
|
||||
|
||||
payload: dict = {
|
||||
"input": text.strip(),
|
||||
"response_format": "pcm" if stream else response_format,
|
||||
"stream": stream,
|
||||
}
|
||||
if stream:
|
||||
payload["stream_format"] = "audio"
|
||||
|
||||
ref_url = ref_audio_url.strip() if ref_audio_url else ""
|
||||
if ref_audio is not None:
|
||||
payload["ref_audio"] = encode_audio_to_base64(ref_audio)
|
||||
elif ref_url:
|
||||
payload["ref_audio"] = ref_url
|
||||
|
||||
if "ref_audio" in payload:
|
||||
if not ref_text or not ref_text.strip():
|
||||
raise gr.Error("Voice cloning requires the transcript of the reference audio.")
|
||||
payload["ref_text"] = ref_text.strip()
|
||||
|
||||
return payload
|
||||
|
||||
|
||||
def generate_speech(api_base: str, text: str, ref_audio, ref_audio_url, ref_text, response_format):
|
||||
"""Non-streaming request; returns the whole waveform."""
|
||||
payload = build_payload(text, ref_audio, ref_audio_url, ref_text, response_format, stream=False)
|
||||
try:
|
||||
with httpx.Client(timeout=300.0) as client:
|
||||
resp = client.post(
|
||||
f"{api_base}/v1/audio/speech",
|
||||
json=payload,
|
||||
headers={"Content-Type": "application/json", "Authorization": "Bearer EMPTY"},
|
||||
)
|
||||
except httpx.TimeoutException:
|
||||
raise gr.Error("Request timed out. The server may be busy.") from None
|
||||
except httpx.ConnectError:
|
||||
raise gr.Error(f"Cannot connect to server at {api_base}. Is the server running?") from None
|
||||
|
||||
if resp.status_code != 200:
|
||||
raise gr.Error(f"Server error ({resp.status_code}): {resp.text}")
|
||||
if "application/json" in resp.headers.get("content-type", ""):
|
||||
raise gr.Error(f"Server error: {resp.text}")
|
||||
|
||||
try:
|
||||
if response_format == "pcm":
|
||||
audio_np = np.frombuffer(resp.content, dtype=np.int16).astype(np.float32) / 32767.0
|
||||
return (PCM_SAMPLE_RATE, audio_np)
|
||||
audio_np, sample_rate = sf.read(io.BytesIO(resp.content))
|
||||
if audio_np.ndim > 1:
|
||||
audio_np = audio_np[:, 0]
|
||||
return (sample_rate, audio_np.astype(np.float32))
|
||||
except Exception as e:
|
||||
raise gr.Error(f"Failed to decode audio: {e}") from None
|
||||
|
||||
|
||||
def generate_speech_stream(api_base, text, ref_audio, ref_audio_url, ref_text, response_format, chunk_seconds=0.5):
|
||||
"""Streaming request; yields PCM chunks for progressive playback."""
|
||||
payload = build_payload(text, ref_audio, ref_audio_url, ref_text, response_format, stream=True)
|
||||
min_chunk_samples = int(PCM_SAMPLE_RATE * chunk_seconds)
|
||||
prebuffer_chunks = 2
|
||||
pending: list[np.ndarray] = []
|
||||
pending_len = 0
|
||||
chunks_yielded = 0
|
||||
prebuffer: list[np.ndarray] = []
|
||||
leftover = b""
|
||||
|
||||
try:
|
||||
with (
|
||||
httpx.Client(timeout=300.0) as client,
|
||||
client.stream(
|
||||
"POST",
|
||||
f"{api_base}/v1/audio/speech",
|
||||
json=payload,
|
||||
headers={"Content-Type": "application/json", "Authorization": "Bearer EMPTY"},
|
||||
) as resp,
|
||||
):
|
||||
if resp.status_code != 200:
|
||||
resp.read()
|
||||
raise gr.Error(f"Server error ({resp.status_code}): {resp.text}")
|
||||
for chunk in resp.iter_bytes():
|
||||
if not chunk:
|
||||
continue
|
||||
raw = leftover + chunk
|
||||
# s16le: never split a sample across chunk boundaries.
|
||||
usable = len(raw) - (len(raw) % 2)
|
||||
leftover = raw[usable:]
|
||||
if usable == 0:
|
||||
continue
|
||||
samples = np.frombuffer(raw[:usable], dtype=np.int16).copy().astype(np.float32) / 32767.0
|
||||
pending.append(samples)
|
||||
pending_len += len(samples)
|
||||
if pending_len < min_chunk_samples:
|
||||
continue
|
||||
audio_chunk = np.concatenate(pending)
|
||||
pending.clear()
|
||||
pending_len = 0
|
||||
if chunks_yielded < prebuffer_chunks:
|
||||
prebuffer.append(audio_chunk)
|
||||
chunks_yielded += 1
|
||||
if chunks_yielded == prebuffer_chunks:
|
||||
yield (PCM_SAMPLE_RATE, np.concatenate(prebuffer))
|
||||
prebuffer.clear()
|
||||
else:
|
||||
yield (PCM_SAMPLE_RATE, audio_chunk)
|
||||
remaining = prebuffer + pending
|
||||
if remaining:
|
||||
yield (PCM_SAMPLE_RATE, np.concatenate(remaining))
|
||||
except httpx.TimeoutException:
|
||||
raise gr.Error("Request timed out. The server may be busy.") from None
|
||||
except httpx.ConnectError:
|
||||
raise gr.Error(f"Cannot connect to server at {api_base}. Is the server running?") from None
|
||||
|
||||
|
||||
def on_stream_change(stream: bool):
|
||||
"""Streaming only makes sense with raw PCM."""
|
||||
if stream:
|
||||
return gr.update(value="pcm", interactive=False)
|
||||
return gr.update(value="wav", interactive=True)
|
||||
|
||||
|
||||
def build_interface(api_base: str, stream_chunk_seconds: float = 0.5):
|
||||
with gr.Blocks(title="Audio8 TTS Preview Demo") as demo:
|
||||
gr.Markdown("# Audio8 TTS Preview 0.6B - Text to Speech")
|
||||
gr.Markdown(f"**Server:** `{api_base}` | **Model:** Audio8/Audio8-TTS-Preview-0.6b | **Output:** 44.1 kHz")
|
||||
|
||||
with gr.Row():
|
||||
with gr.Column(scale=3):
|
||||
text_input = gr.Textbox(label="Text to Synthesize", placeholder="Enter text here...", lines=4)
|
||||
|
||||
with gr.Accordion("Voice Cloning (optional)", open=False):
|
||||
gr.Markdown(
|
||||
"Upload or link a short reference recording (5-30 s) and paste its **exact** transcript. "
|
||||
"A transcript that does not match the audio degrades both stability and speaker similarity."
|
||||
)
|
||||
ref_audio = gr.Audio(label="Reference Audio", type="numpy", sources=["upload", "microphone"])
|
||||
ref_audio_url = gr.Textbox(
|
||||
label="Reference Audio URL (alternative to upload)",
|
||||
placeholder="https://example.com/reference.wav",
|
||||
lines=1,
|
||||
)
|
||||
ref_text = gr.Textbox(
|
||||
label="Reference Audio Transcript (required for cloning)",
|
||||
placeholder="Exact transcript of the reference audio...",
|
||||
lines=2,
|
||||
)
|
||||
|
||||
with gr.Row():
|
||||
response_format = gr.Dropdown(
|
||||
choices=["wav", "mp3", "flac", "pcm"], value="wav", label="Audio Format", scale=1
|
||||
)
|
||||
stream_checkbox = gr.Checkbox(
|
||||
label="Stream output", value=False, info="Progressive PCM streaming", scale=1
|
||||
)
|
||||
|
||||
generate_btn = gr.Button("Generate Speech", variant="primary", size="lg")
|
||||
|
||||
with gr.Column(scale=2):
|
||||
audio_output = gr.Audio(label="Generated Audio", interactive=False, streaming=True, autoplay=True)
|
||||
gr.Markdown(
|
||||
"### About\n"
|
||||
"- **Audio8 TTS Preview** — 0.6B DualAR model (slow AR + fast AR codebook decoder)\n"
|
||||
"- **Languages**: Cantonese, Chinese, Dutch, English, French, German, "
|
||||
"Italian, Japanese, Korean, Polish, Spanish\n"
|
||||
"- **Voice cloning**: zero-shot from a reference clip + transcript\n"
|
||||
"- **44.1 kHz** output, ~21.5 codec frames per second"
|
||||
)
|
||||
|
||||
stream_checkbox.change(fn=on_stream_change, inputs=[stream_checkbox], outputs=[response_format])
|
||||
all_inputs = [text_input, ref_audio, ref_audio_url, ref_text, response_format]
|
||||
|
||||
def dispatch(stream_enabled, *args):
|
||||
if stream_enabled:
|
||||
yield from generate_speech_stream(api_base, *args, chunk_seconds=stream_chunk_seconds)
|
||||
else:
|
||||
yield generate_speech(api_base, *args)
|
||||
|
||||
generate_btn.click(fn=dispatch, inputs=[stream_checkbox] + all_inputs, outputs=[audio_output])
|
||||
demo.queue()
|
||||
return demo
|
||||
|
||||
|
||||
def main() -> None:
|
||||
parser = argparse.ArgumentParser(description="Gradio demo for Audio8 TTS Preview")
|
||||
parser.add_argument("--api-base", default=DEFAULT_API_BASE, help=f"API base URL (default: {DEFAULT_API_BASE})")
|
||||
parser.add_argument("--host", default="0.0.0.0", help="Gradio host")
|
||||
parser.add_argument("--port", type=int, default=7861, help="Gradio port")
|
||||
parser.add_argument("--share", action="store_true", help="Create a public share link")
|
||||
parser.add_argument("--stream-chunk-seconds", type=float, default=0.5, help="Seconds of audio per yielded chunk")
|
||||
args = parser.parse_args()
|
||||
|
||||
print(f"Connecting to vLLM server at: {args.api_base}")
|
||||
build_interface(args.api_base, stream_chunk_seconds=args.stream_chunk_seconds).launch(
|
||||
server_name=args.host, server_port=args.port, share=args.share
|
||||
)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -1,44 +0,0 @@
|
||||
#!/bin/bash
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
# SPDX-FileCopyrightText: Copyright contributors to the vLLM-Omni project
|
||||
|
||||
# Launch the Audio8 TTS Preview server + Gradio demo together.
|
||||
#
|
||||
# Usage:
|
||||
# ./run_gradio_demo.sh
|
||||
# CUDA_VISIBLE_DEVICES=0 PORT=8092 GRADIO_PORT=7861 ./run_gradio_demo.sh
|
||||
|
||||
set -e
|
||||
|
||||
MODEL="${MODEL:-Audio8/Audio8-TTS-Preview-0.6b}"
|
||||
PORT="${PORT:-8092}"
|
||||
GRADIO_PORT="${GRADIO_PORT:-7861}"
|
||||
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
||||
|
||||
echo "Starting Audio8 TTS Preview server (port $PORT)..."
|
||||
vllm serve "$MODEL" \
|
||||
--omni \
|
||||
--host 0.0.0.0 \
|
||||
--port "$PORT" &
|
||||
SERVER_PID=$!
|
||||
|
||||
cleanup() {
|
||||
echo "Stopping server (PID $SERVER_PID)..."
|
||||
kill $SERVER_PID 2>/dev/null
|
||||
wait $SERVER_PID 2>/dev/null
|
||||
}
|
||||
trap cleanup EXIT
|
||||
|
||||
echo "Waiting for server to start..."
|
||||
for _ in $(seq 1 120); do
|
||||
if curl -s "http://localhost:$PORT/health" > /dev/null 2>&1; then
|
||||
echo "Server ready."
|
||||
break
|
||||
fi
|
||||
sleep 2
|
||||
done
|
||||
|
||||
echo "Starting Gradio demo (port $GRADIO_PORT)..."
|
||||
python "$SCRIPT_DIR/gradio_demo.py" \
|
||||
--api-base "http://localhost:$PORT" \
|
||||
--port "$GRADIO_PORT"
|
||||
@@ -1,24 +0,0 @@
|
||||
#!/bin/bash
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
# SPDX-FileCopyrightText: Copyright contributors to the vLLM-Omni project
|
||||
|
||||
# Launch a vLLM-Omni server for Audio8 TTS Preview 0.6B.
|
||||
#
|
||||
# Usage:
|
||||
# ./run_server.sh
|
||||
# CUDA_VISIBLE_DEVICES=0 PORT=8092 ./run_server.sh
|
||||
|
||||
set -e
|
||||
|
||||
MODEL="${MODEL:-Audio8/Audio8-TTS-Preview-0.6b}"
|
||||
PORT="${PORT:-8092}"
|
||||
|
||||
echo "Starting Audio8 TTS Preview server with model: $MODEL"
|
||||
|
||||
# --trust-remote-code is deliberately NOT passed: vllm-omni registers its own
|
||||
# `arktts` config, and transformers would otherwise prefer the checkpoint's
|
||||
# remote code and bypass it.
|
||||
vllm serve "$MODEL" \
|
||||
--omni \
|
||||
--host 0.0.0.0 \
|
||||
--port "$PORT"
|
||||
@@ -1,131 +0,0 @@
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
# SPDX-FileCopyrightText: Copyright contributors to the vLLM-Omni project
|
||||
|
||||
"""Client for Audio8 TTS Preview via the /v1/audio/speech endpoint.
|
||||
|
||||
Examples:
|
||||
# Basic TTS
|
||||
python speech_client.py --text "Welcome to Audio8 TTS."
|
||||
|
||||
# Zero-shot voice cloning (the transcript must match the reference audio)
|
||||
python speech_client.py --text "Welcome to Audio8 TTS." \
|
||||
--ref-audio ref.wav --ref-text "The exact transcript of the reference recording."
|
||||
|
||||
# Streaming PCM output
|
||||
python speech_client.py --text "Welcome to Audio8 TTS." --stream --output output.pcm
|
||||
"""
|
||||
|
||||
import argparse
|
||||
import base64
|
||||
import os
|
||||
|
||||
import httpx
|
||||
|
||||
DEFAULT_API_BASE = "http://localhost:8092"
|
||||
DEFAULT_API_KEY = "EMPTY"
|
||||
DEFAULT_MODEL = "Audio8/Audio8-TTS-Preview-0.6b"
|
||||
#: The codec runs at 44.1 kHz, so raw PCM must be played back at that rate.
|
||||
PCM_SAMPLE_RATE = 44100
|
||||
|
||||
|
||||
def encode_audio_to_base64(audio_path: str) -> str:
|
||||
"""Encode a local audio file as a base64 data URL."""
|
||||
if not os.path.exists(audio_path):
|
||||
raise FileNotFoundError(f"Audio file not found: {audio_path}")
|
||||
ext = audio_path.lower().rsplit(".", 1)[-1]
|
||||
mime_type = {"wav": "audio/wav", "mp3": "audio/mpeg", "flac": "audio/flac", "ogg": "audio/ogg"}.get(
|
||||
ext, "audio/wav"
|
||||
)
|
||||
with open(audio_path, "rb") as handle:
|
||||
audio_b64 = base64.b64encode(handle.read()).decode("utf-8")
|
||||
return f"data:{mime_type};base64,{audio_b64}"
|
||||
|
||||
|
||||
def build_payload(args) -> dict:
|
||||
payload = {
|
||||
"model": args.model,
|
||||
"input": args.text,
|
||||
"response_format": args.response_format,
|
||||
}
|
||||
if args.ref_audio:
|
||||
if args.ref_audio.startswith(("http://", "https://")):
|
||||
payload["ref_audio"] = args.ref_audio
|
||||
else:
|
||||
payload["ref_audio"] = encode_audio_to_base64(args.ref_audio)
|
||||
if args.ref_text:
|
||||
payload["ref_text"] = args.ref_text
|
||||
if args.max_new_tokens is not None:
|
||||
payload["max_new_tokens"] = args.max_new_tokens
|
||||
if args.stream:
|
||||
payload["stream"] = True
|
||||
payload["stream_format"] = "audio"
|
||||
payload["response_format"] = "pcm"
|
||||
return payload
|
||||
|
||||
|
||||
def run_tts(args) -> None:
|
||||
payload = build_payload(args)
|
||||
api_url = f"{args.api_base}/v1/audio/speech"
|
||||
headers = {"Content-Type": "application/json", "Authorization": f"Bearer {args.api_key}"}
|
||||
|
||||
print(f"Model: {args.model}")
|
||||
print(f"Text: {args.text}")
|
||||
if args.ref_audio:
|
||||
print(f"Voice cloning: ref_audio={args.ref_audio!r} ref_text={args.ref_text!r}")
|
||||
|
||||
if args.stream:
|
||||
output_path = args.output or "output.pcm"
|
||||
with (
|
||||
httpx.Client(timeout=300.0) as client,
|
||||
client.stream("POST", api_url, json=payload, headers=headers) as resp,
|
||||
):
|
||||
if resp.status_code != 200:
|
||||
print(f"Error {resp.status_code}: {resp.read().decode()}")
|
||||
return
|
||||
total_bytes = 0
|
||||
with open(output_path, "wb") as handle:
|
||||
for chunk in resp.iter_bytes():
|
||||
handle.write(chunk)
|
||||
total_bytes += len(chunk)
|
||||
seconds = total_bytes / 2 / PCM_SAMPLE_RATE
|
||||
print(f"Streamed {total_bytes} bytes (~{seconds:.2f}s of s16le @ {PCM_SAMPLE_RATE} Hz) to {output_path}")
|
||||
print(f"Play with: ffplay -f s16le -ar {PCM_SAMPLE_RATE} -ac 1 {output_path}")
|
||||
return
|
||||
|
||||
with httpx.Client(timeout=300.0) as client:
|
||||
response = client.post(api_url, json=payload, headers=headers)
|
||||
if response.status_code != 200:
|
||||
print(f"Error {response.status_code}: {response.text}")
|
||||
return
|
||||
if response.headers.get("content-type", "").startswith("application/json"):
|
||||
print(f"Error: {response.text}")
|
||||
return
|
||||
|
||||
output_path = args.output or f"output.{args.response_format}"
|
||||
with open(output_path, "wb") as handle:
|
||||
handle.write(response.content)
|
||||
print(f"Audio saved to: {output_path} ({len(response.content)} bytes)")
|
||||
|
||||
|
||||
def main() -> None:
|
||||
parser = argparse.ArgumentParser(description="Audio8 TTS Preview client")
|
||||
parser.add_argument("--api-base", default=DEFAULT_API_BASE, help="API base URL")
|
||||
parser.add_argument("--api-key", default=DEFAULT_API_KEY, help="API key")
|
||||
parser.add_argument("--model", "-m", default=DEFAULT_MODEL, help="Model name")
|
||||
parser.add_argument("--text", required=True, help="Text to synthesize")
|
||||
parser.add_argument("--ref-audio", default=None, help="Reference audio for voice cloning (path or URL)")
|
||||
parser.add_argument("--ref-text", default=None, help="Transcript of the reference audio")
|
||||
parser.add_argument("--max-new-tokens", type=int, default=None, help="Cap the number of generated codec frames")
|
||||
parser.add_argument("--stream", action="store_true", help="Stream PCM instead of returning a whole file")
|
||||
parser.add_argument(
|
||||
"--response-format",
|
||||
default="wav",
|
||||
choices=["wav", "mp3", "flac", "pcm", "aac", "opus"],
|
||||
help="Audio format (default: wav)",
|
||||
)
|
||||
parser.add_argument("--output", "-o", default=None, help="Output file path")
|
||||
run_tts(parser.parse_args())
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -24,11 +24,6 @@ Usage:
|
||||
--text "Hello world. How are you? I am fine." \
|
||||
--simulate-stt --stt-delay 0.1
|
||||
|
||||
# Opt into per-sentence synthesis (Indic danda, CJK, Latin)
|
||||
python streaming_speech_client.py \
|
||||
--text "नमस्ते। कैसे हो?" \
|
||||
--split-granularity sentence
|
||||
|
||||
# Receive JSON sidecar chunks with word-level timestamps
|
||||
python streaming_speech_client.py \
|
||||
--text "Hello world. How are you?" \
|
||||
@@ -78,9 +73,8 @@ except ImportError:
|
||||
def frame_basename(msg: dict) -> str:
|
||||
"""Name a file after the utterance and sentence a frame belongs to.
|
||||
|
||||
Every utterance uses `sentence_index` for units inside that flush.
|
||||
With default `split_granularity=none` that index stays 0; sentence mode
|
||||
uses 0, 1, ... so files from one connection do not overwrite each other.
|
||||
Every utterance is sentence 0, so the utterance index is what keeps the
|
||||
files of one connection from overwriting each other.
|
||||
"""
|
||||
return f"utterance_{msg['utterance_index']:03d}_sentence_{msg['sentence_index']:03d}"
|
||||
|
||||
@@ -374,13 +368,6 @@ def main():
|
||||
)
|
||||
parser.add_argument("--speed", type=float, default=1.0, help="Playback speed (0.25-4.0)")
|
||||
parser.add_argument("--max-new-tokens", type=int, default=None, help="Max tokens")
|
||||
parser.add_argument("--seed", type=int, default=None, help="Sampling seed forwarded to the server")
|
||||
parser.add_argument(
|
||||
"--split-granularity",
|
||||
default=None,
|
||||
choices=["none", "sentence", "clause"],
|
||||
help="Text split mode (default: server none = one request per input.done)",
|
||||
)
|
||||
|
||||
# Base task options
|
||||
parser.add_argument("--ref-audio", default=None, help="Reference audio")
|
||||
@@ -422,8 +409,6 @@ def main():
|
||||
"max_new_tokens",
|
||||
"ref_audio",
|
||||
"ref_text",
|
||||
"seed",
|
||||
"split_granularity",
|
||||
]:
|
||||
val = getattr(args, key.replace("-", "_"), None)
|
||||
if val is not None:
|
||||
|
||||
+5
-7
@@ -53,9 +53,7 @@ dev = [
|
||||
"soundfile==0.14.0",
|
||||
"imageio[ffmpeg]==2.37.4",
|
||||
"opencv-python==5.0.0.93",
|
||||
# 0.3.12 includes acknowledged TCP writes (Mooncake #2850): completion
|
||||
# must mean the receive buffer is ready before zero-copy consumers read it.
|
||||
"mooncake-transfer-engine-cuda13==0.3.12.post1",
|
||||
"mooncake-transfer-engine-cuda13==0.3.11.post1",
|
||||
"av==18.0.0", # for ComfyUI tests
|
||||
"openpyxl==3.1.5", # for nightly CI
|
||||
"pyttsx3==2.99",
|
||||
@@ -77,6 +75,7 @@ dev = [
|
||||
# Provides top-level cosyvoice2; do not co-install stepaudio2-minicpmo,
|
||||
# whose top-level stepaudio2 package conflicts with this distribution.
|
||||
"step-audio2==1.0.0", # Step-Audio2 / MiniCPM-o 4.5 Token2Wav (flashcosyvoice / hyperpyyaml)
|
||||
"silero-vad==6.1", # Realtime server-VAD duplex E2E
|
||||
]
|
||||
|
||||
demo = [
|
||||
@@ -86,6 +85,9 @@ demo = [
|
||||
"cn2an>=0.5.22", # Chinese number normalization for TTS (e.g. "1次" -> "一次")
|
||||
]
|
||||
|
||||
server-vad = [
|
||||
"silero-vad==6.1",
|
||||
]
|
||||
|
||||
forced-aligner = [
|
||||
"qwen-asr>=0.0.6", # faithful Japanese/Korean word segmentation for the TTS forced aligner
|
||||
@@ -374,7 +376,3 @@ ba = "ba"
|
||||
SER = "SER"
|
||||
# NumPy ndarray.flags.writeable (canonical flag name, not "writable").
|
||||
writeable = "writeable"
|
||||
# "convnet" abbreviates convolutional network. It appears in the vendored Fish
|
||||
# Speech DAC codec identifiers (convnet_type, transconvnet_type) and is not a
|
||||
# typo of "convent".
|
||||
convnet = "convnet"
|
||||
@@ -1,13 +1,12 @@
|
||||
# Boogu-Image
|
||||
|
||||
> Text-to-image and image-editing online serving
|
||||
(Boogu-Image-0.1-Base / -Turbo / -Edit / -Edit-Turbo)
|
||||
(Boogu-Image-0.1-Base / -Edit / -Edit-Turbo)
|
||||
|
||||
## Summary
|
||||
|
||||
- Vendor: Boogu
|
||||
- Model: `Boogu/Boogu-Image-0.1-Base` (text-to-image),
|
||||
`Boogu/Boogu-Image-0.1-Turbo` (four-step text-to-image),
|
||||
`Boogu/Boogu-Image-0.1-Edit` (image editing), and
|
||||
`Boogu/Boogu-Image-0.1-Edit-Turbo` (four-step image editing)
|
||||
- Task: Text-to-image generation and text-guided image editing (TI2I)
|
||||
@@ -17,9 +16,8 @@
|
||||
## When to use this recipe
|
||||
|
||||
Use this recipe when you want a known-good starting point for serving
|
||||
`Boogu/Boogu-Image-0.1-Base`, `Boogu/Boogu-Image-0.1-Turbo`,
|
||||
`Boogu/Boogu-Image-0.1-Edit`, or `Boogu/Boogu-Image-0.1-Edit-Turbo` with
|
||||
vLLM-Omni's native pipeline (no
|
||||
`Boogu/Boogu-Image-0.1-Base`, `Boogu/Boogu-Image-0.1-Edit`, or
|
||||
`Boogu/Boogu-Image-0.1-Edit-Turbo` with vLLM-Omni's native pipeline (no
|
||||
`--diffusion-load-format diffusers`, and the upstream `boogu` package is not
|
||||
required).
|
||||
|
||||
@@ -27,14 +25,12 @@ Boogu-Image-0.1 is an Apache-2.0 unified image generation and editing model
|
||||
family. The Base text-to-image checkpoint pairs a Qwen3-VL multimodal encoder
|
||||
with a Diffusion Transformer (DiT) and a flow-match Euler scheduler with
|
||||
time-shift. It handles photorealistic generation and Chinese/English text
|
||||
rendering. The Edit checkpoint uses the native `BooguImagePipeline`, while the
|
||||
distilled Turbo and Edit-Turbo checkpoints run the four-step DMD path through
|
||||
`BooguImageTurboPipeline`.
|
||||
rendering. The Edit and Edit-Turbo checkpoints use the same native
|
||||
`BooguImagePipeline` for image editing.
|
||||
|
||||
## References
|
||||
|
||||
- Upstream model card: <https://huggingface.co/Boogu/Boogu-Image-0.1-Base>
|
||||
- Turbo model card: <https://huggingface.co/Boogu/Boogu-Image-0.1-Turbo>
|
||||
- Edit model card: <https://huggingface.co/Boogu/Boogu-Image-0.1-Edit>
|
||||
- Edit-Turbo 1K hotfix: <https://huggingface.co/Boogu/Boogu-Image-0.1-Edit-Turbo/tree/hotfix-1k-20260708>
|
||||
- Project page: <https://boogu.org>
|
||||
@@ -152,7 +148,7 @@ The following configuration was validated:
|
||||
- vLLM-Omni version or commit: Use a commit that contains TorchAO FP8
|
||||
checkpoint loading for diffusion models
|
||||
- TorchAO version: 0.17.0
|
||||
- `kernels` / `kernels-data`: 0.16.1 / matching kernels-data
|
||||
- `kernels` / `kernels-data`: 0.15.2 / 0.16.1
|
||||
|
||||
#### Command
|
||||
|
||||
@@ -190,19 +186,6 @@ ID passed to `vllm serve`. For example, use
|
||||
corresponding Edit model.
|
||||
|
||||
Base text-to-image:
|
||||
## Fast text-to-image (Boogu-Image-0.1-Turbo)
|
||||
|
||||
Turbo is the distilled text-to-image checkpoint. Its `model_index.json`
|
||||
declares `BooguImageTurboPipeline`, which runs the four-step DMD path instead
|
||||
of the scheduler-driven path used by Base.
|
||||
|
||||
### Command
|
||||
|
||||
```bash
|
||||
vllm serve Boogu/Boogu-Image-0.1-Turbo --omni --port 8091
|
||||
```
|
||||
|
||||
### Verification
|
||||
|
||||
```bash
|
||||
curl -X POST http://localhost:8091/v1/images/generations \
|
||||
@@ -247,23 +230,6 @@ curl -X POST http://localhost:8091/v1/images/edits \
|
||||
checkpoint-declared FP8 configuration. With the regular checkpoints used for
|
||||
online FP8, the MLLM remains in BF16. The VAE and scheduler are outside this
|
||||
quantization routing.
|
||||
"model": "Boogu/Boogu-Image-0.1-Turbo",
|
||||
"prompt": "A mountain lake at sunset, photorealistic, cinematic lighting",
|
||||
"size": "1024x1024",
|
||||
"seed": 42
|
||||
}' | jq -r '.data[0].b64_json' | base64 -d > output-turbo.png
|
||||
```
|
||||
|
||||
### Notes
|
||||
|
||||
- **Required settings:** `guidance_scale=1.0` and `guidance_scale_2=1.0`; any
|
||||
other value is rejected. `num_inference_steps` defaults to 4. All three are
|
||||
pipeline defaults, so the request above omits them.
|
||||
- **Resolution:** upstream constrains Turbo to 1K, so `1024x1024` is the
|
||||
supported working resolution. The shared pipeline still clamps at 2K; larger
|
||||
sizes are not validated for this checkpoint.
|
||||
- **Known limitations:** the same single-GPU limitations as Base apply; CPU
|
||||
offload, Cache-DiT, and multi-GPU parallelism are not yet validated.
|
||||
|
||||
## Image editing (Boogu-Image-0.1-Edit)
|
||||
|
||||
@@ -388,18 +354,16 @@ curl -s http://localhost:8091/v1/chat/completions \
|
||||
## Fast image editing (Boogu-Image-0.1-Edit-Turbo)
|
||||
|
||||
Edit-Turbo is the distilled image-editing checkpoint. Its `model_index.json`
|
||||
declares `BooguImagePipeline`, so `--model-class-name BooguImageTurboPipeline`
|
||||
is required to reach the four-step DMD path; without it the checkpoint is
|
||||
served on the dense Edit path. The upstream 1K hotfix is recommended for
|
||||
stable results and is pinned below to avoid silently loading the older
|
||||
checkpoint from the repository's default revision.
|
||||
declares `BooguImagePipeline`, so it uses the same native TI2I path as Edit.
|
||||
The upstream 1K hotfix is recommended for stable results and is pinned below
|
||||
to avoid silently loading the older checkpoint from the repository's default
|
||||
revision.
|
||||
|
||||
### Command
|
||||
|
||||
```bash
|
||||
vllm serve Boogu/Boogu-Image-0.1-Edit-Turbo \
|
||||
--omni \
|
||||
--model-class-name BooguImageTurboPipeline \
|
||||
--revision hotfix-1k-20260708 \
|
||||
--port 8091
|
||||
```
|
||||
@@ -443,10 +407,11 @@ curl -s http://localhost:8091/v1/chat/completions \
|
||||
|
||||
- **Pinned revision:** use `hotfix-1k-20260708`; upstream recommends the 1K
|
||||
hotfix over the 1.5K variant for more stable results.
|
||||
- **Required settings:** `guidance_scale=1.0` and `guidance_scale_2=1.0`; the
|
||||
Turbo pipeline rejects any other value, so the `guidance_scale_2=2.0` shown
|
||||
for the regular Edit checkpoint does not apply here. `num_inference_steps`
|
||||
defaults to 4.
|
||||
- **Recommended settings:** `num_inference_steps=4` and
|
||||
`guidance_scale=1.0`. Edit-Turbo is guidance-distilled, meaning the guidance
|
||||
behavior is already baked into the distilled checkpoint. A scale of `1.0`
|
||||
avoids applying additional classifier-free guidance; unlike the regular Edit
|
||||
checkpoint, it should not be increased to `5.0`.
|
||||
- **Reference images:** the same single-reference and `align_res` behavior as
|
||||
the regular Edit checkpoint applies.
|
||||
- **Known limitations:** the same single-GPU limitations as Base and Edit apply;
|
||||
|
||||
@@ -219,51 +219,3 @@ the audio-track caveat.
|
||||
5 chunks, `key_frames=0` = summarize all chunk frames) are aligned to the JoyVL
|
||||
reference adapter so per-tick behavior matches the released model; the framework only
|
||||
supplies the serving structure.
|
||||
|
||||
## Native multi-stage pipeline (experimental)
|
||||
|
||||
An experimental native speech path is available alongside the existing Day-0 serving path:
|
||||
|
||||
```text
|
||||
one request with image/video and text
|
||||
-> JoyAI complete action text
|
||||
-> Qwen3-TTS Talker
|
||||
-> Code2Wav
|
||||
-> 24 kHz audio
|
||||
```
|
||||
|
||||
It runs behind one `vllm serve --omni` endpoint:
|
||||
|
||||
```bash
|
||||
vllm serve jdopensource/JoyAI-VL-Interaction-Preview --omni \
|
||||
--deploy-config vllm_omni/deploy/joyai_vl_interaction.yaml \
|
||||
--port 8091
|
||||
```
|
||||
|
||||
With `modalities: ["text", "audio"]`, its behavior is:
|
||||
|
||||
| JoyAI action | Native output |
|
||||
|---|---|
|
||||
| `</response> <text>` | action text + speech for `<text>` |
|
||||
| `</silence>` | action text + empty audio output (zero samples) |
|
||||
| `</response> <note> </delegation> <question>` | action text + speech for `<note>` only |
|
||||
|
||||
Native speech supports the Qwen3-TTS `CustomVoice` task. The request-level `voice` and
|
||||
`language` fields select the speaker and language; when omitted, they default to
|
||||
`Vivian` and `Auto`. Values supplied as `tts_speaker` and `tts_language` inside
|
||||
`additional_information` take priority.
|
||||
|
||||
This experimental native multi-stage pipeline is request-scoped, stateless, and
|
||||
all-sync. It currently does not include:
|
||||
|
||||
- continuous frame sessions, persistent standing instructions, or session memory;
|
||||
- audio input / ASR, full-duplex interaction, or barge-in;
|
||||
- background Agent execution for delegated questions;
|
||||
- async-chunk support from Talker to Code2Wav;
|
||||
- integration with the existing WebUI.
|
||||
|
||||
For actions with spoken text, the Talker starts only after the complete JoyAI action is
|
||||
available, and Code2Wav starts only after the Talker completes. Silence actions skip both
|
||||
TTS stages and return an empty audio output with zero samples. All three stages are placed
|
||||
on GPU 0 by the provided
|
||||
[`deploy config`](../../vllm_omni/deploy/joyai_vl_interaction.yaml).
|
||||
@@ -110,29 +110,6 @@ vllm serve Lightricks/LTX-2.5-Diffusers \
|
||||
|
||||
Use the T2V or I2V request below after the server is ready.
|
||||
|
||||
### Multi-GPU low-latency path
|
||||
|
||||
For low-latency 1920x1088 distilled two-stage serving, match the Ulysses and
|
||||
VAE patch-parallel degrees to the GPU count. For example, on four GPUs:
|
||||
|
||||
```bash
|
||||
CUDA_VISIBLE_DEVICES=0,1,2,3 \
|
||||
vllm serve Lightricks/LTX-2.5-Diffusers \
|
||||
--omni \
|
||||
--model-class-name LTX2DistilledTwoStagePipeline \
|
||||
--usp 4 \
|
||||
--vae-patch-parallel-size 4 \
|
||||
--vae-use-tiling \
|
||||
--host 0.0.0.0 \
|
||||
--port 8000 \
|
||||
--stage-init-timeout 900
|
||||
```
|
||||
|
||||
Strict Ulysses only: `((F - 1) / 8 + 1) * (H / 32) * (W / 32)` and TP-local
|
||||
SP attention head counts must be divisible by `ulysses_degree`. Use each
|
||||
phase's `H, W` (half/full resolution for two-stage); non-divisible shapes fail.
|
||||
Each GPU must still fit the resident weights. Warm up with the production shape.
|
||||
|
||||
## Offline inference
|
||||
|
||||
Choose values from the pipeline table. For example, the distilled two-stage
|
||||
|
||||
@@ -101,12 +101,6 @@ sigmas and input latents.
|
||||
Ordinary two-stage uses layer-fused LoRA for an unquantized BF16 Transformer
|
||||
and automatically switches to dynamic LoRA when quantization is enabled.
|
||||
|
||||
## Sequence Parallelism
|
||||
|
||||
Strict Ulysses only: `((F - 1) / 8 + 1) * (H / 32) * (W / 32)` and TP-local
|
||||
SP attention head counts must be divisible by `ulysses_degree`. Use each
|
||||
phase's `H, W` (half/full resolution for two-stage); non-divisible shapes fail.
|
||||
|
||||
## Serving
|
||||
|
||||
Start either one-stage checkpoint:
|
||||
@@ -341,8 +335,9 @@ bundled offline CLI do not currently expose `sigmas`.
|
||||
`--max-num-seqs 1`.
|
||||
- `--cfg-parallel-size` shards the complete LTX guidance plan, including STG,
|
||||
modality guidance, and rescale-compatible prediction gathering.
|
||||
- Ulysses masks padded audio latents; video sequences must satisfy the
|
||||
[sequence-parallel divisibility constraints](#sequence-parallelism).
|
||||
- Sequence parallelism may pad audio latents. Pure Ulysses masks the padding;
|
||||
Ring cannot, so audio length must be SP-divisible. Use `ring_degree=1` or a
|
||||
divisible request shape.
|
||||
- Cache-DiT is one-stage only; multi-stage configurations are rejected.
|
||||
|
||||
## Operational Notes
|
||||
|
||||
@@ -68,24 +68,16 @@ The `/v1/videos` request schema and `extra_params.task` values (`t2va`,
|
||||
|
||||
## Turbo LoRA
|
||||
|
||||
The deploy config below carries the four-step 768p contract -- five sigma
|
||||
points, `flow_shift=6`, `audio_flow_shift=3` -- so requests that omit sampling
|
||||
controls do not inherit the 50-step base schedule:
|
||||
MiniMax-H3 Turbo uses five sigma points, `flow_shift=6`, and
|
||||
`audio_flow_shift=3`. Start Turbo deployments with the dedicated defaults so
|
||||
requests that omit sampling controls do not inherit the 50-step base schedule:
|
||||
|
||||
```bash
|
||||
vllm-omni serve MiniMaxAI/MiniMax-H3 \
|
||||
--omni \
|
||||
--lora-path /path/to/minimax_h3_fl2v_turbo_4step_v1.0_768p_bf16.safetensors \
|
||||
--lora-path /path/to/MiniMax-H3-Turbo \
|
||||
--deploy-config vllm_omni/deploy/minimax_h3_disaggregated_turbo.yaml
|
||||
```
|
||||
|
||||
`--lora-path` must name one artifact, or a directory holding exactly one; the
|
||||
Turbo repository holds several and a directory of them is rejected as
|
||||
ambiguous. Serving a different artifact means overriding those defaults with
|
||||
that artifact's own contract -- see the
|
||||
[Turbo LoRA table](MiniMax-H3.md#turbo-lora) for every published row.
|
||||
|
||||
The base deployment intentionally retains 50 inference steps for non-LoRA
|
||||
quality. This disaggregated topology is validated on the `fl2v` artifacts,
|
||||
which serve T2VA and FL2VA; the `ref2v` artifacts need a `--task-type ref2va`
|
||||
server.
|
||||
quality. Turbo LoRA supports T2VA and FL2VA requests, not Ref2VA.
|
||||
@@ -869,51 +869,13 @@ balanced switch order.
|
||||
|
||||
### Turbo LoRA
|
||||
|
||||
The eight Diffusers-layout LightX2V Turbo artifacts are supported. The
|
||||
filename records the contract, so the server reads the step count, task family
|
||||
and flow shift from it and validates each request against the artifact that is
|
||||
loaded. It does not rewrite request or deploy-config sampling values: the
|
||||
request must carry that artifact's own settings, listed here, or it is
|
||||
rejected.
|
||||
Only the native Diffusers 4-step FL2VA/T2VA v1.0 artifact is supported:
|
||||
|
||||
| Artifact | Task | Forwards | `num_inference_steps` | `flow_shift` | declared `alpha` |
|
||||
| --- | --- | ---: | ---: | ---: | ---: |
|
||||
| `minimax_h3_fl2v_turbo_4step_v0.1.safetensors` | T2VA / FL2VA | 4 | 5 | 12 | none -> 8 |
|
||||
| `minimax_h3_fl2v_turbo_4step_v1.0_768p_bf16.safetensors` | T2VA / FL2VA | 4 | 5 | 6 | 128 |
|
||||
| `minimax_h3_fl2v_turbo_4step_v1.1_768p_bf16.safetensors` | T2VA / FL2VA | 4 | 5 | 6 | 128 |
|
||||
| `minimax_h3_fl2v_turbo_4step_v1.2_768p_bf16.safetensors` | T2VA / FL2VA | 4 | 5 | 6 | 8 |
|
||||
| `minimax_h3_fl2v_turbo_8step_v1.0_bf16.safetensors` | T2VA / FL2VA | 8 | 9 | 12 | 8 |
|
||||
| `minimax_h3_fl2v_turbo_8step_v1.0_768p_bf16.safetensors` | T2VA / FL2VA | 8 | 9 | 6 | 8 |
|
||||
| `minimax_h3_ref2v_turbo_4step_v0.1_bf16.safetensors` | Ref2VA | 4 | 5 | 12 | 8 |
|
||||
| `minimax_h3_ref2v_turbo_8step_v1.0_768p_bf16.safetensors` | Ref2VA | 8 | 9 | 6 | 8 |
|
||||
```text
|
||||
lightx2v/Minimax-h3-Turbo/minimax_h3_fl2v_turbo_4step_v1.0_768p_bf16.safetensors
|
||||
```
|
||||
|
||||
`audio_flow_shift` is `3.0` across the family. Each row is the complete
|
||||
published filename; use it verbatim as `TURBO_FILE` below.
|
||||
|
||||
Alpha needs no manual compensation: the server reads it from the artifact's
|
||||
metadata, falling back to 8 with a warning for
|
||||
`minimax_h3_fl2v_turbo_4step_v0.1`, the one artifact that declares none. The
|
||||
request-level `scale` is a further multiplier on top of it.
|
||||
|
||||
> [!NOTE]
|
||||
> Every artifact is rank 128 and the delta is applied at `scale * alpha /
|
||||
> rank`, so the `alpha=8` rows drive at 1/16 the strength of the `alpha=128`
|
||||
> rows. 8 is the default of LightX2V's reference script, which never reads the
|
||||
> metadata; its documented `v0.1` command does not override that default.
|
||||
|
||||
Every artifact except `minimax_h3_fl2v_turbo_4step_v0.1` also ships a
|
||||
`_comfyui_` export of the same weights. Those fuse Q/K/V into one projection
|
||||
and are **not** supported; downloading one is refused by name. Take the
|
||||
Diffusers file. The filename is the contract, so do not rename an artifact
|
||||
either -- a renamed file is rejected rather than served on a guess.
|
||||
|
||||
FL2VA artifacts serve `t2va` and `fl2va` on any FL2VA or combined server.
|
||||
Ref2VA artifacts require
|
||||
`--task-type ref2va`: a combined server serves `ref2va` from a second DiT that
|
||||
the adapter cannot bind to, so loading one there is refused rather than silently
|
||||
running an undistilled model on the few-step schedule.
|
||||
|
||||
Download the artifact you want:
|
||||
Download only that file:
|
||||
|
||||
```bash
|
||||
export TURBO_DIR=/path/to/minimax-h3-turbo
|
||||
@@ -922,19 +884,10 @@ hf download lightx2v/Minimax-h3-Turbo "${TURBO_FILE}" --local-dir "${TURBO_DIR}"
|
||||
export TURBO_LORA="${TURBO_DIR}/${TURBO_FILE}"
|
||||
```
|
||||
|
||||
`--lora-path` accepts one artifact, or a directory holding exactly one.
|
||||
|
||||
> [!IMPORTANT]
|
||||
> This changes earlier behaviour. `--lora-path /path/to/minimax-h3-turbo`
|
||||
> pointing at a full clone of the Turbo repository used to select the v1.0 768p
|
||||
> file implicitly; a directory holding several recognized artifacts is now
|
||||
> rejected as ambiguous. Name the artifact instead:
|
||||
> `--lora-path /path/to/minimax-h3-turbo/minimax_h3_fl2v_turbo_4step_v1.0_768p_bf16.safetensors`.
|
||||
|
||||
Start from a non-offloaded or DLO FL2VA server command and add
|
||||
`--task-type fl2va --lora-backend peft --lora-path "${TURBO_LORA}"`.
|
||||
`--lora-path` preloads the adapter; each request still activates it and must
|
||||
carry that artifact's sampling settings:
|
||||
`--lora-path` preloads the adapter; each request still activates it and uses
|
||||
the published sampling settings:
|
||||
|
||||
```bash
|
||||
-F 'num_inference_steps=5' \
|
||||
@@ -943,25 +896,14 @@ carry that artifact's sampling settings:
|
||||
-F "lora={\"name\":\"h3-turbo-v1.0\",\"path\":\"${TURBO_LORA}\",\"scale\":1.0}"
|
||||
```
|
||||
|
||||
Switching to another FL2VA artifact means repointing `TURBO_FILE`, which moves
|
||||
both `--lora-path` and the request's `lora.path`, and carrying that row's
|
||||
`num_inference_steps` and `flow_shift`: `9` and `6` for `8step_v1.0_768p`, `9`
|
||||
and `12` for the 544p `8step_v1.0`. A request that does not match the loaded
|
||||
artifact is rejected, so a mismatch cannot silently degrade output.
|
||||
|
||||
The two `ref2v` rows are not served by this FL2VA command. Start a
|
||||
`--task-type ref2va` server, take a request from
|
||||
[Ref2VA](#3-ref2va-image-only-imageaudio-or-mixed-references) and override
|
||||
`num_inference_steps` and `flow_shift` with that row's values; those examples
|
||||
already send `audio_flow_shift=3.0`.
|
||||
|
||||
For FL2VA, change `task` and add `input_reference` as shown above. This
|
||||
integration is dynamic-only and does not support prefusion or LoRA composition. DLO is
|
||||
For FL2VA, change `task` and add `input_reference` as shown above. The 8-step,
|
||||
ComfyUI, Ref2VA, and v1.1 artifacts are not supported. This integration is
|
||||
dynamic-only and does not support prefusion or LoRA composition. DLO is
|
||||
supported by keeping the request-switchable LoRA A/B buffers resident on the
|
||||
accelerator while DLO streams only the base blocks; budget for this additional
|
||||
fixed HBM usage. Model-level and standard layerwise offload remain unsupported.
|
||||
The requested sigma points always number one more than the artifact's denoiser
|
||||
evaluations.
|
||||
The five requested sigma points produce the four denoiser evaluations expected
|
||||
by the Turbo artifact.
|
||||
|
||||
### FlashGen native LoRA
|
||||
|
||||
|
||||
@@ -263,94 +263,6 @@ curl -X POST http://localhost:8091/v1/audio/speech \
|
||||
gpu_memory_utilization: 0.15
|
||||
```
|
||||
|
||||
### 1x A100 40GB (0.6B CustomVoice)
|
||||
|
||||
#### Environment
|
||||
|
||||
- OS: Linux 4.18.0-553 (RHEL 8.10), x86_64
|
||||
- Python: 3.12.14
|
||||
- PyTorch: 2.13.0+cu129
|
||||
- Driver / runtime: NVIDIA 570.124.06 / CUDA 12.8 (`nvidia-smi`); PyTorch CUDA 12.9
|
||||
- GPU: NVIDIA A100-SXM4-40GB, 40960 MiB
|
||||
- vLLM version: 0.28.0+cu129
|
||||
- vLLM-Omni version or commit: `3204a0b2ade0f05424b7f11e3bcc03cb3542e0c6`
|
||||
|
||||
#### Command
|
||||
|
||||
```bash
|
||||
vllm serve Qwen/Qwen3-TTS-12Hz-0.6B-CustomVoice \
|
||||
--deploy-config vllm_omni/deploy/qwen3_tts.yaml \
|
||||
--omni --port 8091
|
||||
```
|
||||
|
||||
The default deploy config (`qwen3_tts.yaml`) works without modification on this
|
||||
A100 40GB. Both stages (talker + code2wav) share GPU 0 with
|
||||
`gpu_memory_utilization: 0.3` each.
|
||||
|
||||
#### Verification
|
||||
|
||||
**English synthesis:**
|
||||
|
||||
```bash
|
||||
curl -X POST http://localhost:8091/v1/audio/speech \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{
|
||||
"input": "Hello, this is Qwen3-TTS running on A100 40GB.",
|
||||
"voice": "vivian",
|
||||
"language": "English"
|
||||
}' --output test_english.wav
|
||||
```
|
||||
|
||||
**Chinese synthesis:**
|
||||
|
||||
```bash
|
||||
curl -X POST http://localhost:8091/v1/audio/speech \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{
|
||||
"input": "你好,这是在A100 40GB上运行的语音合成测试。",
|
||||
"voice": "vivian",
|
||||
"language": "Chinese"
|
||||
}' --output test_chinese.wav
|
||||
```
|
||||
|
||||
**With emotion instruction:**
|
||||
|
||||
```bash
|
||||
curl -X POST http://localhost:8091/v1/audio/speech \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{
|
||||
"input": "I am so excited about this!",
|
||||
"voice": "vivian",
|
||||
"language": "English",
|
||||
"instructions": "Speak with great enthusiasm"
|
||||
}' --output test_emotion.wav
|
||||
```
|
||||
|
||||
#### Notes
|
||||
|
||||
- Memory usage: **16283 MiB / 40960 MiB** peak (`nvidia-smi`) during the three
|
||||
verification requests with the default deploy config
|
||||
(`gpu_memory_utilization: 0.3` per stage). Stage 0 used 12404 MiB and stage 1
|
||||
used 3862 MiB. The 0.6B weights occupy only ~2.4 GiB (Stage 0: 1.91 GiB,
|
||||
Stage 1: 0.45 GiB); the rest is KV cache reserved as a fraction of device
|
||||
memory, so the same `0.3` setting reads higher in GiB on 40GB than the
|
||||
~13.5 GiB idle figure on the 24GB 4090 profile above. To shrink the
|
||||
reservation, use the `gpu_memory_utilization: 0.15` override documented in
|
||||
that 4090 section.
|
||||
- vLLM 0.28.0's default wheel targets CUDA 13.0. Driver 570 cannot load that
|
||||
variant. This qualification used the official CUDA 12.9 wheel (same pin as
|
||||
the A100 Wan2.2 recipe):
|
||||
|
||||
```bash
|
||||
uv pip install \
|
||||
'https://github.com/vllm-project/vllm/releases/download/v0.28.0/vllm-0.28.0%2Bcu129-cp38-abi3-manylinux_2_28_x86_64.whl' \
|
||||
--torch-backend=cu129
|
||||
```
|
||||
|
||||
Confirm `torch.__version__` contains `cu129`. If a CPU build is already
|
||||
installed, `uv pip install --torch-backend=cu129` is a no-op; use
|
||||
`--reinstall`.
|
||||
|
||||
### 1x AMD MI300X, 1.7B checkpoints
|
||||
|
||||
#### Environment
|
||||
|
||||
@@ -42,7 +42,6 @@ recipes/
|
||||
| -------- | ------ | ---------- |
|
||||
| [`Baidu/ERNIE-Image.md`](./Baidu/ERNIE-Image.md) | Text-to-image online serving (ERNIE-Image 8B) | 1x or 2x RTX 4090 24GB |
|
||||
| [`Bagel/BAGEL-7B-MoT.md`](./Bagel/BAGEL-7B-MoT.md) | Text-to-image with shared online/offline examples | 1x A100 80GB / 2x CUDA GPUs |
|
||||
| [`black-forest-labs/FLUX.1-schnell.md`](./black-forest-labs/FLUX.1-schnell.md) | Offline text-to-image generation with CPU offload | 1x NVIDIA GeForce RTX 5090 32GB |
|
||||
| [`Boogu/Boogu-Image.md`](./Boogu/Boogu-Image.md) | Text-to-image online serving (Boogu-Image-0.1-Base) | 1x A100/H100 40GB+ |
|
||||
| [`BosonAI/Higgs-Audio-V3-TTS.md`](./BosonAI/Higgs-Audio-V3-TTS.md) | Online + offline multilingual TTS with voice cloning | 1x H100 80GB |
|
||||
| [`ByteDance/Lance.md`](./ByteDance/Lance.md) | Unified AR+diffusion: text/img/video gen + understanding (Lance 3B) | 1x B300 / A100 80GB |
|
||||
@@ -86,7 +85,6 @@ recipes/
|
||||
| [`Tencent/Covo-Audio-Chat.md`](./Tencent/Covo-Audio-Chat.md) | Online serving for audio chat | 1x A100 80GB |
|
||||
| [`Tencent/HunyuanImage-3.0-Instruct.md`](./Tencent/HunyuanImage-3.0-Instruct.md) | DiT-only text-to-image serving and benchmark, including ModelOpt mixed FP8/NVFP4 | 4x H100/H800 80GB / 2x B200 |
|
||||
| [`Wan-AI/Wan2.2-T2V.md`](./Wan-AI/Wan2.2-T2V.md) | Text-to-video serving (Wan2.2 14B) with Skip-Softmax sparse attention | 1x datacenter Blackwell (B200/B300) |
|
||||
| [`Wan-AI/Wan2.2-TI2V-5B-A100.md`](./Wan-AI/Wan2.2-TI2V-5B-A100.md) | Unified 720p text-to-video and image-to-video serving (Wan2.2 5B) | 1x A100-SXM4-80GB |
|
||||
| [`Wan-AI/Wan2.2-I2V.md`](./Wan-AI/Wan2.2-I2V.md) | Image-to-video serving (Wan2.2 14B) | 8x Ascend NPU (A2/A3) |
|
||||
| [`Wan-AI/Wan2.2-S2V.md`](./Wan-AI/Wan2.2-S2V.md) | Speech-to-video serving (Wan2.2 14B) | 2x A100/H100 80GB |
|
||||
| [`Wan-AI/Wan2.1-VACE.md`](./Wan-AI/Wan2.1-VACE.md) | Unified T2V, I2V, V2LF, FLF2V, inpaint, and R2V | 1x RTX 5090 (1.3B) / 1x L40S 48GB with layerwise offload (14B) |
|
||||
|
||||
@@ -7,31 +7,13 @@
|
||||
- Vendor: Robbyant
|
||||
- Model: `robbyant/lingbot-world-v2-14b-causal-fast-diffusers`
|
||||
- Task: image-conditioned interactive world generation
|
||||
- Modes: offline trajectory replay, stepwise one-request streaming, and in-process realtime AR-Diffusion ticks (deprecated)
|
||||
- Modes: offline trajectory replay and in-process realtime AR-Diffusion ticks
|
||||
- Hardware validated: NVIDIA H200 and B200
|
||||
- Maintainer: Community
|
||||
|
||||
The checkpoint is separately licensed under CC BY-NC-SA and restricted to
|
||||
non-commercial use. The vLLM-Omni integration code remains Apache-2.0.
|
||||
|
||||
## Which path to use
|
||||
|
||||
There are three ways to drive this model, each documented in its own section
|
||||
below.
|
||||
|
||||
- **Realtime stepwise** — see [Streaming video serving](#streaming-video-serving).
|
||||
The suggested path: one `WS /v1/realtime/video` session produces the whole
|
||||
rollout, one video chunk per AR block. It cannot take realtime camera
|
||||
interaction yet; that is being added, and this path is the one that will
|
||||
remain.
|
||||
- **Realtime tick** *(deprecated)* — see
|
||||
[Realtime in-process generation](#realtime-in-process-generation-deprecated).
|
||||
The only path that takes realtime camera interaction today, so it stays until
|
||||
the stepwise path can, but it takes no new work and will be removed.
|
||||
- **Offline** — see [Offline generation](#offline-generation). Replays a fixed
|
||||
pose/intrinsics trajectory in one request and writes an MP4. Use it when the
|
||||
camera path is known up front and streaming is not needed.
|
||||
|
||||
## Offline generation
|
||||
|
||||
The offline path consumes one source image and an action directory containing
|
||||
@@ -52,12 +34,7 @@ counts must be `9 + 12k`, up to 117 frames. Camera files may contain a
|
||||
longer bounded source trajectory (the official example contains 269 frames);
|
||||
the runtime consumes only the prefix needed by the request.
|
||||
|
||||
## Realtime in-process generation (deprecated)
|
||||
|
||||
Use [Streaming video serving](#streaming-video-serving) instead unless you need
|
||||
mid-session camera interaction, which only this path has. It still works and
|
||||
emits no runtime warning; removal is tracked as B4 of the LingBot World 2.0
|
||||
roadmap ([#6672](https://github.com/vllm-project/vllm-omni/issues/6672)).
|
||||
## Realtime in-process generation
|
||||
|
||||
The realtime example keeps AR-Diffusion KV and model-owned state across
|
||||
requests. Each JSONL line describes the prompt and/or three latent-frame camera
|
||||
@@ -84,81 +61,12 @@ exercises the same `ARDiffusionSessionManager -> ARDiffusionOmniTickConsumer
|
||||
-> AsyncOmni -> ARDiffusionEngine` path used by a future HTTP or WebSocket
|
||||
transport.
|
||||
|
||||
Realtime serving now goes through the generic `WS /v1/realtime/video`
|
||||
transport, which exposes no LingBot-specific event fields; the tick loop above
|
||||
stays available only for the older control plane.
|
||||
|
||||
## Streaming video serving
|
||||
|
||||
The stepwise path keeps AR-Diffusion paged KV but issues **one** request for
|
||||
the whole rollout: `prepare_encode` runs once, then every AR block is four DMD
|
||||
steps followed by one streamed chunk. Identity metadata uses
|
||||
`session_id = request_id` with contiguous `chunk_index` values from zero.
|
||||
Camera motion for this landing is request-scoped: one three-frame action list
|
||||
per chunk, fixed when the rollout starts.
|
||||
|
||||
Serve it with the AR-Diffusion deploy config, which selects the AR-Diffusion
|
||||
engine and enables streamed step execution:
|
||||
|
||||
```bash
|
||||
vllm serve robbyant/lingbot-world-v2-14b-causal-fast-diffusers \
|
||||
--omni \
|
||||
--deploy-config vllm_omni/deploy/lingbot_world_v2_stepwise.yaml \
|
||||
--port 8000
|
||||
```
|
||||
|
||||
`--deploy-config` is required: the `lingbot_world` pipeline deliberately
|
||||
registers no default deploy config, so offline replay and the tick example
|
||||
keep their request-mode topology when no deploy config is given, and the
|
||||
stepwise serving topology is only ever an explicit choice.
|
||||
|
||||
Clients then use the generic WebSocket protocol documented in
|
||||
[`docs/serving/video_stream_api.md`](../../docs/serving/video_stream_api.md):
|
||||
`session.start` begins one rollout and each AR block arrives as a binary video
|
||||
chunk. The model is image-conditioned, so the first frame is required and rides
|
||||
on `image_reference` as an `http(s)` or `data:` URL; per-chunk camera actions
|
||||
ride on `extra_params`:
|
||||
|
||||
```json
|
||||
{"type": "session.start", "model": "robbyant/lingbot-world-v2-14b-causal-fast-diffusers",
|
||||
"prompt": "The camera moves slowly forward through the scene.",
|
||||
"image_reference": {"image_url": "data:image/png;base64,<first frame>"},
|
||||
"width": 832, "height": 480, "num_frames": 33,
|
||||
"extra_params": {"flow_shift": 5.0,
|
||||
"camera_action_script": [[["w"], ["w"], ["w"]], [["a"], [], []], [[], [], []]]}}
|
||||
```
|
||||
|
||||
`camera_action_script` must hold exactly one action list per generated
|
||||
chunk, and a request generates `((num_frames - 1) // 4 + 1) // 3` chunks:
|
||||
three for `num_frames: 33`, seven for `num_frames: 81`.
|
||||
|
||||
The bundled client speaks this protocol:
|
||||
|
||||
```bash
|
||||
python examples/online_serving/streaming_video_generation/streaming_video_client.py \
|
||||
--model robbyant/lingbot-world-v2-14b-causal-fast-diffusers \
|
||||
--prompt "The camera moves slowly forward through the scene." \
|
||||
--image-reference /path/to/first_frame.png \
|
||||
--width 832 --height 480 --num-frames 33 --fps 16 --seed 42 \
|
||||
--extra-params '{"camera_action_script":[[["w"],["w"],["w"]],[["a"],[],[]],[[],[],[]]]}' \
|
||||
--output lingbot_world_v2_stream.mp4
|
||||
```
|
||||
|
||||
A served request may instead point at a pose/intrinsics trajectory with
|
||||
`extra_params.action_path`, which is resolved inside the trusted root set by
|
||||
`model_config.lingbot_action_root` or `VLLM_OMNI_LINGBOT_ACTION_ROOT`; a server
|
||||
started without that root configured accepts only `camera_action_script`.
|
||||
|
||||
Requested `width`/`height` must match `ar_diffusion_width`/`ar_diffusion_height`
|
||||
in the deploy config, because the AR cache geometry is fixed at load time.
|
||||
Blocks are decoded independently, so seams between chunks are possible; a
|
||||
session-owned streaming decoder is tracked separately.
|
||||
|
||||
Mid-session `session.interaction` for camera control is not wired yet, so a
|
||||
served rollout follows the script it started with.
|
||||
|
||||
The deprecated tick example remains available for the older
|
||||
one-block-per-`generate()` control plane.
|
||||
This PR intentionally does not define a public realtime HTTP/WebSocket schema.
|
||||
An online serving client should be added together with the public transport
|
||||
API rather than exposing LingBot-specific event fields from the generic model
|
||||
runtime. The structured camera-interaction frontend and transport work is
|
||||
tracked separately in
|
||||
[vllm-project/vllm-omni#5527](https://github.com/vllm-project/vllm-omni/pull/5527).
|
||||
|
||||
## Realtime identity and controls
|
||||
|
||||
@@ -196,16 +104,10 @@ tested commit.
|
||||
## Current limitations
|
||||
|
||||
- Only the 14B causal-fast checkpoint is supported.
|
||||
- The tick control plane is internal; the public transport is the stepwise
|
||||
`WS /v1/realtime/video` path, which cannot take mid-session camera
|
||||
interaction yet.
|
||||
- Stepwise serving requires an explicit
|
||||
`--deploy-config vllm_omni/deploy/lingbot_world_v2_stepwise.yaml`; there is
|
||||
no default deploy config for this model.
|
||||
- The realtime control plane is internal; there is no public server transport yet.
|
||||
- AR-Diffusion stages currently require one replica because session-affine
|
||||
routing across replicas is not implemented.
|
||||
- Tick mode generates one AR block per request. Stepwise mode generates many
|
||||
AR blocks in one request. `max_num_seqs` must be one in both cases.
|
||||
- One AR block is generated per request and `max_num_seqs` must be one.
|
||||
- Stateful streaming VAE decode is not implemented; the realtime example emits
|
||||
latent chunks.
|
||||
- SP/USP, pipeline/CFG parallelism, HSDP, VAE parallelism, quantization,
|
||||
@@ -217,7 +119,4 @@ tested commit.
|
||||
- Checkpoint: <https://huggingface.co/robbyant/lingbot-world-v2-14b-causal-fast-diffusers>
|
||||
- Official implementation: <https://github.com/robbyant/lingbot-world-v2>
|
||||
- Offline example: [`examples/offline_inference/diffusion/lingbot_world_v2.py`](../../examples/offline_inference/diffusion/lingbot_world_v2.py)
|
||||
- Streaming serving client: [`examples/online_serving/streaming_video_generation/`](../../examples/online_serving/streaming_video_generation/README.md)
|
||||
- Streaming serving end-to-end test: [`tests/e2e/online_serving/test_lingbot_world_v2_stepwise.py`](../../tests/e2e/online_serving/test_lingbot_world_v2_stepwise.py)
|
||||
- Stepwise latent-level end-to-end test: [`tests/e2e/offline_inference/test_lingbot_world_v2_stepwise.py`](../../tests/e2e/offline_inference/test_lingbot_world_v2_stepwise.py)
|
||||
- Realtime design: [`docs/design/feature/realtime_ar_diffusion.md`](../../docs/design/feature/realtime_ar_diffusion.md)
|
||||
@@ -1,184 +0,0 @@
|
||||
# Wan2.2 TI2V 5B — A100 80GB
|
||||
|
||||
> Single-GPU, native 720p text-to-video and image-to-video serving
|
||||
|
||||
## Summary
|
||||
|
||||
- Vendor: Wan-AI
|
||||
- Model: `Wan-AI/Wan2.2-TI2V-5B-Diffusers`
|
||||
- Task: Unified text-to-video (T2V) and image-to-video (I2V) generation
|
||||
- Mode: Online serving with the OpenAI-compatible Videos API
|
||||
- Hardware: 1x NVIDIA A100-SXM4-80GB
|
||||
- Maintainer: Community
|
||||
|
||||
## When to use this recipe
|
||||
|
||||
Use this recipe to serve both T2V and I2V from one dense 5B checkpoint on one
|
||||
A100 80GB. It qualifies the model's native 720p profile without CPU offload or
|
||||
multi-GPU parallelism. The synchronous endpoint is used below because it
|
||||
returns the MP4 and request timing in one response; the asynchronous Videos API
|
||||
uses the same server and sampling parameters.
|
||||
|
||||
## Supported model contract
|
||||
|
||||
| Task | Required input | Qualified output | Endpoint |
|
||||
| --- | --- | --- | --- |
|
||||
| T2V | Text prompt; omit `input_reference` | 1280x704, 121 frames, 24 fps | `POST /v1/videos/sync` |
|
||||
| I2V | Text prompt plus one image uploaded as `input_reference` | 1280x704, 121 frames, 24 fps | `POST /v1/videos/sync` |
|
||||
|
||||
The upstream checkpoint supports both tasks at 720p and 24 fps. For native
|
||||
landscape 720p, use `1280x704`; portrait generation uses `704x1280`. Wan video
|
||||
lengths follow the temporal VAE contract (`4k+1` frames). This recipe validates
|
||||
one output per request with 50 denoising steps and seed 42.
|
||||
|
||||
## References
|
||||
|
||||
- Upstream model card:
|
||||
<https://huggingface.co/Wan-AI/Wan2.2-TI2V-5B-Diffusers>
|
||||
- Online T2V example:
|
||||
[`examples/online_serving/text_to_video`](../../examples/online_serving/text_to_video)
|
||||
- Online I2V example:
|
||||
[`examples/online_serving/image_to_video`](../../examples/online_serving/image_to_video)
|
||||
- Offline I2V example:
|
||||
[`examples/offline_inference/image_to_video`](../../examples/offline_inference/image_to_video)
|
||||
- Community recipe tracker:
|
||||
[vllm-project/vllm-omni#2645](https://github.com/vllm-project/vllm-omni/issues/2645)
|
||||
|
||||
## Hardware
|
||||
|
||||
- Accelerator model and per-device memory: NVIDIA A100-SXM4-80GB, 81,920 MiB
|
||||
- Number of devices: 1
|
||||
- Device interconnect: not applicable to this single-GPU profile
|
||||
- Host memory: 1 TiB installed on the qualification host; CPU offload was not used
|
||||
- Qualification scope: BF16, batch size 1, native FlashAttention, eager mode,
|
||||
VAE tiling, T2V and I2V at 1280x704 / 121 frames / 24 fps
|
||||
|
||||
## Software environment
|
||||
|
||||
- OS: Ubuntu 24.04.3 LTS, Linux 6.8.0
|
||||
- Python: 3.12.3
|
||||
- NVIDIA driver / host toolkit: 550.127.05 / CUDA 12.8
|
||||
- PyTorch: 2.13.0+cu129
|
||||
- Transformers / Diffusers: 5.14.1 / 0.40.0
|
||||
- vLLM: 0.28.0+cu129
|
||||
- vLLM-Omni: commit `ff6e906a25de1ca3122c0d0d5250fde5a0ddbc7b`
|
||||
|
||||
The default vLLM 0.28.0 wheel targets CUDA 13.0. Driver 550 cannot run that
|
||||
variant, so this qualification used the official CUDA 12.9 wheel:
|
||||
|
||||
```bash
|
||||
uv venv --python 3.12 --seed
|
||||
source .venv/bin/activate
|
||||
uv pip install \
|
||||
'https://github.com/vllm-project/vllm/releases/download/v0.28.0/vllm-0.28.0%2Bcu129-cp38-abi3-manylinux_2_28_x86_64.whl' \
|
||||
--torch-backend=auto
|
||||
uv pip install -e .
|
||||
```
|
||||
|
||||
## Command
|
||||
|
||||
Start the server from the repository root:
|
||||
|
||||
```bash
|
||||
vllm serve Wan-AI/Wan2.2-TI2V-5B-Diffusers \
|
||||
--omni \
|
||||
--port 8092 \
|
||||
--vae-use-tiling \
|
||||
--enforce-eager
|
||||
```
|
||||
|
||||
In another terminal, download the public reference image:
|
||||
|
||||
```bash
|
||||
wget -O cherry_blossom.jpg \
|
||||
https://vllm-public-assets.s3.us-west-2.amazonaws.com/vision_model_images/cherry_blossom.jpg
|
||||
```
|
||||
|
||||
Generate a text-only video:
|
||||
|
||||
```bash
|
||||
curl --fail-with-body -D t2v-headers.txt \
|
||||
-X POST http://127.0.0.1:8092/v1/videos/sync \
|
||||
-F "prompt=Two anthropomorphic cats in comfortable boxing gear and bright gloves fight intensely on a spotlighted stage, cinematic lighting, smooth motion." \
|
||||
-F "negative_prompt=blurry, low quality, static, distorted, artifacts, watermark, text" \
|
||||
-F "width=1280" -F "height=704" \
|
||||
-F "num_frames=121" -F "fps=24" \
|
||||
-F "num_inference_steps=50" -F "guidance_scale=5.0" \
|
||||
-F "flow_shift=5.0" -F "seed=42" \
|
||||
--output wan22-ti2v-5b-t2v.mp4
|
||||
```
|
||||
|
||||
Generate an image-conditioned video from the same server:
|
||||
|
||||
```bash
|
||||
curl --fail-with-body -D i2v-headers.txt \
|
||||
-X POST http://127.0.0.1:8092/v1/videos/sync \
|
||||
-F "input_reference=@cherry_blossom.jpg" \
|
||||
-F "prompt=Cherry blossoms sway gently in the breeze while petals drift across the path, cinematic, smooth natural motion." \
|
||||
-F "negative_prompt=blurry, low quality, static, distorted, artifacts, watermark, text" \
|
||||
-F "width=1280" -F "height=704" \
|
||||
-F "num_frames=121" -F "fps=24" \
|
||||
-F "num_inference_steps=50" -F "guidance_scale=5.0" \
|
||||
-F "flow_shift=5.0" -F "seed=42" \
|
||||
--output wan22-ti2v-5b-i2v.mp4
|
||||
```
|
||||
|
||||
## Verification
|
||||
|
||||
Check both MP4 files with `ffprobe`:
|
||||
|
||||
```bash
|
||||
for video in wan22-ti2v-5b-t2v.mp4 wan22-ti2v-5b-i2v.mp4; do
|
||||
ffprobe -v error -select_streams v:0 -count_frames \
|
||||
-show_entries stream=codec_name,width,height,r_frame_rate,nb_read_frames,duration \
|
||||
-of default=noprint_wrappers=1 "$video"
|
||||
done
|
||||
```
|
||||
|
||||
Each file reported:
|
||||
|
||||
```text
|
||||
codec_name=h264
|
||||
width=1280
|
||||
height=704
|
||||
r_frame_rate=24/1
|
||||
duration=5.041667
|
||||
nb_read_frames=121
|
||||
```
|
||||
|
||||
The synchronous response headers and an independent 200 ms `nvidia-smi`
|
||||
sampler produced these steady-state results after server warmup:
|
||||
|
||||
| Task | HTTP | `X-Inference-Time-S` | Server peak | Observed device peak | MP4 size |
|
||||
| --- | ---: | ---: | ---: | ---: | ---: |
|
||||
| T2V | 200 | 288.267 s | 26,546 MB | 27,533 MiB | 7,321,179 bytes |
|
||||
| I2V | 200 | 299.439 s | 29,766 MB | 30,333 MiB | 15,667,146 bytes |
|
||||
|
||||
Both outputs were decoded in full and visually inspected. The T2V output
|
||||
contained the prompted boxing cats. The I2V first frame preserved the uploaded
|
||||
cherry-blossom scene (5.81 mean absolute pixel error after resize and H.264
|
||||
encoding), and later frames showed motion.
|
||||
|
||||
## Notes
|
||||
|
||||
- Memory usage: model loading used 21.2239 GiB. The measured I2V device peak
|
||||
was 30,333 MiB, leaving more than 50 GiB free on this A100.
|
||||
- `--vae-use-tiling` is retained in the known-good command even though this
|
||||
profile has ample headroom; it bounds decode memory at 720p.
|
||||
- `--enforce-eager` removes graph-compilation variability from the measured
|
||||
profile. Remove it only after separately warming and measuring compiled mode.
|
||||
- `flow_shift=5.0` is the 720p setting. The shared 480p examples use 12.0.
|
||||
- The generated MP4 contains video only; this checkpoint does not generate audio.
|
||||
- The first request includes neither model-load time nor the server's startup
|
||||
warmup. Server initialization took approximately 26 seconds with a warm cache.
|
||||
|
||||
## Supported features
|
||||
|
||||
| Feature | Status for this profile | Shared guide |
|
||||
| --- | --- | --- |
|
||||
| OpenAI-compatible Videos API | Qualified for synchronous T2V and I2V | [Videos API](../../docs/serving/videos_api.md) |
|
||||
| VAE tiling | Enabled and qualified on one A100 | [VAE parallelism and tiling](../../docs/user_guide/diffusion/parallelism/vae_parallelism.md) |
|
||||
| Cache-DiT / TaylorSeer | Available but not enabled in the measurements above | [Cache-DiT](../../docs/user_guide/diffusion/cache_acceleration/cache_dit.md) |
|
||||
| TeaCache | Available but not qualified in this recipe | [TeaCache](../../docs/user_guide/diffusion/cache_acceleration/teacache.md) |
|
||||
| CPU or layerwise offload | Not needed for the qualified 80GB profile | [CPU offload](../../docs/user_guide/diffusion/cpu_offload.md) |
|
||||
| TP / SP / CFG parallelism | Not applicable to this single-GPU profile | [Parallelism overview](../../docs/user_guide/diffusion/parallelism/overview.md) |
|
||||
@@ -1,160 +0,0 @@
|
||||
# FLUX.1-schnell
|
||||
|
||||
> Offline text-to-image generation on one NVIDIA GeForce RTX 5090 32 GB
|
||||
|
||||
## Summary
|
||||
|
||||
- Vendor: Black Forest Labs
|
||||
- Model: `black-forest-labs/FLUX.1-schnell`
|
||||
- Task: Text-to-image generation
|
||||
- Mode: Offline inference with the shared text-to-image runner
|
||||
- Maintainer: Community
|
||||
|
||||
## When to use this recipe
|
||||
|
||||
Use this recipe as a personally validated starting point for generating a
|
||||
1024x1024 image with FLUX.1-schnell on one NVIDIA GeForce RTX 5090. The tested
|
||||
configuration uses BF16, four denoising steps and model-level CPU offload.
|
||||
|
||||
This recipe covers single-image generation. It does not attempt to optimize
|
||||
throughput with quantization or cache acceleration.
|
||||
|
||||
## References
|
||||
|
||||
- Model card: <https://huggingface.co/black-forest-labs/FLUX.1-schnell>
|
||||
- Canonical offline text-to-image guide:
|
||||
[`docs/user_guide/examples/offline_inference/text_to_image.md`](../../docs/user_guide/examples/offline_inference/text_to_image.md)
|
||||
- Shared runnable example:
|
||||
[`examples/offline_inference/text_to_image`](../../examples/offline_inference/text_to_image)
|
||||
- CPU offload guide:
|
||||
[`docs/user_guide/diffusion/cpu_offload.md`](../../docs/user_guide/diffusion/cpu_offload.md)
|
||||
- Community recipe tracker:
|
||||
[#2645](https://github.com/vllm-project/vllm-omni/issues/2645)
|
||||
|
||||
## Hardware Support
|
||||
|
||||
## GPU
|
||||
|
||||
### 1x NVIDIA GeForce RTX 5090 32 GB
|
||||
|
||||
This configuration was personally validated end to end on September 9, 2026.
|
||||
|
||||
#### Environment
|
||||
|
||||
- OS: Ubuntu 22.04.3 x86_64
|
||||
- Python: 3.12.7
|
||||
- GPU: 1x NVIDIA GeForce RTX 5090, 32,607 MiB reported by `nvidia-smi`
|
||||
- Host RAM: approximately 62 GiB (64 GB class)
|
||||
- NVIDIA driver: 595.71.05; CUDA 13.2 reported by `nvidia-smi`
|
||||
- PyTorch: 2.13.0+cu130; PyTorch CUDA runtime: 13.0
|
||||
- vLLM: 0.28.0
|
||||
- vLLM-Omni: `0.28.1.dev112+ga31690041`
|
||||
- Diffusers: 0.40.0
|
||||
- Transformers: 5.14.1
|
||||
|
||||
#### Command
|
||||
|
||||
Run the shared example from the vLLM-Omni repository root in an environment
|
||||
with vLLM-Omni installed:
|
||||
|
||||
```bash
|
||||
python examples/offline_inference/text_to_image/text_to_image.py \
|
||||
--model black-forest-labs/FLUX.1-schnell \
|
||||
--prompt 'A red fox standing in fresh snow, cinematic photography' \
|
||||
--height 1024 --width 1024 \
|
||||
--num-inference-steps 4 --guidance-scale 0 --seed 42 \
|
||||
--enable-cpu-offload \
|
||||
--output flux-schnell-rtx5090.png
|
||||
```
|
||||
|
||||
The command uses the public model ID for portability. The measured runs used
|
||||
already downloaded FLUX.1-schnell weights; initial Hub download and
|
||||
authentication were not part of the inference validation.
|
||||
|
||||
#### Verification
|
||||
|
||||
Verify that the runner succeeded and inspect the saved image:
|
||||
|
||||
```bash
|
||||
python - <<'PY'
|
||||
import hashlib
|
||||
from pathlib import Path
|
||||
|
||||
from PIL import Image, ImageStat
|
||||
|
||||
path = Path("flux-schnell-rtx5090.png")
|
||||
with Image.open(path) as image:
|
||||
image.load()
|
||||
assert image.format == "PNG"
|
||||
assert image.size == (1024, 1024)
|
||||
rgb = image.convert("RGB")
|
||||
stats = ImageStat.Stat(rgb)
|
||||
assert max(stats.stddev) > 1, "Image is nearly uniform"
|
||||
print(f"format={image.format}")
|
||||
print(f"size={image.width}x{image.height}")
|
||||
print(f"mode={image.mode}")
|
||||
print(f"bytes={path.stat().st_size}")
|
||||
print("rgb_mean=" + ",".join(f"{value:.3f}" for value in stats.mean))
|
||||
print(f"rgb_extrema={rgb.getextrema()}")
|
||||
|
||||
print(f"sha256={hashlib.sha256(path.read_bytes()).hexdigest()}")
|
||||
PY
|
||||
```
|
||||
|
||||
The repeated experiment completed 36 image requests (6 additional warmups and
|
||||
30 measured outputs) with successful process exits. Every PNG passed decoding,
|
||||
1024x1024 dimension and non-uniform pixel checks. SHA-256 hashes were recorded
|
||||
for the artifacts; matching those hashes is not required across environments.
|
||||
These checks establish file integrity, not a quantitative image-quality score.
|
||||
|
||||
#### Performance
|
||||
|
||||
The experiment used three independent processes. Each process initialized the
|
||||
model once, generated two warmup images, then generated ten measured images
|
||||
sequentially. All 30 measured images used BF16, CPU offload, 1024x1024, four
|
||||
steps, guidance scale 0 and TP=1, without concurrent requests.
|
||||
|
||||
| Generation measurement | Result |
|
||||
| --- | ---: |
|
||||
| Measured images | 30 |
|
||||
| Mean latency | 25.8411 seconds |
|
||||
| P95 latency (nearest-rank) | 26.1446 seconds |
|
||||
|
||||
| Startup / resource measurement | Maximum |
|
||||
| --- | ---: |
|
||||
| Model initialization (seconds) | 64.73 |
|
||||
| Full-lifetime RAM PSS peak (MiB) | 49306 |
|
||||
| Full-lifetime device GPU memory peak (MiB) | 28121 |
|
||||
| Measured PyTorch reserved GPU memory peak (MiB) | 27360 |
|
||||
|
||||
Latency measures only `Omni.generate()`, excluding image saving and
|
||||
verification. The two warmup images per process are excluded. P95 uses the
|
||||
nearest-rank method over the 30 measured images. Model initialization includes
|
||||
the engine's built-in dummy warmup; weights were already downloaded and OS file
|
||||
caches were not cleared.
|
||||
|
||||
RAM and whole-device GPU memory were sampled throughout each process lifetime
|
||||
at a target interval of 200 ms. RAM is the maximum simultaneous sum of PSS for
|
||||
the inference process and its workers, read from Linux `smaps_rollup`.
|
||||
Whole-device GPU memory is the maximum reported by `nvidia-smi`. Both are
|
||||
sampled peaks and may miss shorter spikes.
|
||||
|
||||
The PyTorch value is the maximum worker-reported `peak_memory_mb` across the
|
||||
30 measured requests. Despite the field name, its unit is MiB; it measures the
|
||||
PyTorch allocator's reserved-memory high-water mark rather than whole-device
|
||||
usage.
|
||||
|
||||
#### Notes
|
||||
|
||||
- `--enable-cpu-offload` swaps the transformer and text encoders between host
|
||||
and device memory at phase boundaries. It reduces GPU residency but adds
|
||||
transfer overhead and requires sufficient host RAM. The minimum host RAM
|
||||
requirement was not measured.
|
||||
- CPU offload does not imply CPU-only computation. The tested model-level
|
||||
offload backend keeps the VAE on the GPU.
|
||||
- Only offline single-image generation on one GPU with BF16, 1024x1024,
|
||||
four steps and CPU offload was validated. Online serving, FP8, other
|
||||
resolutions, concurrency, execution without offload and smaller host RAM
|
||||
configurations are outside this recipe's validated scope.
|
||||
- The upstream revision of the downloaded weights was not recorded, so the
|
||||
measurements do not establish exact checkpoint reproducibility.
|
||||
@@ -207,18 +207,6 @@ curl -sS -X POST http://localhost:8000/v1/videos/sync \
|
||||
-F 'extra_params={"depth":{"control_path":"/path/to/depth_control.mp4"},"max_frames":121,"resolution":"720","num_video_frames_per_chunk":121}' \
|
||||
-o cosmos3_transfer_depth.mp4
|
||||
|
||||
# The same transfer control can be uploaded by a remote client instead of
|
||||
# being placed on the server filesystem. Uploads are limited to 512 MiB.
|
||||
curl -sS -X POST http://localhost:8000/v1/videos/sync \
|
||||
-H "Accept: video/mp4" \
|
||||
-F "model=nvidia/Cosmos3-Nano" \
|
||||
-F "prompt=Generate a realistic scene following the provided world-state control." \
|
||||
-F "input_reference=@/path/to/input.mp4;type=video/mp4" \
|
||||
-F "control_reference=@/path/to/wsm.mp4;type=video/mp4" \
|
||||
-F "control_type=wsm" \
|
||||
-F 'extra_params={"wsm":{"control_weight":1.0},"max_frames":121,"resolution":"720","num_video_frames_per_chunk":121}' \
|
||||
-o cosmos3_transfer_wsm.mp4
|
||||
|
||||
# Text-to-video-with-sound
|
||||
curl -sS -X POST http://localhost:8000/v1/videos/sync \
|
||||
-H "Accept: video/mp4" \
|
||||
|
||||
@@ -36,13 +36,19 @@ Other hardware and configurations are welcome as community validation lands.
|
||||
|
||||
- OS: Linux
|
||||
- Python: 3.10+
|
||||
- Required package: `fish-speech` (for DAC codec)
|
||||
- CUDA 12.8
|
||||
- vLLM version: 0.19.0
|
||||
- vLLM-Omni version or commit: c93359bb354a6aa5c14d062430cb85b2c4db251e
|
||||
|
||||
No extra packages are required: the DAC codec architecture is vendored in
|
||||
vLLM-Omni (`vllm_omni/model_executor/models/fish_speech/dac_modules/`), so the
|
||||
model runs out of the box, including in the official Docker image.
|
||||
```bash
|
||||
# Install PortAudio dependency if missing (required by pyaudio which is a dependency of fish-speech)
|
||||
# For Ubuntu/Debian:
|
||||
if ! dpkg -l | grep -q libportaudio2; then
|
||||
sudo apt-get update && sudo apt-get install -y libportaudio2 portaudio19-dev
|
||||
fi
|
||||
pip install fish-speech
|
||||
```
|
||||
|
||||
#### Kvcache attention fast path
|
||||
|
||||
@@ -123,6 +129,7 @@ curl -X POST http://localhost:8091/v1/audio/speech \
|
||||
|
||||
- OS: Linux
|
||||
- Python: 3.10+
|
||||
- Required package: `fish-speech` (for DAC codec)
|
||||
- CUDA 12.8
|
||||
- vLLM version: 0.19.0+
|
||||
|
||||
|
||||
@@ -9,15 +9,13 @@
|
||||
# That breakage is now handled in code instead of by pinning:
|
||||
# MossTTSNanoForGeneration wraps weight loading in
|
||||
# transformers_keys_to_ignore_compat (vllm_omni/model_executor/models/utils.py).
|
||||
# Floor is 5.13.0 so transformers.integrations.hub_kernels LayerRepository
|
||||
# entries always pass version=/revision= required by kernels>=0.16 (#6971).
|
||||
transformers >= 5.13.0, < 5.15
|
||||
transformers >= 5.10.1, < 5.15
|
||||
av>=14.0.0
|
||||
omegaconf>=2.3.0
|
||||
diffusers==0.40.0
|
||||
# Hub kernels, including LTX-2.5 NATTEN. 0.16+ resolves torch-stable-abi*
|
||||
# FA3 builds on torch 2.13 / cu130; keep in sync with transformers above.
|
||||
kernels==0.16.1
|
||||
# Hub kernels, including LTX-2.5 NATTEN. Keep this pin in sync with the
|
||||
# supported transformers range above.
|
||||
kernels==0.15.2
|
||||
safetensors>=0.8.0
|
||||
accelerate==1.12.0
|
||||
soundfile>=0.13.1
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
# SPDX-FileCopyrightText: Copyright contributors to the vLLM-Omni project
|
||||
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
|
||||
|
||||
import pytest
|
||||
import torch
|
||||
@@ -214,20 +214,11 @@ def test_fish_kvcache_backend_wraps_only_model_instance(monkeypatch):
|
||||
assert fish_kvcache_backend.get_fish_kvcache_attn_stats()["small_hit_count"] == 1
|
||||
|
||||
|
||||
def _vllm_kv_cache_shape(num_blocks, block_size, num_kv_heads, head_size, dtype=torch.float16):
|
||||
def _vllm_kv_cache_shape(num_blocks, block_size, num_kv_heads, head_size):
|
||||
# Source of truth for the paged KV cache layout the backend must unpack.
|
||||
# vLLM 0.29 removed AttentionBackend.get_kv_cache_shape; the per-layer shape
|
||||
# now comes from the spec, with the content dim expressed in bytes.
|
||||
from vllm.v1.kv_cache_interface import FullAttentionSpec, compute_layer_kv_cache_shape_bytes
|
||||
from vllm.v1.attention.backends.flash_attn import FlashAttentionBackend
|
||||
|
||||
spec = FullAttentionSpec(
|
||||
block_size=block_size,
|
||||
num_kv_heads=num_kv_heads,
|
||||
head_size=head_size,
|
||||
dtype=dtype,
|
||||
)
|
||||
num_pages, num_heads, num_states, content_bytes = compute_layer_kv_cache_shape_bytes(spec, num_blocks)
|
||||
return (num_pages, num_heads, num_states, content_bytes // dtype.itemsize)
|
||||
return FlashAttentionBackend.get_kv_cache_shape(num_blocks, block_size, num_kv_heads, head_size)
|
||||
|
||||
|
||||
def test_fish_kvcache_backend_unbinds_kv_on_vllm_cache_layout(monkeypatch):
|
||||
|
||||
@@ -457,136 +457,5 @@ def test_text_benchmark_still_reports_ttft(capsys):
|
||||
assert "Time to First Token" in out, "text benchmarks must keep TTFT"
|
||||
|
||||
|
||||
# ============================================================================
|
||||
# Suppress text metrics for pure image / video endpoints
|
||||
# ============================================================================
|
||||
|
||||
|
||||
def _make_image_output(prompt_len: int) -> MixRequestFuncOutput:
|
||||
output = MixRequestFuncOutput()
|
||||
output.success = True
|
||||
output.prompt_len = prompt_len
|
||||
output.output_tokens = 0
|
||||
output.generated_text = ""
|
||||
output.ttft = 0.0
|
||||
output.text_latency = 0.0
|
||||
output.latency = 2.5
|
||||
output.start_time = 0.0
|
||||
output.itl = []
|
||||
output.image_count = 1
|
||||
output.image_generation_time_ms = 2000.0
|
||||
output.image_pixels = 1024 * 1024
|
||||
output.input_audio_duration = 0.0
|
||||
output.error = ""
|
||||
return output
|
||||
|
||||
|
||||
def _make_video_output(prompt_len: int) -> MixRequestFuncOutput:
|
||||
output = MixRequestFuncOutput()
|
||||
output.success = True
|
||||
output.prompt_len = prompt_len
|
||||
output.output_tokens = 0
|
||||
output.generated_text = ""
|
||||
output.ttft = 0.0
|
||||
output.text_latency = 0.0
|
||||
output.latency = 5.0
|
||||
output.start_time = 0.0
|
||||
output.itl = []
|
||||
output.video_duration = 2.0
|
||||
output.video_frames = 48
|
||||
output.video_generation_time_ms = 4000.0
|
||||
output.video_rtf = 2.0
|
||||
output.input_audio_duration = 0.0
|
||||
output.error = ""
|
||||
return output
|
||||
|
||||
|
||||
_MEDIA_PERCENTILE_METRICS = ["e2el", "ttft"]
|
||||
|
||||
|
||||
def test_pure_image_benchmark_omits_text_result(capsys):
|
||||
"""Pure image generation must not print Text Result or invent peak tok/s."""
|
||||
outputs = [_make_image_output(64), _make_image_output(64)]
|
||||
|
||||
metrics, actual_output_lens = calculate_metrics(
|
||||
input_requests=[],
|
||||
outputs=outputs,
|
||||
dur_s=5.0,
|
||||
tokenizer=None,
|
||||
selected_percentiles=[99.0],
|
||||
goodput_config_dict={},
|
||||
task_type=TaskType.GENERATION,
|
||||
selected_percentile_metrics=_MEDIA_PERCENTILE_METRICS,
|
||||
max_concurrency=None,
|
||||
request_rate=float("inf"),
|
||||
benchmark_duration=5.0,
|
||||
)
|
||||
|
||||
out = capsys.readouterr().out
|
||||
assert actual_output_lens == [0, 0]
|
||||
assert metrics.total_output == 0
|
||||
assert metrics.max_output_tokens_per_s == 0.0
|
||||
assert " Text Result " not in out
|
||||
assert "Peak output token throughput" not in out
|
||||
assert "Time to First Token" not in out
|
||||
assert " Image Result " in out
|
||||
|
||||
|
||||
def test_pure_video_benchmark_omits_text_result(capsys):
|
||||
"""Pure video generation must not print Text Result or invent peak tok/s."""
|
||||
outputs = [_make_video_output(63), _make_video_output(63)]
|
||||
|
||||
metrics, actual_output_lens = calculate_metrics(
|
||||
input_requests=[],
|
||||
outputs=outputs,
|
||||
dur_s=10.0,
|
||||
tokenizer=None,
|
||||
selected_percentiles=[99.0],
|
||||
goodput_config_dict={},
|
||||
task_type=TaskType.GENERATION,
|
||||
selected_percentile_metrics=_MEDIA_PERCENTILE_METRICS,
|
||||
max_concurrency=None,
|
||||
request_rate=float("inf"),
|
||||
benchmark_duration=10.0,
|
||||
)
|
||||
|
||||
out = capsys.readouterr().out
|
||||
assert actual_output_lens == [0, 0]
|
||||
assert metrics.total_output == 0
|
||||
assert metrics.max_output_tokens_per_s == 0.0
|
||||
assert " Text Result " not in out
|
||||
assert "Peak output token throughput" not in out
|
||||
assert "Time to First Token" not in out
|
||||
assert " Video Result " in out
|
||||
|
||||
|
||||
def test_image_with_generated_text_still_reports_text_result(capsys):
|
||||
"""Image edits / AR text alongside images must keep Text Result."""
|
||||
output = _make_image_output(64)
|
||||
output.output_tokens = 8
|
||||
output.generated_text = "revised caption"
|
||||
output.ttft = 0.05
|
||||
output.itl = [0.01] * 7
|
||||
|
||||
calculate_metrics(
|
||||
input_requests=[],
|
||||
outputs=[output],
|
||||
dur_s=3.0,
|
||||
tokenizer=_EmptyAwareTokenizer(),
|
||||
selected_percentiles=[99.0],
|
||||
goodput_config_dict={},
|
||||
task_type=TaskType.GENERATION,
|
||||
selected_percentile_metrics=_MEDIA_PERCENTILE_METRICS,
|
||||
max_concurrency=None,
|
||||
request_rate=float("inf"),
|
||||
benchmark_duration=3.0,
|
||||
)
|
||||
|
||||
out = capsys.readouterr().out
|
||||
assert " Text Result " in out
|
||||
assert "Time to First Token" in out
|
||||
assert " Image Result " in out
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
pytest.main([__file__, "-v", "-s"])
|
||||
@@ -22,16 +22,9 @@ from vllm_omni.benchmarks.data_modules.seed_tts_dataset import (
|
||||
)
|
||||
from vllm_omni.benchmarks.patch.patch import (
|
||||
MixRequestFuncOutput,
|
||||
_add_video_extra_body_to_form,
|
||||
_add_video_reference_to_form,
|
||||
_apply_stage0_token_timings,
|
||||
_apply_video_metrics_from_payload,
|
||||
_attach_seed_tts_to_request_func_input,
|
||||
_build_benchmark_session,
|
||||
_omni_request_timeout_s,
|
||||
async_request_openai_chat_omni_completions,
|
||||
async_request_openai_image_edits_omni,
|
||||
async_request_openai_image_generations_omni,
|
||||
async_request_openai_realtime_duplex,
|
||||
should_request_stage_metrics,
|
||||
)
|
||||
@@ -1203,337 +1196,5 @@ async def test_prompt_len_assigned_from_usage(mocker: MockerFixture):
|
||||
)
|
||||
|
||||
|
||||
class TestOmniRequestTimeout:
|
||||
"""``--omni-request-timeout-s`` precedence: explicit value > 900 s default."""
|
||||
|
||||
_OVERRIDE = "vllm_omni.benchmarks.patch.patch._REQUEST_TIMEOUT_OVERRIDE_S"
|
||||
|
||||
def test_default_timeout_is_900s_when_not_set(self, monkeypatch: pytest.MonkeyPatch) -> None:
|
||||
monkeypatch.setattr(self._OVERRIDE, None)
|
||||
assert _omni_request_timeout_s() == 900.0
|
||||
|
||||
def test_explicit_value_wins_over_default(self, monkeypatch: pytest.MonkeyPatch) -> None:
|
||||
monkeypatch.setattr(self._OVERRIDE, 123.5)
|
||||
assert _omni_request_timeout_s() == 123.5
|
||||
|
||||
def test_non_positive_restores_legacy_6h_cap(self, monkeypatch: pytest.MonkeyPatch) -> None:
|
||||
monkeypatch.setattr(self._OVERRIDE, 0)
|
||||
assert _omni_request_timeout_s() == 6 * 60 * 60.0
|
||||
|
||||
async def test_benchmark_session_uses_configured_timeout(self, monkeypatch: pytest.MonkeyPatch) -> None:
|
||||
monkeypatch.setattr(self._OVERRIDE, 42.0)
|
||||
session = _build_benchmark_session(max_concurrency=8, ssl_setting=False)
|
||||
try:
|
||||
assert session.timeout.total == 42.0
|
||||
assert session.connector.limit == 8
|
||||
assert session.connector.limit_per_host == 8
|
||||
finally:
|
||||
await session.close()
|
||||
|
||||
async def test_hung_server_request_times_out_as_failed(self, monkeypatch: pytest.MonkeyPatch) -> None:
|
||||
"""A server that accepts the request but never responds must surface as ``failed``."""
|
||||
|
||||
async def handler(reader, writer):
|
||||
# Drain the request but never respond — the original hang failure mode.
|
||||
try:
|
||||
while await reader.read(4096):
|
||||
pass
|
||||
except ConnectionResetError:
|
||||
pass
|
||||
finally:
|
||||
# Close our side of the socket: the client aborts after the
|
||||
# timeout and only sends FIN, so without writer.close() the
|
||||
# half-closed connection keeps Server.wait_closed() (which on
|
||||
# Python 3.12+ waits for every accepted connection to drop)
|
||||
# blocked forever.
|
||||
writer.close()
|
||||
try:
|
||||
await writer.wait_closed()
|
||||
except (ConnectionResetError, BrokenPipeError):
|
||||
pass
|
||||
|
||||
monkeypatch.setattr(self._OVERRIDE, 1.0)
|
||||
server = await asyncio.start_server(handler, "127.0.0.1", 0)
|
||||
port = server.sockets[0].getsockname()[1]
|
||||
session = _build_benchmark_session(max_concurrency=1, ssl_setting=False)
|
||||
try:
|
||||
request_input = _seed_tts_request_func_input()
|
||||
request_input.api_url = f"http://127.0.0.1:{port}/v1/chat/completions"
|
||||
output = await async_request_openai_chat_omni_completions(request_input, session)
|
||||
assert output.success is False
|
||||
assert output.error
|
||||
finally:
|
||||
await session.close()
|
||||
server.close()
|
||||
await server.wait_closed()
|
||||
|
||||
|
||||
def test_video_rtf_prefers_generation_time_over_poll_latency():
|
||||
"""RTF must not grow with client poll_interval overshoot in output.latency."""
|
||||
payload = {
|
||||
"duration_s": 2.0,
|
||||
"num_frames": 48,
|
||||
"fps": 24.0,
|
||||
"stage_durations": {"stage_0_gen_ms": 4000.0},
|
||||
}
|
||||
request_body: dict[str, object] = {}
|
||||
|
||||
short_poll = MixRequestFuncOutput()
|
||||
short_poll.latency = 4.2 # ~generation + small poll overshoot
|
||||
_apply_video_metrics_from_payload(short_poll, payload, request_body)
|
||||
|
||||
long_poll = MixRequestFuncOutput()
|
||||
long_poll.latency = 8.0 # same job, larger poll_interval_s overshoot
|
||||
_apply_video_metrics_from_payload(long_poll, payload, request_body)
|
||||
|
||||
assert short_poll.video_generation_time_ms == pytest.approx(4000.0)
|
||||
assert long_poll.video_generation_time_ms == pytest.approx(4000.0)
|
||||
assert short_poll.video_rtf == pytest.approx(2.0)
|
||||
assert long_poll.video_rtf == pytest.approx(2.0)
|
||||
assert short_poll.video_rtf == long_poll.video_rtf
|
||||
|
||||
|
||||
def test_video_rtf_falls_back_to_e2e_latency_without_generation_time():
|
||||
output = MixRequestFuncOutput()
|
||||
output.latency = 6.0
|
||||
_apply_video_metrics_from_payload(
|
||||
output,
|
||||
{"duration_s": 2.0, "num_frames": 48, "fps": 24.0},
|
||||
{},
|
||||
)
|
||||
assert output.video_generation_time_ms == 0.0
|
||||
assert output.video_rtf == pytest.approx(3.0)
|
||||
|
||||
|
||||
# 1x1 PNG used as a valid b64_json image payload in edit-client tests.
|
||||
_MIN_PNG_B64 = "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mP8z8BQDwAEhQGAhKmMIQAAAABJRU5ErkJggg=="
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_image_edits_defaults_to_non_streaming_json(mocker: MockerFixture) -> None:
|
||||
"""Single-stage servers reject stream=true; default path must send stream=false + JSON."""
|
||||
|
||||
class MockJsonResponse:
|
||||
status = 200
|
||||
|
||||
def __init__(self):
|
||||
self._payload = {
|
||||
"created": 1,
|
||||
"data": [
|
||||
{
|
||||
"b64_json": _MIN_PNG_B64,
|
||||
"stage_durations": {"stage_0_gen_ms": 12.5},
|
||||
}
|
||||
],
|
||||
}
|
||||
|
||||
async def json(self):
|
||||
return self._payload
|
||||
|
||||
async def text(self):
|
||||
return json.dumps(self._payload)
|
||||
|
||||
async def __aenter__(self):
|
||||
return self
|
||||
|
||||
async def __aexit__(self, *_args):
|
||||
return None
|
||||
|
||||
captured_stream: list[str] = []
|
||||
real_add_field = None
|
||||
|
||||
def tracking_add_field(self, name, value=None, **kwargs):
|
||||
if name == "stream":
|
||||
captured_stream.append(str(value))
|
||||
return real_add_field(self, name, value, **kwargs)
|
||||
|
||||
import aiohttp
|
||||
|
||||
real_add_field = aiohttp.FormData.add_field
|
||||
mocker.patch.object(aiohttp.FormData, "add_field", tracking_add_field)
|
||||
|
||||
mock_session = mocker.AsyncMock()
|
||||
mock_session.post = mocker.MagicMock(return_value=MockJsonResponse())
|
||||
|
||||
request = RequestFuncInput(
|
||||
model="single-stage-edit",
|
||||
model_name="single-stage-edit",
|
||||
prompt="make it sunny",
|
||||
api_url="http://test.com/v1/images/edits",
|
||||
prompt_len=4,
|
||||
output_len=1,
|
||||
multi_modal_content=[{"type": "image_url", "image_url": {"url": f"data:image/png;base64,{_MIN_PNG_B64}"}}],
|
||||
extra_body={"num_inference_steps": 4},
|
||||
)
|
||||
output = await async_request_openai_image_edits_omni(request, mock_session, pbar=None)
|
||||
|
||||
assert captured_stream == ["false"]
|
||||
assert output.success is True
|
||||
assert not output.error
|
||||
assert output.image_count == 1
|
||||
assert output.image_generation_time_ms == pytest.approx(12.5)
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_image_edits_stream_true_uses_sse_path(mocker: MockerFixture) -> None:
|
||||
"""Explicit stream=true keeps the multi-stage SSE client path."""
|
||||
sse_chunk = (
|
||||
b'data: {"type":"image","data":[{"b64_json":"' + _MIN_PNG_B64.encode() + b'"}]}\n\n' + b"data: [DONE]\n\n"
|
||||
)
|
||||
mock_response = MockResponse(200, [sse_chunk])
|
||||
captured_stream: list[str] = []
|
||||
|
||||
import aiohttp
|
||||
|
||||
real_add_field = aiohttp.FormData.add_field
|
||||
|
||||
def tracking_add_field(self, name, value=None, **kwargs):
|
||||
if name == "stream":
|
||||
captured_stream.append(str(value))
|
||||
return real_add_field(self, name, value, **kwargs)
|
||||
|
||||
mocker.patch.object(aiohttp.FormData, "add_field", tracking_add_field)
|
||||
|
||||
mock_session = mocker.AsyncMock()
|
||||
mock_session.post = mocker.MagicMock(return_value=mock_response)
|
||||
|
||||
request = RequestFuncInput(
|
||||
model="multi-stage-edit",
|
||||
model_name="multi-stage-edit",
|
||||
prompt="edit",
|
||||
api_url="http://test.com/v1/images/edits",
|
||||
prompt_len=2,
|
||||
output_len=1,
|
||||
multi_modal_content=[{"type": "image_url", "image_url": {"url": f"data:image/png;base64,{_MIN_PNG_B64}"}}],
|
||||
extra_body={"stream": True},
|
||||
)
|
||||
output = await async_request_openai_image_edits_omni(request, mock_session, pbar=None)
|
||||
|
||||
assert captured_stream == ["true"]
|
||||
assert output.success is True
|
||||
assert output.image_count == 1
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_image_generations_e2el_includes_json_body_consume(mocker: MockerFixture) -> None:
|
||||
"""E2EL must include body transfer/decode, not stop at HTTP headers."""
|
||||
|
||||
class SlowJsonResponse:
|
||||
status = 200
|
||||
|
||||
def __init__(self):
|
||||
self._payload = {
|
||||
"created": 1,
|
||||
"data": [{"b64_json": _MIN_PNG_B64, "stage_durations": {"stage_0_gen_ms": 1.0}}],
|
||||
}
|
||||
|
||||
async def json(self):
|
||||
await asyncio.sleep(0.05)
|
||||
return self._payload
|
||||
|
||||
async def text(self):
|
||||
return json.dumps(self._payload)
|
||||
|
||||
async def __aenter__(self):
|
||||
return self
|
||||
|
||||
async def __aexit__(self, *_args):
|
||||
return None
|
||||
|
||||
mock_session = mocker.AsyncMock()
|
||||
mock_session.post = mocker.MagicMock(return_value=SlowJsonResponse())
|
||||
request = RequestFuncInput(
|
||||
model="img-gen",
|
||||
model_name="img-gen",
|
||||
prompt="a cat",
|
||||
api_url="http://test.com/v1/images/generations",
|
||||
prompt_len=2,
|
||||
output_len=1,
|
||||
extra_body={},
|
||||
)
|
||||
output = await async_request_openai_image_generations_omni(request, mock_session, pbar=None)
|
||||
assert output.success is True
|
||||
assert output.latency >= 0.05
|
||||
|
||||
|
||||
def test_video_local_image_reference_not_forwarded_as_raw_extra_field(tmp_path, mocker: MockerFixture) -> None:
|
||||
"""Local image_reference must only be uploaded via dedicated serializer."""
|
||||
import aiohttp
|
||||
|
||||
ref_path = tmp_path / "ref.png"
|
||||
ref_path.write_bytes(base64.b64decode(_MIN_PNG_B64))
|
||||
|
||||
captured: list[tuple[str, object]] = []
|
||||
real_add_field = aiohttp.FormData.add_field
|
||||
|
||||
def tracking_add_field(self, name, value=None, **kwargs):
|
||||
captured.append((str(name), value))
|
||||
return real_add_field(self, name, value, **kwargs)
|
||||
|
||||
mocker.patch.object(aiohttp.FormData, "add_field", tracking_add_field)
|
||||
|
||||
form = aiohttp.FormData()
|
||||
extra_body = {
|
||||
"num_inference_steps": 2,
|
||||
"image_reference": str(ref_path),
|
||||
}
|
||||
request_body = {"model": "vid", "prompt": "p", **extra_body}
|
||||
_add_video_extra_body_to_form(form, extra_body, request_body)
|
||||
assert _add_video_reference_to_form(form, extra_body["image_reference"]) is True
|
||||
|
||||
field_names = [name for name, _ in captured]
|
||||
assert "image_reference" not in field_names
|
||||
assert field_names.count("input_reference") == 1
|
||||
# Dedicated uploader sends file bytes, not the raw local path string.
|
||||
uploaded = next(value for name, value in captured if name == "input_reference")
|
||||
assert uploaded == base64.b64decode(_MIN_PNG_B64)
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"reference",
|
||||
[
|
||||
{"image_url": "https://example.com/ref.png"},
|
||||
{"file_id": "file-abc"},
|
||||
[{"image_url": "https://example.com/a.png"}, {"file_id": "file-xyz"}],
|
||||
],
|
||||
)
|
||||
def test_video_structured_image_reference_serialized_to_form(reference: object, mocker: MockerFixture) -> None:
|
||||
"""Object-form image_reference must be JSON-serialized, not silently dropped."""
|
||||
import aiohttp
|
||||
|
||||
captured: list[tuple[str, object]] = []
|
||||
real_add_field = aiohttp.FormData.add_field
|
||||
|
||||
def tracking_add_field(self, name, value=None, **kwargs):
|
||||
captured.append((str(name), value))
|
||||
return real_add_field(self, name, value, **kwargs)
|
||||
|
||||
mocker.patch.object(aiohttp.FormData, "add_field", tracking_add_field)
|
||||
|
||||
form = aiohttp.FormData()
|
||||
extra_body = {"image_reference": reference}
|
||||
request_body = {"model": "vid", "prompt": "p", **extra_body}
|
||||
_add_video_extra_body_to_form(form, extra_body, request_body)
|
||||
assert _add_video_reference_to_form(form, reference) is True
|
||||
|
||||
field_names = [name for name, _ in captured]
|
||||
# Reserved key must not be double-forwarded as a generic extra field;
|
||||
# exactly one dedicated image_reference field.
|
||||
assert field_names.count("image_reference") == 1
|
||||
assert "input_reference" not in field_names
|
||||
payload = next(value for name, value in captured if name == "image_reference")
|
||||
assert json.loads(payload) == reference
|
||||
|
||||
|
||||
def test_video_unsupported_image_reference_raises() -> None:
|
||||
import aiohttp
|
||||
|
||||
form = aiohttp.FormData()
|
||||
with pytest.raises(ValueError, match="Unsupported image_reference"):
|
||||
_add_video_reference_to_form(form, {"not_a_supported_key": "x"})
|
||||
with pytest.raises(ValueError, match="Unsupported image_reference"):
|
||||
_add_video_reference_to_form(form, "/tmp/does-not-exist-ref.png")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
pytest.main([__file__, "-v", "-s"])
|
||||
@@ -1,11 +1,9 @@
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
# SPDX-FileCopyrightText: Copyright contributors to the vLLM-Omni project
|
||||
|
||||
# ruff: noqa: E402, I001
|
||||
import argparse
|
||||
import math
|
||||
import os
|
||||
import sys
|
||||
import types
|
||||
from pathlib import Path
|
||||
|
||||
import pytest
|
||||
@@ -108,9 +106,11 @@ def test_resolve_seed_tts_root_downloads_only_requested_locale(monkeypatch, tmp_
|
||||
captured["allow_patterns"] = allow_patterns
|
||||
return str(downloaded_root)
|
||||
|
||||
from vllm_omni.transformers_utils import repo_utils
|
||||
|
||||
monkeypatch.setattr(repo_utils.hf_api(), "snapshot_download", fake_snapshot_download)
|
||||
monkeypatch.setitem(
|
||||
sys.modules,
|
||||
"huggingface_hub",
|
||||
types.SimpleNamespace(snapshot_download=fake_snapshot_download),
|
||||
)
|
||||
|
||||
resolved = resolve_seed_tts_root(
|
||||
"zhaochenyang20/seed-tts-eval",
|
||||
|
||||
@@ -167,26 +167,6 @@ def test_preprocess_serve_args_applies_safe_omniinteract_prompt_default(
|
||||
{"bot_task": "recaption"},
|
||||
{"backend", "print_stage", "bot_task"},
|
||||
),
|
||||
(
|
||||
[
|
||||
"--endpoint",
|
||||
"/v1/images/edits",
|
||||
"--image-edits-bot-task",
|
||||
"think",
|
||||
],
|
||||
{"bot_task": "think"},
|
||||
{"endpoint", "bot_task"},
|
||||
),
|
||||
(
|
||||
[
|
||||
"--backend",
|
||||
"/v1/images/edits",
|
||||
"--image-edits-bot-task",
|
||||
"recaption",
|
||||
],
|
||||
{"bot_task": "recaption"},
|
||||
{"backend", "bot_task"},
|
||||
),
|
||||
(
|
||||
["--extra-body", '{"bot_task":"vanilla"}'],
|
||||
{"bot_task": "vanilla"},
|
||||
@@ -202,7 +182,6 @@ def test_omni_args_parse_and_preprocess(
|
||||
parser = TrackingArgumentParser()
|
||||
parser.add_argument("--extra-body", type=json.loads, default=None)
|
||||
parser.add_argument("--backend", default="openai-chat-omni")
|
||||
parser.add_argument("--endpoint", default="/v1/chat/completions")
|
||||
add_omni_args(parser)
|
||||
|
||||
args = parser.parse_args(argv)
|
||||
@@ -379,17 +358,3 @@ def test_bench_serve_cli_mocks_http_request(tmp_path: Path):
|
||||
)
|
||||
assert bench_requests
|
||||
assert all(url == expected_url for url in bench_requests), f"Unexpected target URLs: {bench_requests}"
|
||||
|
||||
|
||||
def test_omni_request_timeout_s_flag_defaults_and_parses() -> None:
|
||||
parser = TrackingArgumentParser()
|
||||
add_omni_args(parser)
|
||||
|
||||
args = parser.parse_args([])
|
||||
assert args.omni_request_timeout_s is None
|
||||
|
||||
args = parser.parse_args(["--omni-request-timeout-s", "0"])
|
||||
assert args.omni_request_timeout_s == 0.0
|
||||
|
||||
args = parser.parse_args(["--omni-request-timeout-s", "3600"])
|
||||
assert args.omni_request_timeout_s == 3600.0
|
||||
@@ -1,156 +0,0 @@
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
# SPDX-FileCopyrightText: Copyright contributors to the vLLM-Omni project
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import os
|
||||
import shutil
|
||||
import subprocess
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
import pytest
|
||||
|
||||
pytestmark = [pytest.mark.core_model, pytest.mark.cpu]
|
||||
|
||||
REPO_ROOT = Path(__file__).resolve().parents[2]
|
||||
BOOTSTRAP_PATH = REPO_ROOT / ".buildkite/amd/scripts/bootstrap-amd-omni.sh"
|
||||
|
||||
|
||||
def _run_bootstrap(
|
||||
tmp_path: Path,
|
||||
*,
|
||||
debug_test_yaml: str | None = None,
|
||||
curl_status: int = 0,
|
||||
jq_status: int = 0,
|
||||
labels: tuple[str, ...] = (),
|
||||
pull_request: bool = True,
|
||||
) -> subprocess.CompletedProcess[str]:
|
||||
for relative_path in (
|
||||
".buildkite/common/scripts/resolve_skip_ci.sh",
|
||||
".buildkite/amd/scripts/select_test_suites.py",
|
||||
):
|
||||
destination = tmp_path / relative_path
|
||||
destination.parent.mkdir(parents=True, exist_ok=True)
|
||||
shutil.copyfile(REPO_ROOT / relative_path, destination)
|
||||
|
||||
# Stop after real suite selection, before rendering or uploading a pipeline.
|
||||
(tmp_path / ".buildkite/common/scripts/skip_ci.py").write_text("print('test-skip')\n", encoding="utf-8")
|
||||
env = {
|
||||
"PATH": os.environ["PATH"],
|
||||
"BUILDKITE_PULL_REQUEST": "123" if pull_request else "false",
|
||||
"BUILDKITE_BRANCH": "feature" if pull_request else "main",
|
||||
"TEST_PYTHON": sys.executable,
|
||||
"TEST_CURL_STATUS": str(curl_status),
|
||||
"TEST_JQ_STATUS": str(jq_status),
|
||||
"TEST_PR_LABELS": "\n".join(labels),
|
||||
}
|
||||
if debug_test_yaml is not None:
|
||||
env["DEBUG_TEST_YAML"] = debug_test_yaml
|
||||
|
||||
# Source the unmodified bootstrap with subprocess-local command doubles.
|
||||
script = r"""
|
||||
curl() {
|
||||
echo 'curl called' >&2
|
||||
return "$TEST_CURL_STATUS"
|
||||
}
|
||||
jq() {
|
||||
echo 'jq called' >&2
|
||||
printf '%s\n' "$TEST_PR_LABELS"
|
||||
return "$TEST_JQ_STATUS"
|
||||
}
|
||||
git() { :; }
|
||||
python3() { "$TEST_PYTHON" "$@"; }
|
||||
source "$1"
|
||||
"""
|
||||
return subprocess.run(
|
||||
["bash", "-c", script, "test-amd-bootstrap", str(BOOTSTRAP_PATH)],
|
||||
cwd=tmp_path,
|
||||
env=env,
|
||||
capture_output=True,
|
||||
text=True,
|
||||
timeout=10,
|
||||
check=False,
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.parametrize(("curl_status", "jq_status"), [(22, 0), (0, 4)], ids=["request-failure", "parse-failure"])
|
||||
@pytest.mark.parametrize(
|
||||
("debug_test_yaml", "expected_levels"),
|
||||
[
|
||||
("ready", ["l2"]),
|
||||
("merge", ["l3"]),
|
||||
("ready,merge", ["l2", "l3"]),
|
||||
(" MERGE, ready,", ["l3", "l2"]),
|
||||
],
|
||||
)
|
||||
def test_debug_override_skips_label_lookup(tmp_path, debug_test_yaml, expected_levels, curl_status, jq_status):
|
||||
result = _run_bootstrap(
|
||||
tmp_path,
|
||||
debug_test_yaml=debug_test_yaml,
|
||||
curl_status=curl_status,
|
||||
jq_status=jq_status,
|
||||
)
|
||||
|
||||
assert result.returncode == 0, result.stderr
|
||||
assert "curl called" not in result.stderr
|
||||
assert "jq called" not in result.stderr
|
||||
assert "legacy ready-suite fallback" not in result.stderr
|
||||
assert [
|
||||
line.split()[2] for line in result.stdout.splitlines() if line.startswith("Skipping AMD ")
|
||||
] == expected_levels
|
||||
|
||||
|
||||
@pytest.mark.parametrize(("curl_status", "jq_status"), [(22, 0), (0, 4)], ids=["request-failure", "parse-failure"])
|
||||
@pytest.mark.parametrize("debug_test_yaml", [None, ""], ids=["unset", "empty"])
|
||||
def test_label_lookup_failure_without_override(tmp_path, debug_test_yaml, curl_status, jq_status):
|
||||
result = _run_bootstrap(
|
||||
tmp_path,
|
||||
debug_test_yaml=debug_test_yaml,
|
||||
curl_status=curl_status,
|
||||
jq_status=jq_status,
|
||||
)
|
||||
|
||||
assert result.returncode == 1
|
||||
assert "Could not read PR labels" in result.stderr
|
||||
assert "Skipping AMD " not in result.stdout
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
("labels", "expected_levels"),
|
||||
[
|
||||
(("ready",), ["l2"]),
|
||||
(("merge-test",), ["l3"]),
|
||||
(("ready", "merge-test"), ["l2", "l3"]),
|
||||
((), ["l2"]),
|
||||
],
|
||||
)
|
||||
def test_label_lookup_selects_tiers(tmp_path, labels, expected_levels):
|
||||
result = _run_bootstrap(tmp_path, labels=labels)
|
||||
|
||||
assert result.returncode == 0, result.stderr
|
||||
assert "curl called" in result.stderr
|
||||
assert "jq called" in result.stderr
|
||||
assert [
|
||||
line.split()[2] for line in result.stdout.splitlines() if line.startswith("Skipping AMD ")
|
||||
] == expected_levels
|
||||
|
||||
|
||||
@pytest.mark.parametrize("debug_test_yaml", ["ready,ready", "nightly", ", ,", " \t"])
|
||||
def test_invalid_debug_override_fails_without_label_lookup(tmp_path, debug_test_yaml):
|
||||
result = _run_bootstrap(tmp_path, debug_test_yaml=debug_test_yaml, curl_status=22)
|
||||
|
||||
assert result.returncode == 1
|
||||
assert "DEBUG_TEST_YAML" in result.stderr
|
||||
assert "curl called" not in result.stderr
|
||||
assert "jq called" not in result.stderr
|
||||
assert "Skipping AMD " not in result.stdout
|
||||
|
||||
|
||||
def test_main_does_not_lookup_labels(tmp_path):
|
||||
result = _run_bootstrap(tmp_path, pull_request=False, curl_status=22, jq_status=4)
|
||||
|
||||
assert result.returncode == 0, result.stderr
|
||||
assert "curl called" not in result.stderr
|
||||
assert "jq called" not in result.stderr
|
||||
assert "Skipping AMD l3 suite" in result.stdout
|
||||
@@ -1,61 +0,0 @@
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
# SPDX-FileCopyrightText: Copyright contributors to the vLLM-Omni project
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import importlib.util
|
||||
from pathlib import Path
|
||||
|
||||
import pytest
|
||||
|
||||
pytestmark = [pytest.mark.core_model, pytest.mark.cpu]
|
||||
|
||||
SELECTOR_PATH = Path(".buildkite/amd/scripts/select_test_suites.py")
|
||||
SPEC = importlib.util.spec_from_file_location("select_test_suites", SELECTOR_PATH)
|
||||
assert SPEC is not None and SPEC.loader is not None
|
||||
SELECTOR = importlib.util.module_from_spec(SPEC)
|
||||
SPEC.loader.exec_module(SELECTOR)
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
("branch", "labels", "expected"),
|
||||
[
|
||||
("main", (), ("merge",)),
|
||||
("feature", ("ready",), ("ready",)),
|
||||
("feature", ("merge-test",), ("merge",)),
|
||||
("feature", ("merge-test", "ready"), ("ready", "merge")),
|
||||
("feature", ("amd-test",), ("ready",)),
|
||||
("feature", ("amd-test", "merge-test"), ("merge",)),
|
||||
("feature", ("amd-test", "ready", "merge-test"), ("ready", "merge")),
|
||||
("feature", ("nightly-test",), ("ready",)),
|
||||
("feature", ("not-ready", "merge-test-extra"), ("ready",)),
|
||||
],
|
||||
)
|
||||
def test_label_suite_selection(branch, labels, expected):
|
||||
assert SELECTOR.select_amd_test_suites(branch=branch, labels=labels) == expected
|
||||
|
||||
|
||||
def test_debug_override_takes_precedence_and_normalizes_input():
|
||||
assert SELECTOR.select_amd_test_suites(
|
||||
branch="main",
|
||||
labels=("ready",),
|
||||
debug_test_yaml=" MERGE, ready,",
|
||||
) == ("merge", "ready")
|
||||
|
||||
|
||||
def test_empty_debug_override_uses_normal_selection():
|
||||
assert SELECTOR.select_amd_test_suites(
|
||||
branch="feature",
|
||||
labels=("merge-test",),
|
||||
debug_test_yaml="",
|
||||
) == ("merge",)
|
||||
|
||||
|
||||
@pytest.mark.parametrize("value", ["ready,ready", "nightly", ", ,", " \t"])
|
||||
def test_invalid_debug_override(value):
|
||||
with pytest.raises(ValueError):
|
||||
SELECTOR.select_amd_test_suites(
|
||||
branch="feature",
|
||||
labels=(),
|
||||
debug_test_yaml=value,
|
||||
)
|
||||
@@ -12,7 +12,6 @@ sys.path.insert(0, str(Path(__file__).resolve().parents[2] / ".buildkite" / "com
|
||||
|
||||
from skip_ci import resolve_ci_decision # noqa: E402
|
||||
from upload_pipeline import ( # noqa: E402
|
||||
CUDA_HF_TOKEN_EXPORT,
|
||||
_expand_mirror_hardwares,
|
||||
_get_mirror_hw_selector,
|
||||
_load_bootstrap_steps,
|
||||
@@ -144,10 +143,6 @@ def test_mirror_hardwares_l4_1_expands_to_agents_and_plugins(monkeypatch: pytest
|
||||
container = step["plugins"][0]["kubernetes"]["podSpec"]["containers"][0]
|
||||
assert container["image"].endswith("$BUILDKITE_COMMIT")
|
||||
assert container["resources"]["limits"]["nvidia.com/gpu"] == 1
|
||||
env_names = {item["name"] for item in container["env"]}
|
||||
assert "VLLM_CI_HF_TOKEN" in env_names
|
||||
assert "HF_TOKEN" not in env_names
|
||||
assert step["commands"] == [CUDA_HF_TOKEN_EXPORT, "pytest -sv tests/example"]
|
||||
|
||||
|
||||
def test_mirror_hardwares_l4_preserves_explicit_retry() -> None:
|
||||
@@ -187,33 +182,6 @@ def test_mirror_hardwares_a2b3_npu_4_expands_agents_image_and_plugins() -> None:
|
||||
assert step["plugins"][0]["kubernetes"]["podSpecPatch"]["imagePullSecrets"] == [
|
||||
{"name": "swr-secret"},
|
||||
]
|
||||
assert step["commands"] == ["pytest -sv tests/example"]
|
||||
|
||||
|
||||
def test_all_cuda_mirror_hardwares_restore_hf_token_at_runtime() -> None:
|
||||
for name in (
|
||||
"l4_1",
|
||||
"l4_2",
|
||||
"l4_3",
|
||||
"l4_4",
|
||||
"h100_1",
|
||||
"h100_2",
|
||||
"h100_3",
|
||||
"h100_4",
|
||||
"b200_1",
|
||||
"b200_2",
|
||||
"b200_3",
|
||||
"b200_4",
|
||||
):
|
||||
step = _expand_mirror_hardwares(
|
||||
{"label": name, "mirror_hardwares": name, "commands": ["pytest -sv tests/example"]},
|
||||
)
|
||||
assert step is not None
|
||||
container = step["plugins"][0]["kubernetes"]["podSpec"]["containers"][0]
|
||||
env_names = {item["name"] for item in container["env"]}
|
||||
assert "VLLM_CI_HF_TOKEN" in env_names
|
||||
assert "HF_TOKEN" not in env_names
|
||||
assert step["commands"][0] == CUDA_HF_TOKEN_EXPORT
|
||||
|
||||
|
||||
def _gpu_limit(step: dict) -> int:
|
||||
|
||||
@@ -6,6 +6,7 @@ Unit tests for StageConfigFactory and related classes.
|
||||
|
||||
import importlib
|
||||
import warnings
|
||||
from dataclasses import dataclass
|
||||
from pathlib import Path
|
||||
from unittest.mock import patch
|
||||
|
||||
@@ -36,7 +37,6 @@ from vllm_omni.config.stage_config import (
|
||||
normalize_pipeline_cli_overrides,
|
||||
pipeline_cfg_resolver,
|
||||
)
|
||||
from vllm_omni.diffusion.data import DiffusionParallelConfig
|
||||
from vllm_omni.engine.arg_utils import SHARED_FIELDS, internal_blacklist_keys
|
||||
|
||||
pytestmark = [pytest.mark.core_model, pytest.mark.cpu]
|
||||
@@ -451,8 +451,13 @@ class TestStageConfigFactory:
|
||||
|
||||
def test_default_diffusion_with_parallel_config(self):
|
||||
"""Test diffusion config calculates devices from parallel_config."""
|
||||
|
||||
@dataclass
|
||||
class MockParallelConfig:
|
||||
world_size: int = 4
|
||||
|
||||
kwargs = {
|
||||
"parallel_config": DiffusionParallelConfig(tensor_parallel_size=4),
|
||||
"parallel_config": MockParallelConfig(),
|
||||
"cache_backend": "tea_cache",
|
||||
}
|
||||
configs = StageConfigFactory.create_default_diffusion(kwargs)
|
||||
@@ -932,44 +937,6 @@ class TestPipelineRegistration:
|
||||
assert isinstance(omni_config, VllmOmniConfig)
|
||||
assert omni_config.stage_by_id(0).diffusion_config.model == "fake/model"
|
||||
|
||||
def test_cosyvoice3_deploy_resolves_hash_snapshot_without_hf_metadata(self, tmp_path):
|
||||
snapshot = tmp_path / "models--FunAudioLLM--Fun-CosyVoice3-0.5B-2512" / "snapshots" / ("a" * 40)
|
||||
snapshot.mkdir(parents=True)
|
||||
(snapshot / "config.json").write_text("{}\n", encoding="utf-8")
|
||||
model = str(snapshot)
|
||||
deploy_path = get_deploy_config_path("cosyvoice3.yaml")
|
||||
|
||||
assert StageConfigFactory.try_infer_model_type(model, trust_remote_code=False) is None
|
||||
assert StageConfigFactory.get_pipeline_config(model, trust_remote_code=False) is None
|
||||
|
||||
omni_config = StageConfigFactory.create_from_model(
|
||||
model,
|
||||
trust_remote_code=False,
|
||||
cli_overrides={},
|
||||
deploy_config_path=deploy_path,
|
||||
)
|
||||
legacy_configs, _ = StageConfigFactory.create_legacy_stage_configs_from_model(
|
||||
model,
|
||||
trust_remote_code=False,
|
||||
cli_overrides={},
|
||||
deploy_config_path=deploy_path,
|
||||
)
|
||||
|
||||
assert omni_config is not None
|
||||
assert omni_config.pipeline_config.model_type == "cosyvoice3"
|
||||
assert [
|
||||
(stage.stage_id, stage.stage_type, stage.worker_type, stage.model_stage)
|
||||
for stage in omni_config.stage_configs
|
||||
] == [
|
||||
(0, StageType.LLM, "ar", "cosyvoice3_talker"),
|
||||
(1, StageType.LLM, "generation", "cosyvoice3_code2wav"),
|
||||
]
|
||||
assert all(stage.model_config.model == model for stage in omni_config.stage_configs)
|
||||
assert all(stage.stage_type is not StageType.DIFFUSION for stage in omni_config.stage_configs)
|
||||
|
||||
assert legacy_configs is not None
|
||||
assert [stage.stage_type for stage in legacy_configs] == [StageType.LLM, StageType.LLM]
|
||||
|
||||
def test_pipeline_registration(self, clean_pipeline_registry):
|
||||
"""Ensure that we can register and create a custom pipeline config."""
|
||||
new_model_type = "new_model_type"
|
||||
@@ -1508,11 +1475,6 @@ stages:
|
||||
deploy = load_deploy_config(Path(get_deploy_config_path("minimax_h3_disaggregated.yaml")))
|
||||
stages = merge_pipeline_deploy(pipeline, deploy)
|
||||
|
||||
assert stages[0].yaml_engine_args["model_arch"] == "MiniMaxH3TextEncoder"
|
||||
assert stages[1].yaml_engine_args["model_arch"] == "MiniMaxH3Pipeline"
|
||||
assert stages[0].yaml_runtime["num_replicas"] == 1
|
||||
assert stages[1].yaml_runtime["num_replicas"] == 1
|
||||
assert stages[1].yaml_engine_args["model_loaded"] == {"text_encoder": False}
|
||||
assert stages[0].yaml_engine_args["max_num_seqs"] == 1
|
||||
assert stages[0].yaml_engine_args["model_path_resolver"].endswith(".resolve_minimax_h3_model_root")
|
||||
assert stages[1].yaml_engine_args["model_path_resolver"].endswith(".resolve_minimax_h3_diffusion_model_path")
|
||||
@@ -1635,7 +1597,7 @@ stages:
|
||||
assert stage.max_model_len == 1024
|
||||
assert stage.max_num_batched_tokens == 1024
|
||||
assert stage.max_num_seqs == 1
|
||||
assert stage.gpu_memory_utilization == 0.8
|
||||
assert stage.gpu_memory_utilization == 0.7
|
||||
assert stage.skip_mm_profiling is True
|
||||
assert stage.enforce_eager is True
|
||||
assert stage.async_scheduling is False
|
||||
|
||||
@@ -167,7 +167,7 @@ def test_inventory_matches_reviewed_snapshot_counts():
|
||||
EnvironmentVariableCategory.PUBLIC_OMNI: 24,
|
||||
EnvironmentVariableCategory.INHERITED_VLLM: 20,
|
||||
EnvironmentVariableCategory.PLATFORM_EXTERNAL: 27,
|
||||
EnvironmentVariableCategory.MODEL_SPECIFIC: 61,
|
||||
EnvironmentVariableCategory.MODEL_SPECIFIC: 62,
|
||||
EnvironmentVariableCategory.BENCHMARK_TRANSITIONAL: 20,
|
||||
EnvironmentVariableCategory.INTERNAL: 2,
|
||||
}
|
||||
@@ -179,7 +179,7 @@ def test_inventory_matches_reviewed_snapshot_counts():
|
||||
)
|
||||
assert {disposition: disposition_counts[disposition] for disposition in ModelEnvironmentVariableDisposition} == {
|
||||
ModelEnvironmentVariableDisposition.PROMOTE: 37,
|
||||
ModelEnvironmentVariableDisposition.REQUEST_SCOPE: 6,
|
||||
ModelEnvironmentVariableDisposition.REQUEST_SCOPE: 7,
|
||||
ModelEnvironmentVariableDisposition.EXTERNAL: 0,
|
||||
ModelEnvironmentVariableDisposition.INTERNALIZE: 13,
|
||||
ModelEnvironmentVariableDisposition.DEPRECATE_REMOVE: 5,
|
||||
|
||||
@@ -1,52 +0,0 @@
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
# SPDX-FileCopyrightText: Copyright contributors to the vLLM-Omni project
|
||||
"""The LingBot stepwise deploy config must keep serving on the AR-Diffusion path.
|
||||
|
||||
`WS /v1/realtime/video` only reaches the stepwise code when the stage selects the
|
||||
AR-Diffusion engine and asks for streamed step execution, so those fields are
|
||||
pinned here rather than left to drift.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import pytest
|
||||
|
||||
from tests.helpers.stage_config import get_deploy_config_path
|
||||
from vllm_omni.config.stage_config import load_deploy_config
|
||||
|
||||
pytestmark = [pytest.mark.core_model, pytest.mark.cpu]
|
||||
|
||||
_DEPLOY = "lingbot_world_v2_stepwise.yaml"
|
||||
|
||||
|
||||
def _stage():
|
||||
deploy = load_deploy_config(get_deploy_config_path(_DEPLOY))
|
||||
assert len(deploy.stages) == 1, "stepwise serving is a single diffusion stage"
|
||||
return deploy.stages[0]
|
||||
|
||||
|
||||
def test_stage_selects_the_ar_diffusion_engine_and_pipeline() -> None:
|
||||
stage = _stage()
|
||||
assert stage.model_class_name == "LingBotWorldCausalDMDPipeline"
|
||||
# engine_backend/model_config reach the engine through the passthrough, the
|
||||
# same way the DreamZero AR-Diffusion deploy config does.
|
||||
assert stage.engine_extras["engine_backend"].endswith("ar_diffusion.engine.ARDiffusionEngine")
|
||||
|
||||
|
||||
def test_stage_requests_streamed_step_execution_on_one_sequence() -> None:
|
||||
stage = _stage()
|
||||
assert stage.step_execution is True
|
||||
assert stage.engine_extras["streaming_output"] is True
|
||||
# AR-Diffusion binds one session per runner invocation; batching requests
|
||||
# would break that contract, so the runner rejects max_num_seqs > 1.
|
||||
assert stage.max_num_seqs == 1
|
||||
|
||||
|
||||
def test_stage_declares_the_fixed_ar_cache_geometry() -> None:
|
||||
stage = _stage()
|
||||
model_config = stage.engine_extras["model_config"]
|
||||
# The KV cache geometry is fixed at load time, so a served request must ask
|
||||
# for exactly this resolution.
|
||||
assert model_config["ar_diffusion_height"] == 480
|
||||
assert model_config["ar_diffusion_width"] == 832
|
||||
assert model_config["ar_diffusion_kv_config"]["gpu_memory_fraction"] == 0.6
|
||||
@@ -215,16 +215,6 @@ def test_from_pipeline_config_normalizes_stage_engine_extras_without_expanding_s
|
||||
assert stage.diffusion_config.model_config["default_robot_embodiment"] == "roboarena"
|
||||
|
||||
|
||||
@pytest.mark.parametrize("disabled", [True, False])
|
||||
def test_frontend_log_stats_flag_is_not_an_unowned_stage_argument(disabled):
|
||||
from vllm_omni.engine.stage_init_utils import build_engine_args_dict_from_omni_stage_config
|
||||
|
||||
config = _from_pipeline_key("dots_tts", cli_overrides={"disable_log_stats": disabled})
|
||||
assert config.stage_configs
|
||||
engine_args = build_engine_args_dict_from_omni_stage_config(config.stage_by_id(0), model="test-model")
|
||||
assert "disable_log_stats" not in engine_args
|
||||
|
||||
|
||||
def test_from_pipeline_config_applies_cli_overrides_without_stage_config_runtime_bridge():
|
||||
omni_config = _from_pipeline_key(
|
||||
"qwen3_tts",
|
||||
@@ -271,57 +261,6 @@ def test_from_pipeline_config_rejects_unowned_deploy_engine_extras(engine_extras
|
||||
VllmOmniConfig.from_pipeline_config(pipeline, user_deploy_config=deploy)
|
||||
|
||||
|
||||
@pytest.mark.parametrize("stage_id", [0, 2], ids=["ar", "generation"])
|
||||
def test_llm_additional_config_roundtrip_and_isolation(stage_id, monkeypatch):
|
||||
from vllm_omni.engine import stage_init_utils
|
||||
from vllm_omni.engine.stage_init_utils import build_engine_args_dict_from_omni_stage_config
|
||||
|
||||
# Worker discovery requires hardware support; this test covers config transport.
|
||||
monkeypatch.setattr(stage_init_utils, "resolve_worker_cls", lambda engine_args: None)
|
||||
additional_config = {"backend_options": {"enabled": True}}
|
||||
pipeline = _resolve_pipeline_or_skip("minicpmo_4_5")
|
||||
deploy = DeployConfig(
|
||||
stages=[StageDeployConfig(stage_id=i, engine_extras={"additional_config": additional_config}) for i in (0, 2)]
|
||||
)
|
||||
config = VllmOmniConfig.from_pipeline_config(pipeline, user_deploy_config=deploy)
|
||||
stage = config.stage_by_id(stage_id)
|
||||
assert stage.runtime_config.additional_config == additional_config
|
||||
engine_args = build_engine_args_dict_from_omni_stage_config(stage, model="test-model")
|
||||
assert engine_args["additional_config"] == additional_config
|
||||
|
||||
engine_args["additional_config"]["backend_options"]["enabled"] = False
|
||||
assert stage.runtime_config.additional_config["backend_options"]["enabled"] is True
|
||||
stage.runtime_config.additional_config["backend_options"]["enabled"] = False
|
||||
assert config.stage_by_id(2 if stage_id == 0 else 0).runtime_config.additional_config == additional_config
|
||||
assert additional_config["backend_options"]["enabled"] is True
|
||||
|
||||
|
||||
@pytest.mark.parametrize("deploy_name", ["minicpmo_4_5", "minicpmo_4_5_2gpu", "minicpmo_4_5_3gpu"])
|
||||
def test_minicpmo_npu_additional_config_reaches_engine_args(monkeypatch, deploy_name):
|
||||
from vllm_omni.engine import stage_init_utils
|
||||
from vllm_omni.engine.stage_init_utils import build_engine_args_dict_from_omni_stage_config
|
||||
from vllm_omni.platforms import current_omni_platform
|
||||
|
||||
monkeypatch.setattr(current_omni_platform, "device_name", "npu")
|
||||
monkeypatch.setattr(stage_init_utils, "resolve_worker_cls", lambda engine_args: None)
|
||||
stage = _from_pipeline_key("minicpmo_4_5", deploy_config_path=deploy_name).stage_by_id(2)
|
||||
expected = {"code2wav_enable_npu_graph": True, "code2wav_max_npu_graphs": 32}
|
||||
assert stage.runtime_config.additional_config == expected
|
||||
engine_args = build_engine_args_dict_from_omni_stage_config(stage, model="test-model")
|
||||
assert engine_args["additional_config"] == expected
|
||||
|
||||
|
||||
def test_diffusion_additional_config_keeps_diffusion_owner():
|
||||
from vllm_omni.engine.stage_init_utils import build_engine_args_dict_from_omni_stage_config
|
||||
|
||||
additional_config = {"torchair_graph_config": {"enabled": True}}
|
||||
stage = _from_pipeline_key("dreamzero", cli_overrides={"additional_config": additional_config}).stage_by_id(0)
|
||||
assert stage.runtime_config.additional_config is None
|
||||
assert stage.diffusion_config.additional_config == additional_config
|
||||
engine_args = build_engine_args_dict_from_omni_stage_config(stage, model="test-model")
|
||||
assert engine_args["additional_config"] == additional_config
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
("engine_extras", "cli_overrides"),
|
||||
[
|
||||
@@ -593,17 +532,6 @@ def test_from_pipeline_config_dispatches_async_chunk_processors_without_mutating
|
||||
assert pipeline.get_stage(1).custom_process_input_func is None
|
||||
|
||||
|
||||
def test_joyai_code2wav_waits_for_full_payload():
|
||||
config = _from_pipeline_key("joyai_vl_interaction")
|
||||
talker = config.stage_by_id(1)
|
||||
code2wav = config.stage_by_id(2)
|
||||
|
||||
assert talker.custom_process_next_stage_input_func.endswith("talker2code2wav_full_payload")
|
||||
assert code2wav.custom_process_input_func.endswith("talker2code2wav_token_only")
|
||||
assert code2wav.connector_config.async_chunk is False
|
||||
assert code2wav.model_config.requires_full_payload_input is True
|
||||
|
||||
|
||||
def test_vllm_omni_stage_config_public_fields_use_typed_stage_realizations():
|
||||
assert not hasattr(BaseVllmOmniStageConfig, "from_stage_config")
|
||||
assert not hasattr(BaseVllmOmniStageConfig, "to_legacy_stage_config")
|
||||
@@ -631,7 +559,6 @@ def test_vllm_omni_stage_config_public_fields_use_typed_stage_realizations():
|
||||
|
||||
def test_runtime_config_fields_match_structured_runtime_scope():
|
||||
assert {f.name for f in fields(OmniStageRuntimeConfig)} == {
|
||||
"additional_config",
|
||||
"distributed_executor_backend",
|
||||
"worker_cls",
|
||||
"devices",
|
||||
@@ -1326,70 +1253,6 @@ def test_diffusion_config_from_kwargs_reuses_legacy_normalization(monkeypatch):
|
||||
assert cfg.diffusers_call_kwargs == {}
|
||||
|
||||
|
||||
def test_diffusion_config_none_values_preserve_dataclass_defaults():
|
||||
from vllm_omni.diffusion.data import OmniDiffusionConfig
|
||||
|
||||
normalized = OmniDiffusionConfig.normalize_init_kwargs(
|
||||
{
|
||||
"lora_scale": None,
|
||||
"enable_sleep_mode": None,
|
||||
"diffusers_load_kwargs": None,
|
||||
}
|
||||
)
|
||||
|
||||
assert "lora_scale" not in normalized
|
||||
assert "enable_sleep_mode" not in normalized
|
||||
assert normalized["diffusers_load_kwargs"] == {}
|
||||
|
||||
config = OmniDiffusionConfig.from_kwargs(
|
||||
lora_scale=None,
|
||||
enable_sleep_mode=None,
|
||||
)
|
||||
assert config.lora_scale == 1.0
|
||||
assert config.enable_sleep_mode is False
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
("canonical_key", "alias_key", "canonical_value", "alias_value"),
|
||||
[
|
||||
("lora_scale", "static_lora_scale", 0.75, 0.25),
|
||||
(
|
||||
"quantization_config",
|
||||
"diffusion_quantization_config",
|
||||
{"method": "canonical"},
|
||||
{"method": "diffusion-alias"},
|
||||
),
|
||||
(
|
||||
"quantization_config",
|
||||
"quantization",
|
||||
{"method": "canonical"},
|
||||
"legacy-alias",
|
||||
),
|
||||
("diffusion_kv_cache_dtype", "kv_cache_dtype", "fp8", "fp16"),
|
||||
("diffusion_kv_cache_skip_steps", "kv_cache_skip_steps", "0-1", "2-3"),
|
||||
("diffusion_kv_cache_skip_layers", "kv_cache_skip_layers", "1-2", "3-4"),
|
||||
("streaming_output", "diffusion_streaming_output", False, True),
|
||||
],
|
||||
)
|
||||
def test_diffusion_alias_conflicts_prefer_canonical_key(
|
||||
canonical_key,
|
||||
alias_key,
|
||||
canonical_value,
|
||||
alias_value,
|
||||
):
|
||||
from vllm_omni.diffusion.data import normalize_omni_diffusion_kwargs
|
||||
|
||||
normalized = normalize_omni_diffusion_kwargs(
|
||||
{
|
||||
canonical_key: canonical_value,
|
||||
alias_key: alias_value,
|
||||
}
|
||||
)
|
||||
|
||||
assert normalized[canonical_key] == canonical_value
|
||||
assert alias_key not in normalized
|
||||
|
||||
|
||||
def test_from_pipeline_config_normalizes_diffusion_config_aliases_from_engine_args(tmp_path, monkeypatch):
|
||||
from vllm_omni.platforms import current_omni_platform
|
||||
|
||||
|
||||
@@ -19,9 +19,6 @@ from vllm.v1.core.sched.output import SchedulerOutput
|
||||
from vllm.v1.outputs import ModelRunnerOutput
|
||||
from vllm.v1.request import Request, RequestStatus, StreamingUpdate
|
||||
from vllm_omni.core.sched.omni_ar_scheduler import OmniARAsyncScheduler, OmniARScheduler
|
||||
from vllm_omni.distributed.omni_connectors.transfer_adapter.chunk_transfer_adapter import (
|
||||
OmniChunkTransferAdapter,
|
||||
)
|
||||
|
||||
# isort: on
|
||||
|
||||
@@ -65,43 +62,6 @@ def _make_update(prompt_token_ids: list[int] | None = None) -> StreamingUpdate:
|
||||
)
|
||||
|
||||
|
||||
def _make_talker_adapter(
|
||||
*,
|
||||
max_model_len: int = 100,
|
||||
recompute_on_capacity: bool = True,
|
||||
) -> OmniChunkTransferAdapter:
|
||||
adapter = OmniChunkTransferAdapter.__new__(OmniChunkTransferAdapter)
|
||||
adapter.receives_chunks = False
|
||||
adapter._max_model_len = max_model_len
|
||||
adapter._streaming_prompt_previous_chunks = 1
|
||||
adapter._streaming_prompt_recompute_on_capacity = recompute_on_capacity
|
||||
adapter._streaming_condition_lengths = {}
|
||||
adapter._streaming_condition_seqs = {}
|
||||
adapter.segment_finished_requests = set()
|
||||
adapter.requests_num_chunks_sent = {}
|
||||
return adapter
|
||||
|
||||
|
||||
def _make_talker_update(
|
||||
condition_len: int,
|
||||
*,
|
||||
reserve: int = 10,
|
||||
condition_seq: int | None,
|
||||
) -> StreamingUpdate:
|
||||
update = _make_update([0] * condition_len)
|
||||
update.model_intermediate_buffer = {
|
||||
"native_duplex": True,
|
||||
"ids": {"prompt": [1]},
|
||||
"meta": {
|
||||
"next_stage_prompt_len": condition_len,
|
||||
"next_stage_generation_tokens": reserve,
|
||||
},
|
||||
}
|
||||
if condition_seq is not None:
|
||||
update.model_intermediate_buffer["meta"]["streaming_condition_seq"] = condition_seq
|
||||
return update
|
||||
|
||||
|
||||
def _run_resumable_segment_stop(
|
||||
session: Request,
|
||||
*,
|
||||
@@ -578,288 +538,6 @@ def test_explicit_model_intermediate_prompt_replacement_releases_cache_and_water
|
||||
sched.encoder_cache_manager.free.assert_called_once_with(session)
|
||||
|
||||
|
||||
def test_talker_capacity_exact_fit_extends_from_declared_length_without_ids_prompt() -> None:
|
||||
sched = _make_scheduler(stage_id=1)
|
||||
adapter = _make_talker_adapter(max_model_len=100)
|
||||
sched.chunk_transfer_adapter = adapter
|
||||
session = _make_request()
|
||||
session.external_req_id = "external-capacity-exact-fit"
|
||||
session.prompt_token_ids = [0] * 70
|
||||
session._all_token_ids.clear()
|
||||
session._all_token_ids.extend(session.prompt_token_ids)
|
||||
session._output_token_ids.clear()
|
||||
session.append_output_token_ids([7, 8, 9, 10])
|
||||
session.num_prompt_tokens = 70
|
||||
session.num_computed_tokens = 74
|
||||
session.status = RequestStatus.WAITING_FOR_STREAMING_REQ
|
||||
sched.num_waiting_for_streaming_input = 1
|
||||
adapter._streaming_condition_lengths[session.request_id] = 20
|
||||
adapter._streaming_condition_seqs[session.request_id] = 0
|
||||
update = _make_talker_update(16, condition_seq=1)
|
||||
update.model_intermediate_buffer["ids"] = {"tts": [1, 2, 3]}
|
||||
|
||||
sched._update_request_as_session(session, update)
|
||||
|
||||
assert session.num_computed_tokens == 74
|
||||
assert session.num_prompt_tokens == 90
|
||||
assert list(session._all_token_ids[-20:]) == [7, 8, 9, 10] + [0] * 16
|
||||
assert update.model_intermediate_buffer["meta"] == {
|
||||
"next_stage_prompt_len": 16,
|
||||
"next_stage_generation_tokens": 10,
|
||||
"streaming_condition_seq": 1,
|
||||
"streaming_prompt_recompute": False,
|
||||
}
|
||||
assert adapter._streaming_condition_lengths[session.request_id] == 16
|
||||
assert adapter._streaming_condition_seqs[session.request_id] == 1
|
||||
assert session._omni_segment_generation == 1
|
||||
assert session.status == RequestStatus.WAITING
|
||||
assert sched.num_waiting_for_streaming_input == 0
|
||||
sched._free_request_blocks.assert_not_called()
|
||||
sched.encoder_cache_manager.free.assert_not_called()
|
||||
|
||||
|
||||
def test_talker_first_update_seeds_sender_condition_tracking() -> None:
|
||||
sched = _make_scheduler(stage_id=1)
|
||||
adapter = _make_talker_adapter(max_model_len=100)
|
||||
sched.chunk_transfer_adapter = adapter
|
||||
session = _make_request()
|
||||
session.external_req_id = "external-capacity-first-update"
|
||||
session.prompt_token_ids = [0] * 20
|
||||
session._all_token_ids.clear()
|
||||
session._all_token_ids.extend(session.prompt_token_ids)
|
||||
session._output_token_ids.clear()
|
||||
session.append_output_token_ids([7, 8, 9])
|
||||
session.num_prompt_tokens = 20
|
||||
session.num_computed_tokens = 23
|
||||
session.model_intermediate_buffer = {
|
||||
"native_duplex": True,
|
||||
"meta": {
|
||||
"next_stage_prompt_len": 20,
|
||||
"next_stage_generation_tokens": 10,
|
||||
"streaming_condition_seq": 0,
|
||||
},
|
||||
}
|
||||
session.status = RequestStatus.WAITING_FOR_STREAMING_REQ
|
||||
sched.num_waiting_for_streaming_input = 1
|
||||
update = _make_talker_update(16, condition_seq=1)
|
||||
|
||||
sched._update_request_as_session(session, update)
|
||||
|
||||
assert update.model_intermediate_buffer["meta"]["streaming_condition_seq"] == 1
|
||||
assert update.model_intermediate_buffer["meta"]["streaming_prompt_recompute"] is False
|
||||
assert adapter._streaming_condition_lengths[session.request_id] == 16
|
||||
assert adapter._streaming_condition_seqs[session.request_id] == 1
|
||||
assert session.num_computed_tokens == 23
|
||||
assert session.num_prompt_tokens == 39
|
||||
sched._free_request_blocks.assert_not_called()
|
||||
sched.encoder_cache_manager.free.assert_not_called()
|
||||
|
||||
|
||||
def test_talker_first_sliding_update_recomputes_from_seeded_condition() -> None:
|
||||
sched = _make_scheduler(stage_id=1)
|
||||
adapter = _make_talker_adapter(recompute_on_capacity=False)
|
||||
sched.chunk_transfer_adapter = adapter
|
||||
session = _make_request()
|
||||
session.external_req_id = "external-sliding-first-update"
|
||||
session.prompt_token_ids = [0] * 20
|
||||
session._all_token_ids.clear()
|
||||
session._all_token_ids.extend(session.prompt_token_ids)
|
||||
session._output_token_ids.clear()
|
||||
previous_codes = [7, 8, 9]
|
||||
session.append_output_token_ids(previous_codes)
|
||||
session.num_prompt_tokens = 20
|
||||
session.num_computed_tokens = 23
|
||||
session.model_intermediate_buffer = {
|
||||
"native_duplex": True,
|
||||
"meta": {
|
||||
"next_stage_prompt_len": 20,
|
||||
"next_stage_generation_tokens": 10,
|
||||
"streaming_condition_seq": 0,
|
||||
},
|
||||
}
|
||||
session.status = RequestStatus.WAITING_FOR_STREAMING_REQ
|
||||
sched.num_waiting_for_streaming_input = 1
|
||||
update = _make_talker_update(16, condition_seq=1)
|
||||
|
||||
sched._update_request_as_session(session, update)
|
||||
|
||||
assert session.num_computed_tokens == 0
|
||||
assert session.num_prompt_tokens == 39
|
||||
assert update.model_intermediate_buffer["ids"]["streaming_prompt_previous_codes"] == previous_codes
|
||||
assert update.model_intermediate_buffer["meta"]["streaming_prompt_recompute"] is True
|
||||
assert adapter._streaming_condition_lengths[session.request_id] == 16
|
||||
assert adapter._streaming_condition_seqs[session.request_id] == 1
|
||||
sched._free_request_blocks.assert_called_once_with(session)
|
||||
sched.encoder_cache_manager.free.assert_called_once_with(session)
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
("condition_seq", "error"),
|
||||
[
|
||||
(None, "missing streaming_condition_seq"),
|
||||
(0, "expected=1, received=0"),
|
||||
(2, "expected=1, received=2"),
|
||||
],
|
||||
)
|
||||
def test_talker_invalid_condition_sequence_does_not_advance_tracking(mocker, condition_seq, error) -> None:
|
||||
sched = _make_scheduler(stage_id=1)
|
||||
adapter = _make_talker_adapter()
|
||||
adapter.record_receive_failure = mocker.MagicMock()
|
||||
adapter._streaming_condition_lengths["req-ar-streaming-test"] = 20
|
||||
adapter._streaming_condition_seqs["req-ar-streaming-test"] = 0
|
||||
sched.chunk_transfer_adapter = adapter
|
||||
session = _make_request()
|
||||
session.status = RequestStatus.WAITING_FOR_STREAMING_REQ
|
||||
sched.num_waiting_for_streaming_input = 1
|
||||
update = _make_talker_update(16, condition_seq=condition_seq)
|
||||
|
||||
sched._update_request_as_session(session, update)
|
||||
|
||||
failure = adapter.record_receive_failure.call_args.args
|
||||
assert failure[0] == session.request_id
|
||||
assert error in failure[1]
|
||||
assert adapter._streaming_condition_lengths[session.request_id] == 20
|
||||
assert adapter._streaming_condition_seqs[session.request_id] == 0
|
||||
assert session.status == RequestStatus.WAITING_FOR_STREAMING_REQ
|
||||
|
||||
|
||||
def test_talker_first_update_that_cannot_fit_window_is_request_local(mocker) -> None:
|
||||
sched = _make_scheduler(stage_id=1)
|
||||
adapter = _make_talker_adapter()
|
||||
adapter.record_receive_failure = mocker.MagicMock()
|
||||
sched.chunk_transfer_adapter = adapter
|
||||
session = _make_request()
|
||||
session.prompt_token_ids = [0] * 20
|
||||
session._all_token_ids.clear()
|
||||
session._all_token_ids.extend(session.prompt_token_ids)
|
||||
session._output_token_ids.clear()
|
||||
session.append_output_token_ids(list(range(9)))
|
||||
session.num_prompt_tokens = 20
|
||||
session.num_computed_tokens = 29
|
||||
session.model_intermediate_buffer = {
|
||||
"native_duplex": True,
|
||||
"meta": {
|
||||
"next_stage_prompt_len": 20,
|
||||
"next_stage_generation_tokens": 10,
|
||||
"streaming_condition_seq": 0,
|
||||
},
|
||||
}
|
||||
session.status = RequestStatus.WAITING_FOR_STREAMING_REQ
|
||||
sched.num_waiting_for_streaming_input = 1
|
||||
update = _make_talker_update(62, condition_seq=1)
|
||||
|
||||
sched._update_request_as_session(session, update)
|
||||
|
||||
failure = adapter.record_receive_failure.call_args.args
|
||||
assert failure[0] == session.request_id
|
||||
assert "sliding streaming prompt plus generation reserve exceeds max_model_len" in failure[1]
|
||||
assert adapter._streaming_condition_lengths == {}
|
||||
assert adapter._streaming_condition_seqs == {}
|
||||
assert session.status == RequestStatus.WAITING_FOR_STREAMING_REQ
|
||||
|
||||
|
||||
def test_talker_capacity_overflow_recomputes_then_resumes_accumulation() -> None:
|
||||
sched = _make_scheduler(stage_id=1)
|
||||
adapter = _make_talker_adapter(max_model_len=100)
|
||||
sched.chunk_transfer_adapter = adapter
|
||||
session = _make_request()
|
||||
session.external_req_id = "external-capacity-rollover"
|
||||
session.prompt_token_ids = [0] * 70
|
||||
session._all_token_ids.clear()
|
||||
session._all_token_ids.extend(session.prompt_token_ids)
|
||||
session._output_token_ids.clear()
|
||||
previous_codes = [7, 8, 9, 10]
|
||||
session.append_output_token_ids(previous_codes)
|
||||
session.num_prompt_tokens = 70
|
||||
session.num_computed_tokens = 74
|
||||
session.status = RequestStatus.WAITING_FOR_STREAMING_REQ
|
||||
sched.num_waiting_for_streaming_input = 1
|
||||
adapter._streaming_condition_lengths[session.request_id] = 20
|
||||
adapter._streaming_condition_seqs[session.request_id] = 0
|
||||
adapter.segment_finished_requests.add(session.request_id)
|
||||
adapter.requests_num_chunks_sent[session.external_req_id] = 74
|
||||
overflow_update = _make_talker_update(17, condition_seq=1)
|
||||
|
||||
sched._update_request_as_session(session, overflow_update)
|
||||
|
||||
assert session.num_computed_tokens == 0
|
||||
assert session.num_prompt_tokens == 41
|
||||
assert session.prompt_token_ids == [0] * 41
|
||||
assert overflow_update.model_intermediate_buffer["ids"]["streaming_prompt_previous_codes"] == previous_codes
|
||||
assert overflow_update.model_intermediate_buffer["meta"]["streaming_condition_seq"] == 1
|
||||
assert overflow_update.model_intermediate_buffer["meta"]["streaming_prompt_recompute"] is True
|
||||
assert adapter.segment_finished_requests == set()
|
||||
assert adapter.requests_num_chunks_sent == {}
|
||||
assert session._omni_segment_generation == 1
|
||||
sched._free_request_blocks.assert_called_once_with(session)
|
||||
sched.encoder_cache_manager.free.assert_called_once_with(session)
|
||||
|
||||
# Once the replacement has been recomputed, later conditions append to
|
||||
# the new full-attention prefix until capacity is approached again.
|
||||
next_codes = [21, 22, 23, 24, 25, 26]
|
||||
session.append_output_token_ids(next_codes)
|
||||
session.num_computed_tokens = 47
|
||||
session.status = RequestStatus.WAITING_FOR_STREAMING_REQ
|
||||
sched.num_waiting_for_streaming_input = 1
|
||||
append_update = _make_talker_update(20, condition_seq=2)
|
||||
|
||||
sched._update_request_as_session(session, append_update)
|
||||
|
||||
assert session.num_computed_tokens == 47
|
||||
assert session.num_prompt_tokens == 67
|
||||
assert list(session._all_token_ids[-26:]) == next_codes + [0] * 20
|
||||
assert append_update.model_intermediate_buffer["meta"]["streaming_condition_seq"] == 2
|
||||
assert append_update.model_intermediate_buffer["meta"]["streaming_prompt_recompute"] is False
|
||||
assert session._omni_segment_generation == 2
|
||||
assert sched._free_request_blocks.call_count == 1
|
||||
assert sched.encoder_cache_manager.free.call_count == 1
|
||||
|
||||
# A later overflow replaces the accumulated prefix again rather than
|
||||
# reverting to recompute-on-every-condition behavior.
|
||||
second_rollover_codes = [31, 32, 33, 34, 35, 36]
|
||||
session.num_computed_tokens = session.num_prompt_tokens
|
||||
session.append_output_token_ids(second_rollover_codes)
|
||||
session.num_computed_tokens += len(second_rollover_codes)
|
||||
session.status = RequestStatus.WAITING_FOR_STREAMING_REQ
|
||||
sched.num_waiting_for_streaming_input = 1
|
||||
second_overflow_update = _make_talker_update(18, condition_seq=3)
|
||||
|
||||
sched._update_request_as_session(session, second_overflow_update)
|
||||
|
||||
assert session.num_computed_tokens == 0
|
||||
assert session.num_prompt_tokens == 44
|
||||
assert second_overflow_update.model_intermediate_buffer["ids"]["streaming_prompt_previous_codes"] == (
|
||||
second_rollover_codes
|
||||
)
|
||||
assert second_overflow_update.model_intermediate_buffer["meta"]["streaming_condition_seq"] == 3
|
||||
assert second_overflow_update.model_intermediate_buffer["meta"]["streaming_prompt_recompute"] is True
|
||||
assert session._omni_segment_generation == 3
|
||||
assert sched._free_request_blocks.call_count == 2
|
||||
assert sched.encoder_cache_manager.free.call_count == 2
|
||||
|
||||
|
||||
def test_talker_invalid_capacity_update_is_reported_per_request(mocker) -> None:
|
||||
sched = _make_scheduler(stage_id=1)
|
||||
adapter = _make_talker_adapter(max_model_len=100)
|
||||
adapter.record_receive_failure = mocker.MagicMock()
|
||||
sched.chunk_transfer_adapter = adapter
|
||||
session = _make_request()
|
||||
session.status = RequestStatus.WAITING_FOR_STREAMING_REQ
|
||||
sched.num_waiting_for_streaming_input = 1
|
||||
update = _make_talker_update(91, condition_seq=0)
|
||||
|
||||
sched._update_request_as_session(session, update)
|
||||
|
||||
adapter.record_receive_failure.assert_called_once_with(
|
||||
session.request_id,
|
||||
"fresh streaming prompt plus generation reserve exceeds max_model_len: prompt=91, reserve=10, limit=100",
|
||||
)
|
||||
assert session.status == RequestStatus.WAITING_FOR_STREAMING_REQ
|
||||
assert sched.num_waiting_for_streaming_input == 1
|
||||
sched._free_request_blocks.assert_not_called()
|
||||
sched.encoder_cache_manager.free.assert_not_called()
|
||||
|
||||
|
||||
def test_ready_async_chunk_prompt_replacement_releases_stale_kv_once() -> None:
|
||||
sched = _make_scheduler(stage_id=1)
|
||||
session = _make_request()
|
||||
|
||||
@@ -1,59 +0,0 @@
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
# SPDX-FileCopyrightText: Copyright contributors to the vLLM-Omni project
|
||||
"""The omni scheduler must stay on the v1 model runner, like every omni worker.
|
||||
|
||||
vLLM 0.28 resolved this config to v1; 0.29 ends its fallback chain with v2. When
|
||||
only the workers forced v1, the scheduler took its v2 fast path -- which omits
|
||||
resumed-request token ids -- while the v1 runner still read them, so resuming a
|
||||
request raised ``KeyError: <req_id>`` in ``_update_states`` and killed the engine
|
||||
core (Multi-Replica Startup Test).
|
||||
|
||||
The default is upstream's to change, so this pins Omni's side of the contract
|
||||
rather than the default itself.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from types import SimpleNamespace
|
||||
|
||||
import pytest
|
||||
|
||||
from vllm_omni.core.sched.omni_scheduler_mixin import OmniSchedulerMixin
|
||||
|
||||
pytestmark = [pytest.mark.core_model, pytest.mark.cpu]
|
||||
|
||||
|
||||
class _Scheduler(OmniSchedulerMixin):
|
||||
"""Minimal carrier for the shared init hook both omni schedulers call."""
|
||||
|
||||
def __init__(self, *, use_v2_model_runner: bool) -> None:
|
||||
self.use_v2_model_runner = use_v2_model_runner
|
||||
self.vllm_config = SimpleNamespace(
|
||||
model_config=SimpleNamespace(
|
||||
async_chunk=False,
|
||||
stage_id=0,
|
||||
pooling_output_decoder=None,
|
||||
)
|
||||
)
|
||||
self._init_omni_io_scheduling_state()
|
||||
|
||||
|
||||
@pytest.mark.parametrize("initial", [True, False])
|
||||
def test_scheduler_ends_on_v1_model_runner(initial: bool) -> None:
|
||||
"""Whatever upstream resolves, the omni scheduler runs v1."""
|
||||
assert _Scheduler(use_v2_model_runner=initial).use_v2_model_runner is False
|
||||
|
||||
|
||||
def test_v2_default_does_not_reach_the_resumed_request_fast_path() -> None:
|
||||
"""The v2 fast path is what dropped resumed-request token ids.
|
||||
|
||||
``OmniGenerationScheduler`` branches on ``use_v2_model_runner`` when it
|
||||
assembles SchedulerOutput; forcing it false keeps the v1 assembly that
|
||||
carries ``all_token_ids`` for resumed requests, which the v1 runner reads.
|
||||
"""
|
||||
scheduler = _Scheduler(use_v2_model_runner=True)
|
||||
|
||||
assert not scheduler.use_v2_model_runner, (
|
||||
"scheduler would take the v2 fast path while omni workers run v1; "
|
||||
"resumed requests then KeyError in _update_states"
|
||||
)
|
||||
@@ -1,6 +1,3 @@
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
# SPDX-FileCopyrightText: Copyright contributors to the vLLM-Omni project
|
||||
|
||||
"""
|
||||
Performance benchmark CI runner for diffusion models.
|
||||
|
||||
@@ -359,8 +356,6 @@ def _resolve_offline_model(model: str) -> str:
|
||||
"""
|
||||
import huggingface_hub
|
||||
|
||||
from vllm_omni.transformers_utils.repo_utils import hf_api
|
||||
|
||||
if not model or os.path.isdir(model):
|
||||
return model
|
||||
|
||||
@@ -385,7 +380,9 @@ def _resolve_offline_model(model: str) -> str:
|
||||
if len(parts) >= 3:
|
||||
repo_id = "/".join(parts[:2])
|
||||
subfolder = "/".join(parts[2:])
|
||||
snapshot_root = hf_api().snapshot_download(
|
||||
from huggingface_hub import snapshot_download
|
||||
|
||||
snapshot_root = snapshot_download(
|
||||
repo_id,
|
||||
allow_patterns=[f"{subfolder}/**"],
|
||||
local_files_only=huggingface_hub.constants.HF_HUB_OFFLINE,
|
||||
@@ -394,7 +391,9 @@ def _resolve_offline_model(model: str) -> str:
|
||||
|
||||
if not huggingface_hub.constants.HF_HUB_OFFLINE:
|
||||
return model
|
||||
return hf_api().snapshot_download(model, local_files_only=True)
|
||||
from huggingface_hub import snapshot_download
|
||||
|
||||
return snapshot_download(model, local_files_only=True)
|
||||
|
||||
|
||||
class DiffusionServer:
|
||||
|
||||
@@ -13,6 +13,9 @@ from tests.helpers.runtime import OmniServer, OmniServerParams, OnlineOmniClient
|
||||
|
||||
pytestmark = [pytest.mark.slow, pytest.mark.diffusion]
|
||||
|
||||
# https://github.com/vllm-project/vllm-omni/issues/3649 — invalid inputs still HTTP 200 / timeout / missing validation.
|
||||
_SKIP_ISSUE_3649 = pytest.mark.skip(reason="https://github.com/vllm-project/vllm-omni/issues/3649")
|
||||
|
||||
_PARAMS = [
|
||||
pytest.param(
|
||||
OmniServerParams(
|
||||
@@ -33,8 +36,10 @@ _PARAMS = [
|
||||
@pytest.mark.parametrize(
|
||||
"overrides, err_message",
|
||||
[
|
||||
pytest.param({"input": ""}, ("cannot be empty", "input"), id="input_empty"),
|
||||
pytest.param({"input": " "}, ("cannot be empty", "input"), id="input_whitespace_only"),
|
||||
pytest.param({"input": ""}, ("cannot be empty", "input"), id="input_empty", marks=_SKIP_ISSUE_3649),
|
||||
pytest.param(
|
||||
{"input": " "}, ("cannot be empty", "input"), id="input_whitespace_only", marks=_SKIP_ISSUE_3649
|
||||
),
|
||||
pytest.param({"input": 123}, ("input", "a valid string"), id="input_wrong_type"),
|
||||
pytest.param(
|
||||
{"response_format": "mpeg"},
|
||||
@@ -49,8 +54,10 @@ _PARAMS = [
|
||||
("sse", "stream_format", "value_error", "not a supported stream_format"),
|
||||
id="stream_format_sse_blocked",
|
||||
),
|
||||
pytest.param({"audio_length": -1.0}, ("audio_length", "greater_than", "0"), id="audio_length_negative"),
|
||||
pytest.param({"audio_length": 0}, ("audio_length", "greater_than", "0"), id="audio_length_zero"),
|
||||
pytest.param(
|
||||
{"audio_length": -1.0}, ("audio_end_in_s", "higher than", "audio_start_in_s"), id="audio_length_negative"
|
||||
),
|
||||
pytest.param({"audio_length": 0}, "audio_length", id="audio_length_zero", marks=_SKIP_ISSUE_3649),
|
||||
# ``OmniOpenAIServingAudioGenerate`` only forwards ``audio_start`` when ``audio_length`` is set.
|
||||
pytest.param(
|
||||
{"audio_start": -0.5, "audio_length": 5.0},
|
||||
@@ -60,30 +67,26 @@ _PARAMS = [
|
||||
pytest.param(
|
||||
{"negative_prompt": ["noise"]}, ("negative_prompt", "a valid string"), id="negative_prompt_wrong_type"
|
||||
),
|
||||
pytest.param(
|
||||
{"guidance_scale": -1.0},
|
||||
("guidance_scale", "greater_than_equal", "0"),
|
||||
id="guidance_scale_negative",
|
||||
),
|
||||
pytest.param({"guidance_scale": -1.0}, "guidance_scale", id="guidance_scale_negative", marks=_SKIP_ISSUE_3649),
|
||||
pytest.param({"guidance_scale": 0}, "guidance_scale", id="guidance_scale_zero", marks=_SKIP_ISSUE_3649),
|
||||
pytest.param(
|
||||
{"num_inference_steps": 0},
|
||||
("num_inference_steps", "greater_than_equal", "1"),
|
||||
("num_inference_steps", "greater than or equal to 1"),
|
||||
id="num_inference_steps_zero",
|
||||
),
|
||||
pytest.param(
|
||||
{"num_inference_steps": -1},
|
||||
("num_inference_steps", "greater_than_equal", "1"),
|
||||
("num_inference_steps", "greater than or equal to 1"),
|
||||
id="num_inference_steps_negative",
|
||||
),
|
||||
pytest.param(
|
||||
{"num_inference_steps": 6000},
|
||||
("num_inference_steps", "less_than_equal", "1000"),
|
||||
"num_inference_steps",
|
||||
id="num_inference_steps_above_max",
|
||||
marks=_SKIP_ISSUE_3649,
|
||||
),
|
||||
pytest.param(
|
||||
{"guidance_scale": 1001.0},
|
||||
("guidance_scale", "less_than_equal", "1000"),
|
||||
id="guidance_scale_above_max",
|
||||
{"guidance_scale": 1001.0}, "guidance_scale", id="guidance_scale_above_max", marks=_SKIP_ISSUE_3649
|
||||
),
|
||||
pytest.param(
|
||||
{"audio_length": 86401.0}, ("Requested audio length", "exceeds maximum"), id="audio_length_above_max"
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
# SPDX-FileCopyrightText: Copyright contributors to the vLLM-Omni project
|
||||
"""CPU contracts for capability-driven AR-Diffusion sessions."""
|
||||
|
||||
from __future__ import annotations
|
||||
@@ -11,7 +10,6 @@ from types import SimpleNamespace
|
||||
import pytest
|
||||
import torch
|
||||
|
||||
from vllm_omni.diffusion.sched.interface import CachedRequestData, DiffusionSchedulerOutput
|
||||
from vllm_omni.diffusion.worker.diffusion_model_runner import DiffusionModelRunner
|
||||
from vllm_omni.experimental.ar_diffusion.capability import (
|
||||
ARDiffusionCrossAttentionKVSpec,
|
||||
@@ -29,22 +27,6 @@ NEG = "negative"
|
||||
pytestmark = [pytest.mark.core_model, pytest.mark.cpu]
|
||||
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
def platform_synchronize_calls(monkeypatch) -> list[None]:
|
||||
"""Stub the platform barrier the runner takes at every chunk boundary.
|
||||
|
||||
These tests run on a CPU host, where the resolved platform is
|
||||
``UnspecifiedOmniPlatform`` and ``synchronize()`` raises. Tests that need
|
||||
a failing barrier override this with their own fake.
|
||||
"""
|
||||
calls: list[None] = []
|
||||
monkeypatch.setattr(
|
||||
"vllm_omni.experimental.ar_diffusion.runner.current_omni_platform",
|
||||
SimpleNamespace(synchronize=lambda: calls.append(None)),
|
||||
)
|
||||
return calls
|
||||
|
||||
|
||||
def lingbot_like_spec(*, capacity: int = 2) -> ARDiffusionKVCacheSpec:
|
||||
"""Single-kv_branch causal DMD: 3 latent frames/block + sink/window + text KV."""
|
||||
return ARDiffusionKVCacheSpec(
|
||||
@@ -132,43 +114,6 @@ class BatchCapablePipeline(CapablePipeline):
|
||||
supports_request_batch = True
|
||||
|
||||
|
||||
class StepCapablePipeline(CapablePipeline):
|
||||
supports_step_execution = True
|
||||
|
||||
def prepare_encode(self, state, **kwargs):
|
||||
del kwargs
|
||||
return state
|
||||
|
||||
def denoise_step(self, input_batch, *, states=None, **kwargs):
|
||||
del input_batch, states, kwargs
|
||||
return None
|
||||
|
||||
def step_scheduler(self, state, noise_pred, **kwargs):
|
||||
del state, noise_pred, kwargs
|
||||
|
||||
def post_decode(self, state, **kwargs):
|
||||
del state, kwargs
|
||||
from vllm_omni.diffusion.data import DiffusionOutput
|
||||
|
||||
return DiffusionOutput()
|
||||
|
||||
|
||||
def scheduler_output(
|
||||
request_ids: tuple[str, ...] = ("req-1",),
|
||||
*,
|
||||
finished: tuple[str, ...] = (),
|
||||
) -> DiffusionSchedulerOutput:
|
||||
"""Build the real scheduler payload; stepwise requests arrive as cached rows."""
|
||||
return DiffusionSchedulerOutput(
|
||||
step_id=0,
|
||||
scheduled_new_reqs=[],
|
||||
scheduled_cached_reqs=CachedRequestData(request_ids=list(request_ids)),
|
||||
finished_req_ids=set(finished),
|
||||
num_running_reqs=len(request_ids),
|
||||
num_waiting_reqs=0,
|
||||
)
|
||||
|
||||
|
||||
def make_runner(
|
||||
pipeline: object,
|
||||
*,
|
||||
@@ -195,7 +140,6 @@ def make_runner(
|
||||
runner._sessions = OrderedDict()
|
||||
runner._session_capacity = 0
|
||||
runner._perf_e2e_times = []
|
||||
runner._stepwise_chunk_started = {}
|
||||
runner._preallocate_kv_cache(available_bytes=available_bytes)
|
||||
return runner
|
||||
|
||||
@@ -451,16 +395,12 @@ def test_synchronize_exception_uses_forward_cleanup_path(monkeypatch):
|
||||
ctx.ensure_video_slots(torch.device("cpu"))
|
||||
return object()
|
||||
|
||||
def synchronize_boom():
|
||||
def synchronize_boom(device):
|
||||
raise RuntimeError("asynchronous kernel failed")
|
||||
|
||||
monkeypatch.setattr(DiffusionModelRunner, "execute_model", return_after_allocation)
|
||||
# The runner defers the device barrier to the platform, so the failure is
|
||||
# injected there rather than on a device-specific torch entry point.
|
||||
monkeypatch.setattr(
|
||||
"vllm_omni.experimental.ar_diffusion.runner.current_omni_platform",
|
||||
SimpleNamespace(synchronize=synchronize_boom),
|
||||
)
|
||||
monkeypatch.setattr(torch.accelerator, "synchronize", synchronize_boom)
|
||||
runner.device = torch.device("cuda")
|
||||
request = SimpleNamespace(
|
||||
request_id="broken-request",
|
||||
sampling_params=SimpleNamespace(extra_args={"session_id": "broken"}),
|
||||
@@ -484,11 +424,6 @@ def test_ar_runner_rejects_step_and_request_batch_modes():
|
||||
make_runner(BatchCapablePipeline(lingbot_like_spec()))
|
||||
|
||||
|
||||
def test_ar_runner_allows_step_execution_when_pipeline_implements_the_contract():
|
||||
runner = make_runner(StepCapablePipeline(lingbot_like_spec()), step_execution=True)
|
||||
assert runner.kv_cache is not None
|
||||
|
||||
|
||||
def test_ar_runner_defensively_rejects_inherited_batch_and_step_entrypoints():
|
||||
runner = object.__new__(ARDiffusionModelRunner)
|
||||
with pytest.raises(RuntimeError, match="request-batch execution"):
|
||||
@@ -497,144 +432,6 @@ def test_ar_runner_defensively_rejects_inherited_batch_and_step_entrypoints():
|
||||
runner.execute_stepwise(None)
|
||||
|
||||
|
||||
def test_execute_stepwise_binds_request_id_session_and_unbinds_after_call(monkeypatch):
|
||||
from vllm_omni.diffusion.worker.utils import BatchRunnerOutput, RunnerOutput
|
||||
|
||||
pipeline = StepCapablePipeline(lingbot_like_spec())
|
||||
runner = make_runner(pipeline, step_execution=True)
|
||||
bound_during = []
|
||||
|
||||
def fake_execute(self, scheduler_output):
|
||||
del self, scheduler_output
|
||||
bound_during.append(pipeline.bound_state is not None)
|
||||
return BatchRunnerOutput.from_list([RunnerOutput(request_id="req-1", finished=False)])
|
||||
|
||||
monkeypatch.setattr(DiffusionModelRunner, "execute_stepwise", fake_execute)
|
||||
output = runner.execute_stepwise(scheduler_output())
|
||||
|
||||
assert bound_during == [True]
|
||||
assert pipeline.bound_state is None
|
||||
assert pipeline.binds == ["req-1"]
|
||||
assert "req-1" in runner._sessions
|
||||
assert output.get_request_output("req-1") is not None
|
||||
assert not pipeline.closes
|
||||
|
||||
|
||||
def test_execute_stepwise_closes_session_when_request_finishes(monkeypatch):
|
||||
from vllm_omni.diffusion.worker.utils import BatchRunnerOutput, RunnerOutput
|
||||
|
||||
pipeline = StepCapablePipeline(lingbot_like_spec())
|
||||
runner = make_runner(pipeline, step_execution=True)
|
||||
|
||||
def fake_execute(self, scheduler_output):
|
||||
del self, scheduler_output
|
||||
return BatchRunnerOutput.from_list([RunnerOutput(request_id="req-1", finished=True)])
|
||||
|
||||
monkeypatch.setattr(DiffusionModelRunner, "execute_stepwise", fake_execute)
|
||||
runner.execute_stepwise(scheduler_output())
|
||||
|
||||
assert pipeline.bound_state is None
|
||||
assert pipeline.closes == ["req-1"]
|
||||
assert "req-1" not in runner._sessions
|
||||
|
||||
|
||||
def test_execute_stepwise_exception_releases_kv_and_does_not_resume_pages(monkeypatch):
|
||||
pipeline = StepCapablePipeline(lingbot_like_spec())
|
||||
runner = make_runner(pipeline, step_execution=True)
|
||||
first = runner._get_or_create_session("req-1")
|
||||
|
||||
def boom(self, scheduler_output):
|
||||
del self, scheduler_output
|
||||
raise RuntimeError("step failed")
|
||||
|
||||
monkeypatch.setattr(DiffusionModelRunner, "execute_stepwise", boom)
|
||||
with pytest.raises(RuntimeError, match="step failed"):
|
||||
runner.execute_stepwise(scheduler_output())
|
||||
|
||||
assert pipeline.bound_state is None
|
||||
assert pipeline.closes == ["req-1"]
|
||||
assert "req-1" not in runner._sessions
|
||||
second = runner._get_or_create_session("req-1")
|
||||
assert second is not first
|
||||
|
||||
|
||||
def test_execute_stepwise_closes_session_for_scheduler_aborted_request(monkeypatch):
|
||||
from vllm_omni.diffusion.worker.utils import BatchRunnerOutput
|
||||
|
||||
pipeline = StepCapablePipeline(lingbot_like_spec())
|
||||
runner = make_runner(pipeline, step_execution=True)
|
||||
runner._get_or_create_session("req-1")
|
||||
|
||||
def fake_execute(self, scheduler_output):
|
||||
del self, scheduler_output
|
||||
return BatchRunnerOutput.from_list([])
|
||||
|
||||
monkeypatch.setattr(DiffusionModelRunner, "execute_stepwise", fake_execute)
|
||||
# An aborted request is never scheduled again and never reports finished,
|
||||
# so the retire path is the only thing that can free its KV.
|
||||
runner.execute_stepwise(scheduler_output(request_ids=(), finished=("req-1",)))
|
||||
|
||||
assert "req-1" not in runner._sessions
|
||||
assert pipeline.closes == ["req-1"]
|
||||
|
||||
|
||||
def test_execute_stepwise_times_once_per_chunk_not_once_per_step(monkeypatch, platform_synchronize_calls):
|
||||
from vllm_omni.diffusion.data import DiffusionOutput
|
||||
from vllm_omni.diffusion.worker.utils import BatchRunnerOutput, RunnerOutput
|
||||
|
||||
pipeline = StepCapablePipeline(lingbot_like_spec())
|
||||
runner = make_runner(pipeline, step_execution=True)
|
||||
results = [None, None, None, DiffusionOutput()]
|
||||
|
||||
def fake_execute(self, scheduler_output):
|
||||
del self, scheduler_output
|
||||
return BatchRunnerOutput.from_list([RunnerOutput(request_id="req-1", finished=False, result=results.pop(0))])
|
||||
|
||||
monkeypatch.setattr(DiffusionModelRunner, "execute_stepwise", fake_execute)
|
||||
for _ in range(4):
|
||||
runner.execute_stepwise(scheduler_output())
|
||||
|
||||
# Four denoise steps, one emitted AR block: one timing sample, matching the
|
||||
# one-sample-per-block meaning request mode already has.
|
||||
assert len(runner._perf_e2e_times) == 1
|
||||
assert len(platform_synchronize_calls) == 1
|
||||
assert "req-1" not in runner._stepwise_chunk_started
|
||||
|
||||
|
||||
def test_execute_stepwise_synchronize_exception_fails_closed(monkeypatch):
|
||||
"""The chunk barrier is where an asynchronous device error surfaces. It must
|
||||
clean up like an in-step failure instead of leaving the session, the cached
|
||||
step state and the timing entry to the scheduler's next cycle."""
|
||||
from vllm_omni.diffusion.worker.utils import BatchRunnerOutput, RunnerOutput
|
||||
|
||||
pipeline = StepCapablePipeline(lingbot_like_spec())
|
||||
runner = make_runner(pipeline, step_execution=True)
|
||||
runner.state_cache = {"req-1": object()}
|
||||
|
||||
def fake_execute(self, scheduler_output):
|
||||
del self, scheduler_output
|
||||
return BatchRunnerOutput.from_list([RunnerOutput(request_id="req-1", finished=False, result=object())])
|
||||
|
||||
def synchronize_boom():
|
||||
raise RuntimeError("asynchronous kernel failed")
|
||||
|
||||
monkeypatch.setattr(DiffusionModelRunner, "execute_stepwise", fake_execute)
|
||||
monkeypatch.setattr(
|
||||
"vllm_omni.experimental.ar_diffusion.runner.current_omni_platform",
|
||||
SimpleNamespace(synchronize=synchronize_boom),
|
||||
)
|
||||
|
||||
with pytest.raises(RuntimeError, match="asynchronous kernel failed"):
|
||||
runner.execute_stepwise(scheduler_output())
|
||||
|
||||
assert pipeline.bound_state is None
|
||||
assert pipeline.closes == ["req-1"]
|
||||
assert "req-1" not in runner._sessions
|
||||
assert "req-1" not in runner.state_cache
|
||||
assert "req-1" not in runner._stepwise_chunk_started
|
||||
assert not runner._perf_e2e_times
|
||||
|
||||
|
||||
def test_model_specific_warmup_provider_is_consumed(monkeypatch):
|
||||
requests = [object(), object()]
|
||||
pipeline = WarmupPipeline(lingbot_like_spec(), requests)
|
||||
|
||||
@@ -25,9 +25,12 @@ from vllm_omni.experimental.ar_diffusion.kv_cache import (
|
||||
)
|
||||
from vllm_omni.experimental.ar_diffusion.kv_cache.paged import chunk_window_skipped_tokens
|
||||
|
||||
pytestmark = [pytest.mark.core_model, pytest.mark.diffusion, pytest.mark.cpu]
|
||||
|
||||
|
||||
BLOCK = 16
|
||||
|
||||
pytestmark = [pytest.mark.core_model, pytest.mark.diffusion, pytest.mark.cpu]
|
||||
pytestmark = [pytest.mark.core_model, pytest.mark.cpu]
|
||||
|
||||
|
||||
def make_spec(*, chunk_size=BLOCK, window_chunks=2, sink_chunks=0, reset_at_boundary=False):
|
||||
@@ -152,155 +155,14 @@ def test_paged_pool_layout_exposes_flat_slot_views():
|
||||
dtype=torch.float32,
|
||||
device=torch.device("cpu"),
|
||||
)
|
||||
key_cache, value_cache = kv_pools[0]
|
||||
assert key_cache.shape == value_cache.shape == (4, BLOCK, 4, 64)
|
||||
assert kv_pools[0].shape == (2, 4, BLOCK, 4, 64)
|
||||
assert k_pools[0].shape == (4 * BLOCK, 4, 64)
|
||||
assert v_pools[0].shape == (4 * BLOCK, 4, 64)
|
||||
|
||||
# The flat views must alias their block-shaped cache, so a slot write is
|
||||
# visible through the layout the attention kernel reads.
|
||||
k_pools[0][BLOCK + 3].fill_(7)
|
||||
v_pools[0][2 * BLOCK + 5].fill_(11)
|
||||
assert torch.equal(key_cache[1, 3], k_pools[0][BLOCK + 3])
|
||||
assert torch.equal(value_cache[2, 5], v_pools[0][2 * BLOCK + 5])
|
||||
|
||||
|
||||
def test_key_and_value_caches_do_not_share_storage():
|
||||
"""K and V must be separate allocations, not halves of one tensor.
|
||||
|
||||
The paged-write custom op declares both as mutated. When they alias one
|
||||
storage, inductor's reinplace pass can re-inplace only the first of the
|
||||
two, and auto_functionalized_v2's clone of the entire second pool survives
|
||||
into the compiled graph -- one full pool copied per compiled region per
|
||||
denoising step.
|
||||
"""
|
||||
kv_pools, k_pools, v_pools = allocate_kv_pool_with_views(
|
||||
num_blocks=4,
|
||||
block_size=BLOCK,
|
||||
num_layers=2,
|
||||
num_kv_heads=4,
|
||||
head_dim=64,
|
||||
dtype=torch.float32,
|
||||
device=torch.device("cpu"),
|
||||
)
|
||||
seen = set()
|
||||
for layer, (key_cache, value_cache) in enumerate(kv_pools):
|
||||
k_storage = key_cache.untyped_storage().data_ptr()
|
||||
v_storage = value_cache.untyped_storage().data_ptr()
|
||||
assert k_storage != v_storage, f"layer {layer}: K and V share one allocation"
|
||||
assert k_pools[layer].untyped_storage().data_ptr() == k_storage
|
||||
assert v_pools[layer].untyped_storage().data_ptr() == v_storage
|
||||
seen.update((k_storage, v_storage))
|
||||
# Every layer's K and V are distinct allocations as well.
|
||||
assert len(seen) == 2 * len(kv_pools)
|
||||
|
||||
# Negative control: writing V must not disturb K.
|
||||
k_pools[0].fill_(0)
|
||||
v_pools[0].fill_(5)
|
||||
assert torch.equal(k_pools[0], torch.zeros_like(k_pools[0]))
|
||||
|
||||
|
||||
def _pool_sized_allocations(code: str, pool_numel: int) -> list[int]:
|
||||
"""Sizes of generated allocations at least as large as one pool."""
|
||||
import re
|
||||
|
||||
sizes = []
|
||||
for shape in re.findall(r"empty_strided_\w+\(\(([\d, ]*?)\)", code):
|
||||
dims = [int(part) for part in shape.replace(" ", "").strip(",").split(",") if part]
|
||||
numel = 1
|
||||
for dim_size in dims:
|
||||
numel *= dim_size
|
||||
if dims and numel >= pool_numel:
|
||||
sizes.append(numel)
|
||||
return sizes
|
||||
|
||||
|
||||
def _generated_code_for_pools(key_cache, value_cache):
|
||||
"""Compile a paged-write-shaped op over these pools, return the generated code."""
|
||||
from torch._inductor import config as inductor_config
|
||||
from torch._inductor.utils import run_and_get_code
|
||||
|
||||
class _Holder(torch.nn.Module):
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
self.register_buffer("key_cache", key_cache)
|
||||
self.register_buffer("value_cache", value_cache)
|
||||
|
||||
def forward(self, value):
|
||||
return torch.ops.test_kv_pool_clone.write(self.key_cache, self.value_cache, value)
|
||||
|
||||
torch._dynamo.reset()
|
||||
# Inductor caches compiled code across ``torch._dynamo.reset()``, so the
|
||||
# second call in a process would otherwise return the first one's code and
|
||||
# both branches of this test would describe the same graph.
|
||||
with inductor_config.patch(force_disable_caches=True):
|
||||
_, codes = run_and_get_code(torch.compile(_Holder(), backend="inductor", fullgraph=True), torch.ones(1))
|
||||
return "\n".join(codes)
|
||||
|
||||
|
||||
def test_compiled_paged_write_does_not_clone_the_pool():
|
||||
"""The compiled graph must write the pools in place, not through a clone.
|
||||
|
||||
``test_key_and_value_caches_do_not_share_storage`` pins the mechanism this
|
||||
change introduces -- two allocations rather than one. This pins the effect
|
||||
that mechanism buys, which is the reason the change exists: with K and V as
|
||||
halves of one tensor, inductor's reinplace pass re-inplaces only the first,
|
||||
and ``auto_functionalized_v2``'s clone of the pool survives into the
|
||||
generated code as a pool-sized allocation plus a copy, once per compiled
|
||||
region per denoising step.
|
||||
|
||||
The shared layout is compiled here as a positive control. Without it, a
|
||||
codegen change that stops emitting ``empty_strided_*`` would leave the
|
||||
detector matching nothing and this test passing for the wrong reason.
|
||||
"""
|
||||
if "write" not in dir(getattr(torch.ops, "test_kv_pool_clone", object())):
|
||||
|
||||
@torch.library.custom_op("test_kv_pool_clone::write", mutates_args=("key_pool", "value_pool"))
|
||||
def _write(key_pool: torch.Tensor, value_pool: torch.Tensor, value: torch.Tensor) -> torch.Tensor:
|
||||
key_pool[0, 0, 0, 0] = value[0]
|
||||
value_pool[0, 0, 0, 0] = value[0]
|
||||
return value * 2
|
||||
|
||||
@_write.register_fake
|
||||
def _(key_pool, value_pool, value):
|
||||
return torch.empty_like(value)
|
||||
|
||||
# The stand-in models the real op's contract; that declaration is what
|
||||
# drives the reinplace pass, so a drift here would silently test nothing.
|
||||
real_schema = torch.ops.vllm_omni.ar_diffusion_paged_write_attn.default._schema
|
||||
real_mutated = [arg.name for arg in real_schema.arguments if arg.alias_info and arg.alias_info.is_write]
|
||||
assert real_mutated == ["key_pool", "value_pool"], (
|
||||
f"the real paged-write op now mutates {real_mutated}; this test still models two pools"
|
||||
)
|
||||
|
||||
num_blocks, heads, dim = 8, 4, 16
|
||||
cache_shape = (num_blocks, BLOCK, heads, dim)
|
||||
pool_numel = num_blocks * BLOCK * heads * dim
|
||||
|
||||
# Positive control: one allocation, K and V aliasing it.
|
||||
shared = torch.empty(2, *cache_shape)
|
||||
shared_allocations = _pool_sized_allocations(_generated_code_for_pools(shared[0], shared[1]), pool_numel)
|
||||
assert shared_allocations, (
|
||||
"the shared layout produced no pool-sized allocation, so this test can no "
|
||||
"longer tell the two layouts apart -- inductor's codegen or the detector changed"
|
||||
)
|
||||
|
||||
# The allocator under test.
|
||||
kv_pools, _, _ = allocate_kv_pool_with_views(
|
||||
num_blocks=num_blocks,
|
||||
block_size=BLOCK,
|
||||
num_layers=1,
|
||||
num_kv_heads=heads,
|
||||
head_dim=dim,
|
||||
dtype=torch.float32,
|
||||
device=torch.device("cpu"),
|
||||
)
|
||||
key_cache, value_cache = kv_pools[0]
|
||||
separate_allocations = _pool_sized_allocations(_generated_code_for_pools(key_cache, value_cache), pool_numel)
|
||||
assert not separate_allocations, (
|
||||
"the compiled graph allocates a pool-sized buffer, so the pool is being cloned "
|
||||
f"rather than written in place: {separate_allocations} (control saw {shared_allocations})"
|
||||
)
|
||||
assert torch.equal(kv_pools[0][0, 1, 3], k_pools[0][BLOCK + 3])
|
||||
assert torch.equal(kv_pools[0][1, 2, 5], v_pools[0][2 * BLOCK + 5])
|
||||
|
||||
|
||||
def test_build_manager_allocate_free_roundtrip():
|
||||
|
||||
@@ -1,193 +0,0 @@
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
"""CUDA-only regression test for the AR-Diffusion paged KV write op.
|
||||
|
||||
Split out of ``test_kv_cache.py``: that module is swept into CI's
|
||||
``core_model and cpu`` job via a module-level ``pytest.mark.cpu``, and
|
||||
``hardware_test(..., num_cards=1)`` adds no ``skipif`` guard for a missing
|
||||
GPU, so this test was being collected (and would fail to import a CUDA
|
||||
device) on CPU-only runners. Keeping it in its own, non-``cpu`` module means
|
||||
it is only ever collected by a job that explicitly selects ``cuda`` for this
|
||||
path -- none does yet, so for now this is intentionally not wired into any
|
||||
CI job.
|
||||
"""
|
||||
|
||||
import pytest
|
||||
import torch
|
||||
|
||||
from tests.helpers.mark import hardware_test
|
||||
from vllm_omni.experimental.ar_diffusion.kv_cache import allocate_kv_pool_with_views
|
||||
|
||||
BLOCK = 16
|
||||
|
||||
pytestmark = [pytest.mark.core_model, pytest.mark.diffusion]
|
||||
|
||||
|
||||
@hardware_test(res={"cuda": "L4"}, num_cards=1)
|
||||
def test_real_paged_write_op_does_not_clone_the_pool_on_cuda():
|
||||
"""Same assertion as the CPU test, against the real op's schema and CUDA codegen.
|
||||
|
||||
The CPU test compiles a stand-in with the same ``mutates_args`` contract,
|
||||
because the real op needs a device and an attention kernel. That leaves
|
||||
one thing unverified: whether Triton codegen reinplaces the same way,
|
||||
which is the path the reported regression was observed on.
|
||||
|
||||
This does not call the real op directly: ``ar_diffusion_paged_write_attn``
|
||||
runs FlashAttention's paged ``flash_attn_varlen_func`` internally, and
|
||||
compiling that under ``fullgraph=True`` can fail for reasons that have
|
||||
nothing to do with cloning (a missing kernel for this toy shape, a graph
|
||||
break, or an autotune illegal-memory-access on the control pool). Instead
|
||||
this registers a second stand-in that copies the real op's full argument
|
||||
list and ``mutates_args`` declaration -- so reinplace sees the identical
|
||||
contract the real op presents -- but skips straight to the pool writes,
|
||||
the same way the real op's own implementation does before it calls
|
||||
attention. That isolates "does Inductor clone this schema on CUDA" from
|
||||
"does FlashAttention compile", which is a separate, already-covered
|
||||
concern.
|
||||
|
||||
Note the pools passed here are the flat views, since that is what the op
|
||||
takes -- it indexes them by slot and unflattens internally.
|
||||
"""
|
||||
import re
|
||||
|
||||
from torch._inductor import config as inductor_config
|
||||
from torch._inductor.utils import run_and_get_code
|
||||
|
||||
device = torch.device("cuda")
|
||||
num_blocks, heads, dim, num_tokens = 8, 4, 64, 8
|
||||
pool_numel = num_blocks * BLOCK * heads * dim
|
||||
# The size a genuine clone would produce: K and V pool-sized allocations,
|
||||
# coalesced into one buffer the way `auto_functionalized_v2` was cloning
|
||||
# them before this PR's fix. Matching this exact size (rather than "any
|
||||
# allocation at least as large as one pool") avoids false positives from
|
||||
# unrelated workspace/scratch buffers Inductor may emit in that range.
|
||||
clone_numel = 2 * pool_numel
|
||||
|
||||
if "write" not in dir(getattr(torch.ops, "test_kv_pool_clone_schema", object())):
|
||||
|
||||
@torch.library.custom_op("test_kv_pool_clone_schema::write", mutates_args=("key_pool", "value_pool"))
|
||||
def _write(
|
||||
query: torch.Tensor,
|
||||
k_curr: torch.Tensor,
|
||||
v_curr: torch.Tensor,
|
||||
k_act: torch.Tensor | None,
|
||||
v_act: torch.Tensor | None,
|
||||
key_pool: torch.Tensor,
|
||||
value_pool: torch.Tensor,
|
||||
block_size: int,
|
||||
video_slots: torch.Tensor,
|
||||
action_slots: torch.Tensor,
|
||||
block_table: torch.Tensor,
|
||||
query_start_loc: torch.Tensor,
|
||||
seq_lens: torch.Tensor,
|
||||
max_query_len: int,
|
||||
max_seq_len: int,
|
||||
softmax_scale: float,
|
||||
) -> torch.Tensor:
|
||||
# Same pool-write side effect as `_paged_write_attn_impl`, minus
|
||||
# the `ar_diffusion_paged_attention` call -- that is the part
|
||||
# this test is not trying to exercise.
|
||||
key_pool[video_slots] = k_curr.to(key_pool.dtype)
|
||||
value_pool[video_slots] = v_curr.to(value_pool.dtype)
|
||||
if k_act is not None and v_act is not None and k_act.shape[0] > 0:
|
||||
key_pool[action_slots] = k_act.to(key_pool.dtype)
|
||||
value_pool[action_slots] = v_act.to(value_pool.dtype)
|
||||
return query * 2
|
||||
|
||||
@_write.register_fake
|
||||
def _(
|
||||
query,
|
||||
k_curr,
|
||||
v_curr,
|
||||
k_act,
|
||||
v_act,
|
||||
key_pool,
|
||||
value_pool,
|
||||
block_size,
|
||||
video_slots,
|
||||
action_slots,
|
||||
block_table,
|
||||
query_start_loc,
|
||||
seq_lens,
|
||||
max_query_len,
|
||||
max_seq_len,
|
||||
softmax_scale,
|
||||
):
|
||||
return torch.empty_like(query)
|
||||
|
||||
class _Holder(torch.nn.Module):
|
||||
def __init__(self, key_flat, value_flat):
|
||||
super().__init__()
|
||||
self.register_buffer("key_flat", key_flat)
|
||||
self.register_buffer("value_flat", value_flat)
|
||||
|
||||
def forward(self, query, k_curr, v_curr, video_slots, action_slots, block_table, query_start_loc, seq_lens):
|
||||
return torch.ops.test_kv_pool_clone_schema.write(
|
||||
query,
|
||||
k_curr,
|
||||
v_curr,
|
||||
None,
|
||||
None,
|
||||
self.key_flat,
|
||||
self.value_flat,
|
||||
BLOCK,
|
||||
video_slots,
|
||||
action_slots,
|
||||
block_table,
|
||||
query_start_loc,
|
||||
seq_lens,
|
||||
num_tokens,
|
||||
num_tokens,
|
||||
dim**-0.5,
|
||||
)
|
||||
|
||||
def compiled_pool_allocations(key_flat, value_flat) -> list[int]:
|
||||
args = (
|
||||
torch.randn(num_tokens, heads, dim, dtype=torch.bfloat16, device=device),
|
||||
torch.randn(num_tokens, heads, dim, dtype=torch.bfloat16, device=device),
|
||||
torch.randn(num_tokens, heads, dim, dtype=torch.bfloat16, device=device),
|
||||
torch.arange(num_tokens, device=device),
|
||||
torch.empty(0, dtype=torch.long, device=device),
|
||||
torch.arange(num_blocks, device=device, dtype=torch.int32).unsqueeze(0),
|
||||
torch.tensor([0, num_tokens], device=device, dtype=torch.int32),
|
||||
torch.tensor([num_tokens], device=device, dtype=torch.int32),
|
||||
)
|
||||
torch._dynamo.reset()
|
||||
# See the CPU test: inductor's cache outlives torch._dynamo.reset().
|
||||
with inductor_config.patch(force_disable_caches=True):
|
||||
_, codes = run_and_get_code(
|
||||
torch.compile(_Holder(key_flat, value_flat), backend="inductor", fullgraph=True), *args
|
||||
)
|
||||
sizes = []
|
||||
for shape in re.findall(r"empty_strided_cuda\(\(([\d, ]*?)\)", "\n".join(codes)):
|
||||
dims = [int(part) for part in shape.replace(" ", "").strip(",").split(",") if part]
|
||||
numel = 1
|
||||
for dim_size in dims:
|
||||
numel *= dim_size
|
||||
if dims and numel >= pool_numel:
|
||||
sizes.append(numel)
|
||||
return sizes
|
||||
|
||||
# Positive control: one allocation, K and V as its two halves. This must
|
||||
# produce an allocation of exactly `clone_numel` -- that is the clone
|
||||
# signature the assertion below checks for, not "no allocation this big".
|
||||
shared = torch.empty(2, num_blocks * BLOCK, heads, dim, dtype=torch.bfloat16, device=device)
|
||||
control = compiled_pool_allocations(shared[0], shared[1])
|
||||
assert clone_numel in control, (
|
||||
f"the shared layout produced no {clone_numel}-element allocation ({control}), so this test can no "
|
||||
"longer tell the two layouts apart -- inductor's codegen or the detector changed"
|
||||
)
|
||||
|
||||
_, k_pools, v_pools = allocate_kv_pool_with_views(
|
||||
num_blocks=num_blocks,
|
||||
block_size=BLOCK,
|
||||
num_layers=1,
|
||||
num_kv_heads=heads,
|
||||
head_dim=dim,
|
||||
dtype=torch.bfloat16,
|
||||
device=device,
|
||||
)
|
||||
separate = compiled_pool_allocations(k_pools[0], v_pools[0])
|
||||
assert clone_numel not in separate, (
|
||||
f"the compiled graph allocates a {clone_numel}-element buffer, so the pool is being cloned "
|
||||
f"rather than written in place: {separate} (control saw {control})"
|
||||
)
|
||||
@@ -13,12 +13,6 @@ from vllm_omni.diffusion.attention.backends.sdpa import SDPAImpl
|
||||
from vllm_omni.platforms import current_omni_platform
|
||||
|
||||
|
||||
def _clear_hub_module_cache(monkeypatch: pytest.MonkeyPatch) -> None:
|
||||
from vllm_omni.diffusion.attention.backends import flash_attn_hub
|
||||
|
||||
monkeypatch.setattr(flash_attn_hub, "_hub_modules", {})
|
||||
|
||||
|
||||
@pytest.mark.core_model
|
||||
@pytest.mark.cpu
|
||||
def test_explicit_kernels_hub_selection_does_not_fallback(monkeypatch: pytest.MonkeyPatch):
|
||||
@@ -60,74 +54,6 @@ def test_explicit_kernels_hub_selection_does_not_fallback(monkeypatch: pytest.Mo
|
||||
CudaOmniPlatform.get_diffusion_attn_backend_cls("FLASH_ATTN_3_HUB", head_size=64)
|
||||
|
||||
|
||||
@pytest.mark.core_model
|
||||
@pytest.mark.cpu
|
||||
def test_explicit_kernels_hub_variant_miss_does_not_fallback(monkeypatch: pytest.MonkeyPatch):
|
||||
"""Explicit Hub backends must fail loudly when no build variant resolves (#6971)."""
|
||||
from vllm.platforms.interface import DeviceCapability
|
||||
|
||||
from vllm_omni.diffusion.envs import PACKAGES_CHECKER
|
||||
from vllm_omni.platforms.cuda.platform import CudaOmniPlatform
|
||||
|
||||
monkeypatch.setattr(
|
||||
CudaOmniPlatform,
|
||||
"get_device_capability",
|
||||
classmethod(lambda cls, device_id=0: DeviceCapability(9, 0)),
|
||||
)
|
||||
monkeypatch.setattr(PACKAGES_CHECKER, "get_packages_info", lambda: {"has_flash_attn": True})
|
||||
_clear_hub_module_cache(monkeypatch)
|
||||
|
||||
kernels_module = types.ModuleType("kernels")
|
||||
|
||||
def _missing_variant(repo_id, version=None, **kwargs):
|
||||
raise FileNotFoundError(f"Cannot find a build variant for this system in {repo_id}")
|
||||
|
||||
kernels_module.get_kernel = _missing_variant # type: ignore[attr-defined]
|
||||
monkeypatch.setitem(sys.modules, "kernels", kernels_module)
|
||||
|
||||
with pytest.raises(RuntimeError, match="no compatible build"):
|
||||
CudaOmniPlatform.get_diffusion_attn_backend_cls("FLASH_ATTN_3_HUB", head_size=64)
|
||||
with pytest.raises(RuntimeError, match="no compatible build"):
|
||||
CudaOmniPlatform.get_diffusion_attn_backend_cls("FLASH_ATTN_HUB", head_size=64)
|
||||
|
||||
|
||||
@pytest.mark.core_model
|
||||
@pytest.mark.cpu
|
||||
def test_explicit_kernels_hub_preflight_uses_v2_when_v1_misses(monkeypatch: pytest.MonkeyPatch):
|
||||
"""Preflight must share _load_hub_module's (1, 2) policy, not pin version=1."""
|
||||
from vllm.platforms.interface import DeviceCapability
|
||||
|
||||
from vllm_omni.diffusion.attention.backends.registry import DiffusionAttentionBackendEnum
|
||||
from vllm_omni.diffusion.envs import PACKAGES_CHECKER
|
||||
from vllm_omni.platforms.cuda.platform import CudaOmniPlatform
|
||||
|
||||
monkeypatch.setattr(
|
||||
CudaOmniPlatform,
|
||||
"get_device_capability",
|
||||
classmethod(lambda cls, device_id=0: DeviceCapability(9, 0)),
|
||||
)
|
||||
monkeypatch.setattr(PACKAGES_CHECKER, "get_packages_info", lambda: {"has_flash_attn": True})
|
||||
_clear_hub_module_cache(monkeypatch)
|
||||
|
||||
kernels_module = types.ModuleType("kernels")
|
||||
versions_tried: list[int | None] = []
|
||||
|
||||
def _v1_miss_v2_hit(repo_id, version=None, **kwargs):
|
||||
versions_tried.append(version)
|
||||
if version == 1:
|
||||
raise FileNotFoundError(f"Cannot find a build variant for this system in {repo_id}")
|
||||
return types.SimpleNamespace(name=f"{repo_id}@v{version}")
|
||||
|
||||
kernels_module.get_kernel = _v1_miss_v2_hit # type: ignore[attr-defined]
|
||||
monkeypatch.setitem(sys.modules, "kernels", kernels_module)
|
||||
|
||||
fa3_path = CudaOmniPlatform.get_diffusion_attn_backend_cls("FLASH_ATTN_3_HUB", head_size=64)
|
||||
assert fa3_path == DiffusionAttentionBackendEnum.FLASH_ATTN_3_HUB.get_path()
|
||||
fa2_path = CudaOmniPlatform.get_diffusion_attn_backend_cls("FLASH_ATTN_HUB", head_size=64)
|
||||
assert fa2_path == DiffusionAttentionBackendEnum.FLASH_ATTN_HUB.get_path()
|
||||
assert versions_tried == [1, 2, 1, 2]
|
||||
|
||||
|
||||
@pytest.mark.core_model
|
||||
@pytest.mark.cpu
|
||||
def test_explicit_flash_attention_unavailable_does_not_fallback(monkeypatch: pytest.MonkeyPatch):
|
||||
|
||||
@@ -27,202 +27,6 @@ from vllm_omni.platforms import current_omni_platform
|
||||
pytestmark = [pytest.mark.core_model, pytest.mark.diffusion, pytest.mark.cpu]
|
||||
|
||||
|
||||
@pytest.mark.core_model
|
||||
@pytest.mark.cpu
|
||||
def test_uaa_equal_rank_contract_skips_length_gather(
|
||||
monkeypatch: pytest.MonkeyPatch,
|
||||
) -> None:
|
||||
from vllm_omni.diffusion.attention.parallel import ulysses
|
||||
|
||||
class FakeGroup:
|
||||
ulysses_group = object()
|
||||
ulysses_world_size = 2
|
||||
ulysses_rank = 0
|
||||
ring_world_size = 1
|
||||
|
||||
observed = []
|
||||
|
||||
def fake_all_to_all(pg, tensor, **kwargs):
|
||||
observed.append((kwargs["seq_lens"], kwargs["padded_head_cnt"]))
|
||||
return tensor, tensor.shape[2]
|
||||
|
||||
monkeypatch.setattr(ulysses, "_ulysses_all_to_all_any_qkv", fake_all_to_all)
|
||||
monkeypatch.setattr(ulysses, "get_ulysses_mode", lambda **kwargs: "advanced_uaa")
|
||||
monkeypatch.setattr(
|
||||
ulysses,
|
||||
"_all_gather_int",
|
||||
lambda *args, **kwargs: pytest.fail("length gather must be skipped"),
|
||||
)
|
||||
strategy = ulysses.UlyssesParallelAttention(
|
||||
FakeGroup(),
|
||||
scatter_idx=2,
|
||||
gather_idx=1,
|
||||
use_sync=False,
|
||||
)
|
||||
|
||||
with set_forward_context():
|
||||
get_forward_context()._sp_equal_pad_stack.append(True)
|
||||
strategy.pre_attention(
|
||||
torch.zeros(1, 3, 28, 4),
|
||||
torch.zeros(1, 3, 7, 4),
|
||||
torch.zeros(1, 3, 7, 4),
|
||||
None,
|
||||
)
|
||||
|
||||
assert observed == [([3, 3], 32), ([3, 3], 8), ([3, 3], 8)]
|
||||
|
||||
|
||||
@pytest.mark.core_model
|
||||
@pytest.mark.cpu
|
||||
def test_uaa_hybrid_equal_rank_contract_skips_ulysses_gather_keeps_ring_check(
|
||||
monkeypatch: pytest.MonkeyPatch,
|
||||
) -> None:
|
||||
"""Contract + ring: the fast path skips only the Ulysses gather.
|
||||
|
||||
The ring equality check is a separate collective on ring_group and must
|
||||
still run, receiving s_global derived from the contract.
|
||||
"""
|
||||
from vllm_omni.diffusion.attention.parallel import ulysses
|
||||
|
||||
class FakeGroup:
|
||||
ulysses_group = object()
|
||||
ring_group = object()
|
||||
ulysses_world_size = 2
|
||||
ulysses_rank = 0
|
||||
ring_world_size = 2
|
||||
|
||||
sp_group = FakeGroup()
|
||||
observed = []
|
||||
ring_checks = []
|
||||
|
||||
def fake_all_to_all(pg, tensor, **kwargs):
|
||||
observed.append((kwargs["seq_lens"], kwargs["padded_head_cnt"]))
|
||||
return tensor, tensor.shape[2]
|
||||
|
||||
def fake_gather_int(pg, value, *, device):
|
||||
if pg is sp_group.ulysses_group:
|
||||
pytest.fail("Ulysses length gather must be skipped under the contract")
|
||||
assert pg is sp_group.ring_group
|
||||
ring_checks.append(int(value))
|
||||
return [int(value), int(value)]
|
||||
|
||||
monkeypatch.setattr(ulysses, "_ulysses_all_to_all_any_qkv", fake_all_to_all)
|
||||
monkeypatch.setattr(ulysses, "_all_gather_int", fake_gather_int)
|
||||
monkeypatch.setattr(ulysses, "get_ulysses_mode", lambda **kwargs: "advanced_uaa")
|
||||
strategy = ulysses.UlyssesParallelAttention(
|
||||
sp_group,
|
||||
scatter_idx=2,
|
||||
gather_idx=1,
|
||||
use_sync=False,
|
||||
)
|
||||
|
||||
with set_forward_context():
|
||||
get_forward_context()._sp_equal_pad_stack.append(True)
|
||||
strategy.pre_attention(
|
||||
torch.zeros(1, 3, 28, 4),
|
||||
torch.zeros(1, 3, 7, 4),
|
||||
torch.zeros(1, 3, 7, 4),
|
||||
None,
|
||||
)
|
||||
|
||||
# Ring check ran: s_global = ulysses_world_size * local = 2 * 3.
|
||||
assert ring_checks == [6]
|
||||
assert observed == [([3, 3], 32), ([3, 3], 8), ([3, 3], 8)]
|
||||
|
||||
|
||||
@pytest.mark.core_model
|
||||
@pytest.mark.cpu
|
||||
def test_uaa_without_contract_keeps_dynamic_length_gather(
|
||||
monkeypatch: pytest.MonkeyPatch,
|
||||
) -> None:
|
||||
"""No auto_pad boundary means shards may differ, so the gather must stay."""
|
||||
from vllm_omni.diffusion.attention.parallel import ulysses
|
||||
|
||||
class FakeGroup:
|
||||
ulysses_group = object()
|
||||
ulysses_world_size = 2
|
||||
ulysses_rank = 0
|
||||
ring_world_size = 1
|
||||
|
||||
observed = []
|
||||
monkeypatch.setattr(
|
||||
ulysses,
|
||||
"_all_gather_int",
|
||||
lambda *args, **kwargs: [3, 4],
|
||||
)
|
||||
monkeypatch.setattr(ulysses, "get_ulysses_mode", lambda **kwargs: "advanced_uaa")
|
||||
|
||||
def fake_all_to_all(pg, tensor, **kwargs):
|
||||
observed.append(kwargs["seq_lens"])
|
||||
return tensor, tensor.shape[2]
|
||||
|
||||
monkeypatch.setattr(ulysses, "_ulysses_all_to_all_any_qkv", fake_all_to_all)
|
||||
strategy = ulysses.UlyssesParallelAttention(
|
||||
FakeGroup(),
|
||||
scatter_idx=2,
|
||||
gather_idx=1,
|
||||
use_sync=False,
|
||||
)
|
||||
|
||||
with set_forward_context():
|
||||
strategy.pre_attention(
|
||||
torch.zeros(1, 3, 28, 4),
|
||||
torch.zeros(1, 3, 7, 4),
|
||||
torch.zeros(1, 3, 7, 4),
|
||||
None,
|
||||
)
|
||||
|
||||
assert observed == [[3, 4], [3, 4], [3, 4]]
|
||||
|
||||
|
||||
@pytest.mark.core_model
|
||||
@pytest.mark.cpu
|
||||
def test_uaa_mixed_boundaries_keep_the_dynamic_length_gather(
|
||||
monkeypatch: pytest.MonkeyPatch,
|
||||
) -> None:
|
||||
"""One manual boundary inside an auto_pad region voids the contract."""
|
||||
from vllm_omni.diffusion.attention.parallel import ulysses
|
||||
|
||||
class FakeGroup:
|
||||
ulysses_group = object()
|
||||
ulysses_world_size = 2
|
||||
ulysses_rank = 0
|
||||
ring_world_size = 1
|
||||
|
||||
monkeypatch.setattr(ulysses, "get_ulysses_mode", lambda **kwargs: "advanced_uaa")
|
||||
gathered = []
|
||||
|
||||
def fake_gather(*args, **kwargs):
|
||||
gathered.append(args)
|
||||
return [3, 4]
|
||||
|
||||
monkeypatch.setattr(ulysses, "_all_gather_int", fake_gather)
|
||||
monkeypatch.setattr(
|
||||
ulysses,
|
||||
"_ulysses_all_to_all_any_qkv",
|
||||
lambda pg, tensor, **kwargs: (tensor, tensor.shape[2]),
|
||||
)
|
||||
strategy = ulysses.UlyssesParallelAttention(
|
||||
FakeGroup(),
|
||||
scatter_idx=2,
|
||||
gather_idx=1,
|
||||
use_sync=False,
|
||||
)
|
||||
|
||||
with set_forward_context():
|
||||
ctx = get_forward_context()
|
||||
ctx._sp_equal_pad_stack.extend([True, False])
|
||||
assert not ctx.sp_rank_local_seq_lens_equal
|
||||
strategy.pre_attention(
|
||||
torch.zeros(1, 3, 28, 4),
|
||||
torch.zeros(1, 3, 7, 4),
|
||||
torch.zeros(1, 3, 7, 4),
|
||||
None,
|
||||
)
|
||||
|
||||
assert len(gathered) == 1
|
||||
|
||||
|
||||
@pytest.mark.core_model
|
||||
@pytest.mark.cpu
|
||||
def test_uaa_gqa_head_padding_preserves_the_query_to_kv_ratio(
|
||||
@@ -830,187 +634,6 @@ def test_ulysses_uaa_matches_baseline(
|
||||
pass
|
||||
|
||||
|
||||
def _run_contract_skip_case(
|
||||
local_rank: int,
|
||||
world_size: int,
|
||||
init_method: str,
|
||||
input_file: str,
|
||||
num_heads: int,
|
||||
head_size: int,
|
||||
num_kv_heads: int | None,
|
||||
) -> None:
|
||||
"""Per-rank worker: slow path vs contract fast path on real rank pairs.
|
||||
|
||||
Phase 1 leaves the equal-pad stack empty so the Ulysses length all-gather
|
||||
really runs (counted); phase 2 pushes the split hook's auto_pad marker and
|
||||
replaces _all_gather_int with a raising guard. With ring_degree=1 any call
|
||||
to it is the Ulysses length gather, so the guard proves the skip, and the
|
||||
per-rank output comparison proves the fast path is numerically equivalent
|
||||
to the slow path it replaces.
|
||||
"""
|
||||
from vllm_omni.diffusion.attention.parallel import ulysses as ulysses_mod
|
||||
|
||||
device = torch.device(f"{current_omni_platform.device_type}:{local_rank}")
|
||||
current_omni_platform.set_device(device)
|
||||
|
||||
os.environ["DIFFUSION_ATTENTION_BACKEND"] = "TORCH_SDPA"
|
||||
|
||||
init_distributed_environment(world_size=world_size, rank=local_rank, distributed_init_method=init_method)
|
||||
initialize_model_parallel(
|
||||
data_parallel_size=1,
|
||||
cfg_parallel_size=1,
|
||||
sequence_parallel_size=world_size,
|
||||
ulysses_degree=world_size,
|
||||
ring_degree=1,
|
||||
tensor_parallel_size=1,
|
||||
pipeline_parallel_size=1,
|
||||
)
|
||||
|
||||
parallel_config = DiffusionParallelConfig(
|
||||
pipeline_parallel_size=1,
|
||||
data_parallel_size=1,
|
||||
tensor_parallel_size=1,
|
||||
sequence_parallel_size=world_size,
|
||||
ulysses_degree=world_size,
|
||||
ring_degree=1,
|
||||
cfg_parallel_size=1,
|
||||
ulysses_mode="advanced_uaa",
|
||||
)
|
||||
od_config = OmniDiffusionConfig(model="test", dtype=torch.float32, parallel_config=parallel_config)
|
||||
|
||||
with set_forward_context(omni_diffusion_config=od_config), set_current_diffusion_config(od_config):
|
||||
attn = Attention(
|
||||
num_heads=num_heads,
|
||||
head_size=head_size,
|
||||
causal=False,
|
||||
softmax_scale=1.0 / (head_size**0.5),
|
||||
num_kv_heads=num_kv_heads,
|
||||
).to(device=device, dtype=torch.float32)
|
||||
|
||||
with np.load(input_file, allow_pickle=False) as payload:
|
||||
q_full = torch.from_numpy(payload["q"]).to(device=device)
|
||||
k_full = torch.from_numpy(payload["k"]).to(device=device)
|
||||
v_full = torch.from_numpy(payload["v"]).to(device=device)
|
||||
|
||||
def make_shards() -> tuple[torch.Tensor, torch.Tensor, torch.Tensor]:
|
||||
# Fresh contiguous shards for each phase; seq_len is divisible by
|
||||
# world_size, so every rank gets the same local length.
|
||||
return (
|
||||
torch.tensor_split(q_full, world_size, dim=1)[local_rank].contiguous(),
|
||||
torch.tensor_split(k_full, world_size, dim=1)[local_rank].contiguous(),
|
||||
torch.tensor_split(v_full, world_size, dim=1)[local_rank].contiguous(),
|
||||
)
|
||||
|
||||
# The Attention layer only enables SP communication when
|
||||
# ForwardContext.sp_active is True; in production the split hook sets
|
||||
# this (and pushes the auto_pad equal-length marker onto
|
||||
# _sp_equal_pad_stack). Here we drive it directly.
|
||||
ctx = get_forward_context()
|
||||
ctx._sp_shard_depth = 1
|
||||
|
||||
def make_sdp_ctx() -> object:
|
||||
# Fresh instance per phase: the @contextmanager instance releases
|
||||
# its state on first exit and cannot be re-entered.
|
||||
return torch.backends.cuda.sdp_kernel(enable_flash=False, enable_mem_efficient=False, enable_math=True)
|
||||
|
||||
# Phase 1: contract absent -> the length all-gather must really run.
|
||||
real_gather = ulysses_mod._all_gather_int
|
||||
gather_calls: list[object] = []
|
||||
|
||||
def counting_gather(pg: object, value: int, *, device: torch.device) -> list[int]:
|
||||
gather_calls.append(pg)
|
||||
return real_gather(pg, value, device=device)
|
||||
|
||||
ulysses_mod._all_gather_int = counting_gather
|
||||
try:
|
||||
q, k, v = make_shards()
|
||||
with make_sdp_ctx():
|
||||
out_slow = attn(q, k, v, attn_metadata=None).contiguous()
|
||||
finally:
|
||||
ulysses_mod._all_gather_int = real_gather
|
||||
assert len(gather_calls) >= 1, "slow path must call the Ulysses length all-gather"
|
||||
|
||||
# Phase 2: replicate the split hook's auto_pad marker so the fast
|
||||
# path fires; any _all_gather_int call in this phase is the Ulysses
|
||||
# length gather and must not happen.
|
||||
ctx._sp_equal_pad_stack.append(True)
|
||||
|
||||
def fail_on_gather(pg: object, value: int, *, device: torch.device) -> list[int]:
|
||||
raise AssertionError("the Ulysses length all-gather must be skipped under the equal-pad contract")
|
||||
|
||||
ulysses_mod._all_gather_int = fail_on_gather
|
||||
try:
|
||||
q, k, v = make_shards()
|
||||
with make_sdp_ctx():
|
||||
out_fast = attn(q, k, v, attn_metadata=None).contiguous()
|
||||
finally:
|
||||
ulysses_mod._all_gather_int = real_gather
|
||||
ctx._sp_equal_pad_stack.pop()
|
||||
|
||||
torch.testing.assert_close(out_fast, out_slow, atol=1e-5, rtol=1e-5)
|
||||
|
||||
destroy_distributed_env()
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"num_heads,num_kv_heads",
|
||||
[
|
||||
(3, None), # MHA: heads padded 3 -> 4 by ulysses_degree=2
|
||||
(28, 7), # GQA: derived-Q padding 28/7 -> 32/8, the main case for the skip
|
||||
],
|
||||
)
|
||||
def test_ulysses_uaa_contract_skips_length_gather_matches_slow_path(num_heads: int, num_kv_heads: int | None) -> None:
|
||||
"""Real 2-rank parity: contract fast path == slow path, gather skipped.
|
||||
|
||||
The CPU-only contract tests replace the all-to-all with a fake; this test
|
||||
runs the real strategy on two ranks. Each rank first computes the slow
|
||||
path (empty equal-pad stack, real length all-gather), then the fast path
|
||||
with the split hook's auto_pad marker pushed and _all_gather_int replaced
|
||||
by a raising guard -- which also proves the collective was truly skipped,
|
||||
not just silently replaced.
|
||||
"""
|
||||
sp_world_size = 2
|
||||
if current_omni_platform.get_device_count() < sp_world_size:
|
||||
pytest.skip(f"Test requires {sp_world_size} GPUs")
|
||||
|
||||
batch_size = 2
|
||||
head_size = 8
|
||||
seq_len = 6 # divisible by 2 so both ranks hold equal-length shards
|
||||
|
||||
init_method = get_distributed_init_method()
|
||||
|
||||
with tempfile.NamedTemporaryFile(delete=False, suffix=".npz") as f_in:
|
||||
input_file = f_in.name
|
||||
|
||||
try:
|
||||
torch.manual_seed(0)
|
||||
kv_heads = num_kv_heads if num_kv_heads is not None else num_heads
|
||||
np.savez(
|
||||
input_file,
|
||||
q=torch.randn(batch_size, seq_len, num_heads, head_size, dtype=torch.float32).numpy(),
|
||||
k=torch.randn(batch_size, seq_len, kv_heads, head_size, dtype=torch.float32).numpy(),
|
||||
v=torch.randn(batch_size, seq_len, kv_heads, head_size, dtype=torch.float32).numpy(),
|
||||
)
|
||||
|
||||
torch.multiprocessing.spawn(
|
||||
_run_contract_skip_case,
|
||||
args=(
|
||||
sp_world_size,
|
||||
init_method,
|
||||
input_file,
|
||||
num_heads,
|
||||
head_size,
|
||||
num_kv_heads,
|
||||
),
|
||||
nprocs=sp_world_size,
|
||||
)
|
||||
finally:
|
||||
try:
|
||||
os.remove(input_file)
|
||||
except OSError:
|
||||
pass
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"num_heads,num_kv_heads,joint_len",
|
||||
[
|
||||
|
||||
@@ -279,17 +279,17 @@ def _install_native_modules(monkeypatch: pytest.MonkeyPatch, events: list[tuple]
|
||||
group = SimpleNamespace(get_metadata_builder=lambda _index: SimpleNamespace(reorder_batch_threshold=None))
|
||||
return [[group], [group]], "cg-support", [4, 8]
|
||||
|
||||
# vLLM 0.29 dropped attn_groups and cache_dtype from init_kv_cache: the
|
||||
# layout now rides on the resolved CacheConfig.kv_cache_layout instead.
|
||||
def init_cache(
|
||||
runner_kv_caches,
|
||||
forward_context,
|
||||
kv_cache_config,
|
||||
attn_groups,
|
||||
device,
|
||||
cache_dtype,
|
||||
kernel_block_sizes,
|
||||
vllm_config,
|
||||
):
|
||||
events.append(("cache", kv_cache_config, kernel_block_sizes))
|
||||
events.append(("cache", kv_cache_config, attn_groups, kernel_block_sizes))
|
||||
runner_kv_caches.extend(["cache-0", "cache-1"])
|
||||
return {"layer-0": "tensor-0", "layer-1": "tensor-1"}
|
||||
|
||||
|
||||
@@ -299,10 +299,8 @@ def test_minus_one_max_model_len_is_auto_fitted_by_native_cache_sizing() -> None
|
||||
)
|
||||
|
||||
assert vllm_config.model_config.original_max_model_len == -1
|
||||
# Sixteen physical pages provide ``(16 - 1) * block_size`` tokens: vLLM 0.29
|
||||
# subtracts the null block that BlockPool permanently holds back before
|
||||
# sizing (check_enough_kv_cache_memory), so only 15 pages are usable. The
|
||||
# native backend chooses the block geometry, so keep this assertion backend
|
||||
# Sixteen physical pages provide ``16 * block_size`` tokens. The native
|
||||
# backend chooses the block geometry, so keep this assertion backend
|
||||
# independent instead of assuming the generic 16-token block size.
|
||||
expected_max_model_len = min(model_limit, spec.block_size * (16 - 1))
|
||||
expected_max_model_len = min(model_limit, spec.block_size * 16)
|
||||
assert vllm_config.model_config.max_model_len == expected_max_model_len
|
||||
@@ -1,147 +0,0 @@
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
# SPDX-FileCopyrightText: Copyright contributors to the vLLM-Omni project
|
||||
"""Physical KV cache layout selection and propagation for the Diffusion cache."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from types import SimpleNamespace
|
||||
|
||||
import pytest
|
||||
import torch
|
||||
from vllm.config import CacheConfig
|
||||
from vllm.v1.kv_cache_interface import FullAttentionSpec
|
||||
from vllm.v1.kv_cache_layout import KVCacheLayout
|
||||
|
||||
from vllm_omni.diffusion.diffusion_kv.layout import (
|
||||
DEFAULT_DIFFUSION_KV_CACHE_LAYOUT,
|
||||
adopt_kv_cache_layout,
|
||||
assert_backend_layout_supported,
|
||||
build_kv_cache_tensor,
|
||||
resolve_diffusion_kv_cache_layout,
|
||||
)
|
||||
|
||||
pytestmark = [pytest.mark.core_model, pytest.mark.cpu, pytest.mark.diffusion]
|
||||
|
||||
|
||||
def _config():
|
||||
return SimpleNamespace(cache_config=CacheConfig())
|
||||
|
||||
|
||||
class _DenseBackend:
|
||||
@classmethod
|
||||
def indexes_kv_by_block_stride(cls) -> bool:
|
||||
return False
|
||||
|
||||
|
||||
class _BlockStrideBackend:
|
||||
@classmethod
|
||||
def indexes_kv_by_block_stride(cls) -> bool:
|
||||
return True
|
||||
|
||||
|
||||
def test_default_layout_is_not_block_outermost() -> None:
|
||||
"""The default reproduces the pre-0.29 indexes_kv_by_block_stride=False."""
|
||||
vllm_config = _config()
|
||||
layout = resolve_diffusion_kv_cache_layout(vllm_config)
|
||||
|
||||
assert layout is DEFAULT_DIFFUSION_KV_CACHE_LAYOUT
|
||||
assert layout.is_block_outermost is False
|
||||
assert vllm_config.cache_config.get_resolved_kv_cache_layout() is layout
|
||||
|
||||
|
||||
def test_block_stride_backend_selects_block_outermost_layout() -> None:
|
||||
layout = resolve_diffusion_kv_cache_layout(_config(), indexes_kv_by_block_stride=True)
|
||||
|
||||
assert layout.is_block_outermost is True
|
||||
|
||||
|
||||
def test_resolution_is_idempotent() -> None:
|
||||
vllm_config = _config()
|
||||
|
||||
assert resolve_diffusion_kv_cache_layout(vllm_config) is resolve_diffusion_kv_cache_layout(vllm_config)
|
||||
|
||||
|
||||
def test_contradicting_requirement_raises_instead_of_misaddressing() -> None:
|
||||
vllm_config = _config()
|
||||
resolve_diffusion_kv_cache_layout(vllm_config)
|
||||
|
||||
with pytest.raises(ValueError, match="contradicts the attention"):
|
||||
resolve_diffusion_kv_cache_layout(vllm_config, indexes_kv_by_block_stride=True)
|
||||
|
||||
|
||||
def test_preset_layout_is_honoured() -> None:
|
||||
vllm_config = _config()
|
||||
vllm_config.cache_config.kv_cache_layout = KVCacheLayout.BLNHC.name
|
||||
|
||||
layout = resolve_diffusion_kv_cache_layout(vllm_config, indexes_kv_by_block_stride=True)
|
||||
|
||||
assert layout is KVCacheLayout.BLNHC
|
||||
|
||||
|
||||
def test_backend_assertion_is_quiet_until_the_layout_is_resolved() -> None:
|
||||
"""Workers collect specs before the control plane hands them the layout."""
|
||||
vllm_config = _config()
|
||||
|
||||
assert_backend_layout_supported(vllm_config, _BlockStrideBackend) # unresolved: nothing to check
|
||||
|
||||
resolve_diffusion_kv_cache_layout(vllm_config)
|
||||
assert_backend_layout_supported(vllm_config, _DenseBackend)
|
||||
assert_backend_layout_supported(vllm_config, None)
|
||||
with pytest.raises(ValueError, match="contradicts the attention"):
|
||||
assert_backend_layout_supported(vllm_config, _BlockStrideBackend)
|
||||
|
||||
|
||||
def test_worker_adopts_the_layout_carried_on_the_kv_cache_config() -> None:
|
||||
"""Diffusion workers receive only a KVCacheConfig, so the name rides on it."""
|
||||
worker = _config()
|
||||
shipped = SimpleNamespace(kv_cache_layout=KVCacheLayout.BLNHC.name)
|
||||
|
||||
assert adopt_kv_cache_layout(worker, shipped) is KVCacheLayout.BLNHC
|
||||
assert worker.cache_config.get_resolved_kv_cache_layout() is KVCacheLayout.BLNHC
|
||||
|
||||
|
||||
def test_worker_without_a_carried_layout_falls_back_to_the_same_default() -> None:
|
||||
worker = _config()
|
||||
|
||||
assert adopt_kv_cache_layout(worker, SimpleNamespace(kv_cache_layout=None)) is DEFAULT_DIFFUSION_KV_CACHE_LAYOUT
|
||||
|
||||
|
||||
def test_worker_disagreeing_with_the_control_plane_raises() -> None:
|
||||
worker = _config()
|
||||
resolve_diffusion_kv_cache_layout(worker)
|
||||
|
||||
with pytest.raises(ValueError, match="disagrees with the layout"):
|
||||
adopt_kv_cache_layout(worker, SimpleNamespace(kv_cache_layout=KVCacheLayout.BLNHC.name))
|
||||
|
||||
|
||||
def test_block_stride_requirement_propagates_control_plane_to_worker() -> None:
|
||||
"""A block-stride backend must reach the worker as a block-outermost layout.
|
||||
|
||||
Covers the whole seam: the control plane resolves with the requirement, the
|
||||
name rides on each rank-local KVCacheConfig, the worker adopts it, and the
|
||||
backend contract check then passes instead of raising.
|
||||
"""
|
||||
control_plane = _config()
|
||||
layout = resolve_diffusion_kv_cache_layout(control_plane, indexes_kv_by_block_stride=True)
|
||||
assert layout.is_block_outermost is True
|
||||
|
||||
shipped = SimpleNamespace(kv_cache_layout=layout.name)
|
||||
|
||||
worker = _config()
|
||||
assert adopt_kv_cache_layout(worker, shipped) is layout
|
||||
# The worker's own backend requirement now agrees with what it was handed.
|
||||
assert_backend_layout_supported(worker, _BlockStrideBackend)
|
||||
with pytest.raises(ValueError, match="contradicts the attention"):
|
||||
assert_backend_layout_supported(worker, _DenseBackend)
|
||||
|
||||
|
||||
def test_tensor_strides_come_from_the_upstream_derivation() -> None:
|
||||
spec = FullAttentionSpec(block_size=16, num_kv_heads=2, head_size=8, dtype=torch.bfloat16)
|
||||
|
||||
tensor = build_kv_cache_tensor(spec, 4, ["layer0", "layer1"])
|
||||
|
||||
assert tensor.layers == ["layer0", "layer1"]
|
||||
assert tensor.size == spec.page_size_bytes * 2 * 4
|
||||
# Layer-outermost: each layer owns a contiguous run of its own blocks.
|
||||
assert tensor.layer_stride == spec.page_size_bytes * 4
|
||||
assert tensor.block_stride == spec.page_size_bytes
|
||||
@@ -1,12 +1,11 @@
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
# SPDX-FileCopyrightText: Copyright contributors to the vLLM-Omni project
|
||||
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
|
||||
|
||||
import pytest
|
||||
import torch
|
||||
import vllm.v1.core.single_type_kv_cache_manager as native_kv_managers
|
||||
from vllm.v1.kv_cache_interface import FullAttentionSpec, KVCacheConfig, KVCacheGroupSpec
|
||||
from vllm.v1.kv_cache_interface import FullAttentionSpec, KVCacheConfig, KVCacheGroupSpec, KVCacheTensor
|
||||
|
||||
from tests.helpers.kv_layout import build_kv_cache_tensor
|
||||
from vllm_omni.diffusion.diffusion_kv.manager import DiffusionKVAdmissionError, DiffusionKVCacheManager
|
||||
from vllm_omni.diffusion.diffusion_kv.request import DiffusionKVContext, DiffusionKVRequest
|
||||
|
||||
@@ -25,7 +24,7 @@ def _config(num_blocks: int) -> KVCacheConfig:
|
||||
)
|
||||
return KVCacheConfig(
|
||||
num_blocks=num_blocks,
|
||||
kv_cache_tensors=[build_kv_cache_tensor(spec, num_blocks, ["layer0"])],
|
||||
kv_cache_tensors=[KVCacheTensor(size=spec.page_size_bytes * num_blocks, shared_by=["layer0"])],
|
||||
kv_cache_groups=[KVCacheGroupSpec(layer_names=["layer0"], kv_cache_spec=spec)],
|
||||
)
|
||||
|
||||
|
||||
@@ -15,7 +15,6 @@ import torch
|
||||
from torch import nn
|
||||
from vllm.v1.kv_cache_interface import FullAttentionSpec
|
||||
|
||||
from tests.helpers.kv_layout import layout_for_backend
|
||||
from vllm_omni.diffusion.attention.backends.flash_attn import FlashAttentionImpl
|
||||
from vllm_omni.diffusion.attention.layer import Attention
|
||||
from vllm_omni.diffusion.diffusion_kv import paged_attention_adapter as adapter_module
|
||||
@@ -1240,8 +1239,7 @@ def test_layer_adapter_accepts_platform_native_backend_and_uses_rank_local_heads
|
||||
assert native_layer.num_heads == 4
|
||||
assert native_layer.num_kv_heads == 2
|
||||
assert native_layer.spec.num_kv_heads == 2
|
||||
# 0.29: the flag no longer rides on the spec, it selects the layout.
|
||||
assert layout_for_backend(native_layer.attn_backend).is_block_outermost is True
|
||||
assert native_layer.spec.indexes_kv_by_block_stride is True
|
||||
assert native_layer._q_scale_float == 1.0
|
||||
assert native_layer._k_scale_float == 1.0
|
||||
assert native_layer._v_scale_float == 1.0
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
# SPDX-FileCopyrightText: Copyright contributors to the vLLM-Omni project
|
||||
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
@@ -10,14 +10,12 @@ import torch
|
||||
from torch import nn
|
||||
from torch.nn import functional as F
|
||||
from vllm.config import AttentionConfig, CacheConfig, VllmConfig, set_current_vllm_config
|
||||
from vllm.v1.kv_cache_interface import FullAttentionSpec, KVCacheConfig, KVCacheGroupSpec
|
||||
from vllm.v1.kv_cache_interface import FullAttentionSpec, KVCacheConfig, KVCacheGroupSpec, KVCacheTensor
|
||||
from vllm.v1.worker.gpu.attn_utils import init_attn_backend, init_kv_cache
|
||||
from vllm.v1.worker.gpu.block_table import BlockTables
|
||||
|
||||
from tests.helpers.kv_layout import build_kv_cache_tensor
|
||||
from vllm_omni.diffusion.attention.backends.abstract import AttentionMetadata
|
||||
from vllm_omni.diffusion.attention.backends.flash_attn import FlashAttentionImpl
|
||||
from vllm_omni.diffusion.diffusion_kv.layout import resolve_diffusion_kv_cache_layout
|
||||
from vllm_omni.diffusion.diffusion_kv.paged_attention_adapter import (
|
||||
DiffusionPagedAttentionAdapter,
|
||||
DiffusionPagedAttentionLayerAdapter,
|
||||
@@ -90,7 +88,12 @@ def test_adapter_executes_native_paged_attention_on_non_contiguous_blocks() -> N
|
||||
canonical_spec = native_layer.spec
|
||||
kv_cache_config = KVCacheConfig(
|
||||
num_blocks=4,
|
||||
kv_cache_tensors=[build_kv_cache_tensor(canonical_spec, 4, [_LAYER_NAME])],
|
||||
kv_cache_tensors=[
|
||||
KVCacheTensor(
|
||||
size=canonical_spec.page_size_bytes * 4,
|
||||
shared_by=[_LAYER_NAME],
|
||||
)
|
||||
],
|
||||
kv_cache_groups=[
|
||||
KVCacheGroupSpec(
|
||||
layer_names=[_LAYER_NAME],
|
||||
@@ -98,9 +101,6 @@ def test_adapter_executes_native_paged_attention_on_non_contiguous_blocks() -> N
|
||||
)
|
||||
],
|
||||
)
|
||||
# 0.29 reads the resolved physical layout when allocating; the diffusion
|
||||
# control plane pins it, so this standalone harness must too.
|
||||
resolve_diffusion_kv_cache_layout(vllm_config)
|
||||
with set_current_vllm_config(vllm_config):
|
||||
attn_groups, _, kernel_block_sizes = init_attn_backend(
|
||||
kv_cache_config,
|
||||
@@ -108,13 +108,13 @@ def test_adapter_executes_native_paged_attention_on_non_contiguous_blocks() -> N
|
||||
device,
|
||||
)
|
||||
runner_kv_caches: list[torch.Tensor | list[torch.Tensor]] = []
|
||||
# vLLM 0.29 dropped attn_groups and cache_dtype here: the layout now
|
||||
# comes from the resolved CacheConfig.kv_cache_layout inside the call.
|
||||
init_kv_cache(
|
||||
runner_kv_caches,
|
||||
vllm_config.compilation_config.static_forward_context,
|
||||
kv_cache_config,
|
||||
attn_groups,
|
||||
device,
|
||||
vllm_config.cache_config.cache_dtype,
|
||||
kernel_block_sizes,
|
||||
vllm_config,
|
||||
)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
# SPDX-FileCopyrightText: Copyright contributors to the vLLM-Omni project
|
||||
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
|
||||
|
||||
import pytest
|
||||
import torch
|
||||
@@ -10,10 +10,10 @@ from vllm.v1.kv_cache_interface import (
|
||||
FullAttentionSpec,
|
||||
KVCacheConfig,
|
||||
KVCacheGroupSpec,
|
||||
KVCacheTensor,
|
||||
)
|
||||
from vllm.v1.request import RequestStatus
|
||||
|
||||
from tests.helpers.kv_layout import build_kv_cache_tensor
|
||||
from vllm_omni.diffusion.diffusion_kv.request import DiffusionKVContext, DiffusionKVRequest
|
||||
|
||||
pytestmark = [pytest.mark.core_model, pytest.mark.cpu, pytest.mark.diffusion]
|
||||
@@ -119,7 +119,7 @@ def _manager(*, enable_caching: bool) -> KVCacheManager:
|
||||
group = KVCacheGroupSpec(layer_names=["layer0"], kv_cache_spec=spec)
|
||||
config = KVCacheConfig(
|
||||
num_blocks=8,
|
||||
kv_cache_tensors=[build_kv_cache_tensor(spec, 8, ["layer0"])],
|
||||
kv_cache_tensors=[KVCacheTensor(size=spec.page_size_bytes * 8, shared_by=["layer0"])],
|
||||
kv_cache_groups=[group],
|
||||
)
|
||||
return KVCacheManager(
|
||||
|
||||
Loaded 100 of 571 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user