Skip to content

Commit fbf57d0

Browse files
fix(fish-speech): preserve ROCm PyTorch
The upstream editable install pins generic PyTorch packages. It replaces the HIP wheels with CUDA wheels in ROCm images. Remove those pins only for hipBLAS builds before the editable install. Keep the existing CPU and CUDA dependency behavior unchanged. Assisted-by: Codex:gpt-5
1 parent c29c99e commit fbf57d0

5 files changed

Lines changed: 94 additions & 6 deletions

File tree

backend/python/fish-speech/Makefile

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
1-
.PHONY: fish-speech
2-
fish-speech:
1+
.PHONY: fish-speech test-source-preparation
2+
fish-speech: test-source-preparation
33
bash install.sh
44

5+
test-source-preparation:
6+
bash prepare-source_test.sh
7+
58
.PHONY: run
69
run: fish-speech
710
@echo "Running fish-speech..."

backend/python/fish-speech/install.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,10 @@ else
3939
cd "${FISH_SPEECH_DIR}" && git pull && cd -
4040
fi
4141

42-
# Remove pyaudio from fish-speech deps — it's only used by the upstream client tool
43-
# (tools/api_client.py) for speaker playback, not by our gRPC backend server.
44-
# It requires native portaudio libs which aren't available on all build environments.
45-
sed -i.bak '/"pyaudio"/d' "${FISH_SPEECH_DIR}/pyproject.toml"
42+
# Keep the platform-specific PyTorch installed above. Upstream pins the generic
43+
# PyPI torch wheel, which replaces ROCm builds with a CUDA wheel during the
44+
# editable install. pyaudio is only used by the upstream playback client.
45+
bash "${backend_dir}/prepare-source.sh" "${BUILD_TYPE:-}" "${FISH_SPEECH_DIR}/pyproject.toml"
4646

4747
# Install fish-speech deps from source (without the package itself since we use PYTHONPATH)
4848
ensureVenv
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/bin/bash
2+
set -euo pipefail
3+
4+
build_type=${1:-}
5+
pyproject=${2:?usage: prepare-source.sh BUILD_TYPE PYPROJECT}
6+
prepared=$(mktemp "${pyproject}.XXXXXX")
7+
trap 'rm -f "$prepared"' EXIT
8+
9+
awk -v build_type="$build_type" '
10+
/^dependencies = \[$/ { in_project_dependencies = 1 }
11+
build_type == "hipblas" && in_project_dependencies && /^[[:space:]]*"(torch|torchaudio)[^"]*",?[[:space:]]*$/ { next }
12+
in_project_dependencies && /^[[:space:]]*"pyaudio",?[[:space:]]*$/ { next }
13+
{ print }
14+
in_project_dependencies && /^\]$/ { in_project_dependencies = 0 }
15+
' "$pyproject" > "$prepared"
16+
17+
mv "$prepared" "$pyproject"
18+
trap - EXIT
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
#!/bin/bash
2+
set -euo pipefail
3+
4+
SCRIPT_DIR=$(dirname "$(realpath "$0")")
5+
WORK_DIR=$(mktemp -d)
6+
trap 'rm -rf "$WORK_DIR"' EXIT
7+
8+
write_fixture() {
9+
cat > "$1" <<'EOF'
10+
[project]
11+
dependencies = [
12+
"numpy",
13+
"torch==2.8.0",
14+
"torchaudio==2.8.0",
15+
"pyaudio",
16+
]
17+
18+
[project.optional-dependencies]
19+
stable = [
20+
"torch==2.8.0",
21+
"torchaudio",
22+
]
23+
EOF
24+
}
25+
26+
write_fixture "$WORK_DIR/rocm.toml"
27+
write_fixture "$WORK_DIR/cuda.toml"
28+
write_fixture "$WORK_DIR/cpu.toml"
29+
30+
bash "$SCRIPT_DIR/prepare-source.sh" hipblas "$WORK_DIR/rocm.toml"
31+
bash "$SCRIPT_DIR/prepare-source.sh" cublas "$WORK_DIR/cuda.toml"
32+
bash "$SCRIPT_DIR/prepare-source.sh" "" "$WORK_DIR/cpu.toml"
33+
34+
cat > "$WORK_DIR/expected-rocm.toml" <<'EOF'
35+
[project]
36+
dependencies = [
37+
"numpy",
38+
]
39+
40+
[project.optional-dependencies]
41+
stable = [
42+
"torch==2.8.0",
43+
"torchaudio",
44+
]
45+
EOF
46+
47+
cat > "$WORK_DIR/expected-default.toml" <<'EOF'
48+
[project]
49+
dependencies = [
50+
"numpy",
51+
"torch==2.8.0",
52+
"torchaudio==2.8.0",
53+
]
54+
55+
[project.optional-dependencies]
56+
stable = [
57+
"torch==2.8.0",
58+
"torchaudio",
59+
]
60+
EOF
61+
62+
diff -u "$WORK_DIR/expected-rocm.toml" "$WORK_DIR/rocm.toml"
63+
diff -u "$WORK_DIR/expected-default.toml" "$WORK_DIR/cuda.toml"
64+
diff -u "$WORK_DIR/expected-default.toml" "$WORK_DIR/cpu.toml"
65+
66+
echo "PASS: source preparation preserves each platform's PyTorch dependencies"

backend/python/fish-speech/test.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,5 @@ else
88
source $backend_dir/../common/libbackend.sh
99
fi
1010

11+
bash "${backend_dir}/prepare-source_test.sh"
1112
runUnittests

0 commit comments

Comments
 (0)