From 79cc9e7678af91cfa123280b3b369d58a7f01b06 Mon Sep 17 00:00:00 2001 From: localai-org-maint-bot <306269227+localai-org-maint-bot@users.noreply.github.com> Date: Tue, 4 Aug 2026 16:06:58 +0000 Subject: [PATCH] fix(fish-speech): use CUDA toolkit ptxas Prefer an explicitly configured Triton assembler, otherwise use the executable ptxas from CUDA_HOME so torch.compile can target GPU architectures newer than Triton bundled tooling. Assisted-by: Codex:gpt-5 --- backend/python/fish-speech/run.sh | 5 ++++ docs/content/features/text-to-audio.md | 18 ++++++++++++ scripts/build/fish-speech-ptxas_test.sh | 39 +++++++++++++++++++++++++ 3 files changed, 62 insertions(+) create mode 100644 scripts/build/fish-speech-ptxas_test.sh diff --git a/backend/python/fish-speech/run.sh b/backend/python/fish-speech/run.sh index eae121f37b0b..87408e2f550c 100644 --- a/backend/python/fish-speech/run.sh +++ b/backend/python/fish-speech/run.sh @@ -6,4 +6,9 @@ else source $backend_dir/../common/libbackend.sh fi +cuda_home=${CUDA_HOME:-/usr/local/cuda} +if [ -z "${TRITON_PTXAS_PATH:-}" ] && [ -x "$cuda_home/bin/ptxas" ]; then + export TRITON_PTXAS_PATH="$cuda_home/bin/ptxas" +fi + startBackend $@ diff --git a/docs/content/features/text-to-audio.md b/docs/content/features/text-to-audio.md index a2485f3bfe00..879edaafef6d 100644 --- a/docs/content/features/text-to-audio.md +++ b/docs/content/features/text-to-audio.md @@ -192,6 +192,24 @@ You can use the env variable COQUI_LANGUAGE to set the language used by the coqu You can also use config files to configure tts models (see section below on how to use config files). +### Fish Speech + +Fish Speech models accept the `compile` backend option. Enabling it can improve +inference performance on CUDA hardware, but the first request after loading the +model includes the `torch.compile` warmup cost: + +```yaml +backend: fish-speech +options: + - compile:true +``` + +When compilation is enabled, the backend uses the CUDA toolkit's executable +`ptxas` from `$CUDA_HOME/bin` (defaulting to `/usr/local/cuda/bin`) instead of +the copy bundled with Triton. This allows newer GPU architectures supported by +the installed CUDA toolkit to compile kernels. Set `TRITON_PTXAS_PATH` on the +backend explicitly to select a different assembler. + ### Piper To install the `piper` audio models manually: diff --git a/scripts/build/fish-speech-ptxas_test.sh b/scripts/build/fish-speech-ptxas_test.sh new file mode 100644 index 000000000000..db4e74f2183d --- /dev/null +++ b/scripts/build/fish-speech-ptxas_test.sh @@ -0,0 +1,39 @@ +#!/bin/bash +set -euo pipefail + +WORK=$(mktemp -d) +trap 'rm -rf "$WORK"' EXIT + +REPO_ROOT=$(dirname "$(dirname "$(dirname "$(realpath "$0")")")") +BACKEND_DIR="$WORK/fish-speech" +mkdir -p "$BACKEND_DIR/common" "$WORK/cuda/bin" +cp "$REPO_ROOT/backend/python/fish-speech/run.sh" "$BACKEND_DIR/run.sh" + +cat > "$BACKEND_DIR/common/libbackend.sh" <<'LIBBACKEND' +startBackend() { + printf '%s\n' "${TRITON_PTXAS_PATH:-}" +} +LIBBACKEND + +fail() { + echo "FAIL: $*" + exit 1 +} + +touch "$WORK/cuda/bin/ptxas" +chmod +x "$WORK/cuda/bin/ptxas" + +got=$(CUDA_HOME="$WORK/cuda" bash "$BACKEND_DIR/run.sh") +[ "$got" = "$WORK/cuda/bin/ptxas" ] || \ + fail "expected toolkit ptxas, got '$got'" + +got=$(CUDA_HOME="$WORK/cuda" TRITON_PTXAS_PATH=/custom/ptxas \ + bash "$BACKEND_DIR/run.sh") +[ "$got" = "/custom/ptxas" ] || \ + fail "explicit TRITON_PTXAS_PATH was overwritten with '$got'" + +chmod -x "$WORK/cuda/bin/ptxas" +got=$(CUDA_HOME="$WORK/cuda" bash "$BACKEND_DIR/run.sh") +[ -z "$got" ] || fail "non-executable ptxas was selected as '$got'" + +echo "PASS: fish-speech selects a usable toolkit ptxas"