fix: un-pin audio-separator to 0.47.1 with RoFormer overlap=2 (v0.278.16) (#1196)

@coderabbitai ignore

## Why
BACKLOG "audio-separator 0.45–0.47 regression: mel-band RoFormer karaoke
models 3–5× slower on L4". The root cause is **python-audio-separator
#299 (0.47.0)**, not #298. #299 made RoFormer `overlap` a *window count*
that defaults to each model YAML's `num_overlap`. Before that, `overlap`
was effectively an 8-second step, which meant almost no overlap. The
karaoke models' YAMLs set `num_overlap` 4/8, so a 3-minute track went
from 23 forward passes to 87 (aufr33) and 124 (gabox_v2, becruily). That
matches the measured 25→75s, 26→149s and 27→157s. 0.45.0 and 0.46.0
still had the old step formula.

python-audio-separator #313 (released as **0.47.1**) keeps #299. It adds
a per-model forward-pass budget test on every PR and a GPU per-pass
timing test (T4: 1.21 s/pass), plus a README note. Andrew chose
overlap=2 for gen: smoother chunk seams than 0.44's no-overlap, at about
1.5× the 0.44 compute instead of 4–6×.

## What
- `karaoke_gen/audio_processor.py`: `SEPARATOR_MDXC_PARAMS` (overlap=2)
goes to all four `Separator(...)` constructions (stage 1, stage 2
karaoke ensemble, single-model paths) **only when audio-separator ≥
0.47**. On older versions `overlap=2` meant a 2-second step, which is 4×
slower, so they keep their defaults. Ensembles load each model through
`load_model`, so the param reaches every model in the preset.
- `backend/Dockerfile.gpu-base`: `AUDIO_SEPARATOR_VERSION=0.47.1`, with
the comment rewritten to explain the root cause. 0.47.1 needs
`torch>=2.3` on Linux, so the pre-installed `torch==2.6.0+cu126`
(required by the L4 driver) is kept.
- The poetry lock stays on 0.44.1. The version-aware params keep CI and
CPU images on the old semantics, and there's no torch churn.

## Expected cost per ~3-min track (forward passes)
| model | 0.44.2 | 0.47 YAML default | 0.47 + overlap=2 |
|---|---|---|---|
| karaoke_aufr33 | 23 | 87 | 44 |
| karaoke_gabox_v2 | 23 | 124 | 32 |
| karaoke_becruily | 23 | 124 | 32 |
| instrumental fv7z / resurrection | 23 | 32 / 21 | 32 / 21 |

## Verification plan (before /backlog-finish)
After the deploy, time the separation of the daily E2E or a real job on
the audio-separation-job logs. I expect roughly 1.5× the 0.44.2
karaoke-stage times (~40–50s per karaoke model rather than 75–157s). If
it's worse, revert the pin to 0.44.2. That's one line.

## Testing
- `tests/unit/test_audio_processor_local_gpu.py`: version gating
(0.47.x/0.48/1.0 → overlap 2; 0.44/0.46 → defaults; unknown → defaults;
fresh copy), and both stages' constructors receive `mdxc_params.overlap
== 2`.
- `make test`: the backend unit suite passes. The only failures are 8
`test_emulator_integration.py` tests, caused by my local environment:
another session's emulator setup is on :8080/:4443, and they fail
identically on untouched main. CI is green on main.
- Local CodeRabbit: 0 findings.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

https://claude.ai/code/session_01Jw21syo4HizJJjYw2mg2Vp

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Andrew Beveridge ☄️andClaude Opus 5.5 authored and GitHub committed 2026-10-19 15:09:41 -04:00
1 parent 92fd647203
commit acb02e138a
4 files changed
+104 -7

No files matched your search

+6 -6
View File
@@ -104,12 +104,12 @@ RUN --mount=type=cache,target=/root/.cache/pip \
# Installing torch first means audio-separator[gpu] sees it as already satisfied.
#
# PINNED to an exact version: an unpinned install silently picked up 0.47.0 on the
# 2026-10-17 rebuild, and on L4 its mel-band RoFormer karaoke models run 3-5x slower
# than 0.44.2 (gabox_v2 ~26s -> 149s, becruily ~27s -> 157s for a ~3-min track;
# YAML overlap/batch are unchanged, so it is in the 0.45-0.47 inference changes).
# Total separation went from ~5 to ~10-16 min and the daily E2E started failing.
# Only bump this after timing a real job on the new version (see BACKLOG).
ARG AUDIO_SEPARATOR_VERSION=0.44.2
# 2026-10-17 rebuild and separation went from ~5 to ~10-16 min. Cause: 0.47 (#299) made
# RoFormer `overlap` a window count defaulting to each model YAML's num_overlap (4-8 for
# the karaoke models = 4-6x the forward passes of 0.44's fixed 8 s step). karaoke_gen's
# audio_processor now passes overlap=2 on >= 0.47 (SEPARATOR_MDXC_PARAMS). Time a real
# job before bumping this, and read the audio-separator release notes for compute changes.
ARG AUDIO_SEPARATOR_VERSION=0.47.1
RUN --mount=type=cache,target=/root/.cache/pip \
pip install torch==2.6.0+cu126 torchvision==0.21.0+cu126 --index-url https://download.pytorch.org/whl/cu126 && \
pip install "audio-separator[gpu]==${AUDIO_SEPARATOR_VERSION}"
+31
View File
@@ -22,6 +22,33 @@ from datetime import datetime
_UNSET = object()
# audio-separator >= 0.47 defaults RoFormer `overlap` to each model YAML's num_overlap,
# counted in windows. The karaoke models set 4-8, which is 4-6x the forward passes we ran
# on 0.44 (gabox_v2 ~26s -> 149s per track on an L4). Two windows keeps chunk seams smooth
# at ~1.5x the 0.44 cost; the instrumental models' YAMLs already use 2.
# Before 0.47 `overlap` meant a step in seconds (2 = 4x slower), so only pass it on >= 0.47.
SEPARATOR_MDXC_PARAMS = {
"segment_size": 256,
"override_model_segment_size": False,
"batch_size": None,
"overlap": 2,
"pitch_shift": 0,
}
WINDOW_OVERLAP_MIN_VERSION = (0, 47)
def _separator_kwargs():
"""Extra Separator kwargs for the installed audio-separator version."""
try:
from importlib.metadata import version
installed = tuple(int(part) for part in version("audio-separator").split(".")[:2])
except Exception:
return {}
if installed < WINDOW_OVERLAP_MIN_VERSION:
return {}
return {"mdxc_params": dict(SEPARATOR_MDXC_PARAMS)}
def _import_remote_client_cls():
try:
@@ -183,6 +210,7 @@ class AudioProcessor:
log_formatter=self.log_formatter,
model_file_dir=self.model_file_dir,
output_format=self.lossless_output_format,
**_separator_kwargs(),
)
separator.load_model(model_filename=model_name)
@@ -357,6 +385,7 @@ class AudioProcessor:
log_formatter=self.log_formatter,
model_file_dir=self.model_file_dir,
output_format=self.lossless_output_format,
**_separator_kwargs(),
output_dir=stems_dir,
ensemble_preset=instrumental_preset,
)
@@ -395,6 +424,7 @@ class AudioProcessor:
log_formatter=self.log_formatter,
model_file_dir=self.model_file_dir,
output_format=self.lossless_output_format,
**_separator_kwargs(),
)
result["clean_instrumental"] = self._separate_clean_instrumental(
separator, audio_file, artist_title, track_output_dir, stems_dir
@@ -425,6 +455,7 @@ class AudioProcessor:
log_formatter=self.log_formatter,
model_file_dir=self.model_file_dir,
output_format=self.lossless_output_format,
**_separator_kwargs(),
output_dir=stems_dir,
ensemble_preset=karaoke_preset,
)
+1 -1
View File
@@ -1,6 +1,6 @@
[tool.poetry]
name = "karaoke-gen"
version = "0.278.15"
version = "0.278.16"
description = "Generate karaoke videos with synchronized lyrics. Handles the entire process from downloading audio and lyrics to creating the final video with title screens."
authors = ["Andrew Beveridge <andrew@beveridge.uk>"]
license = "MIT"
@@ -267,6 +267,40 @@ class TestLocalSeparationWithPresets:
stage2_kwargs = mock_separator_cls.call_args_list[1][1]
assert stage2_kwargs.get("ensemble_preset") == "karaoke"
@patch.dict(os.environ, {}, clear=False)
@patch("importlib.metadata.version", return_value="0.47.1")
@patch("karaoke_gen.audio_processor.shutil")
@patch("karaoke_gen.audio_processor.Separator")
def test_both_stages_pass_overlap_two_on_window_overlap_separator(self, mock_separator_cls, mock_shutil, _mock_version):
"""Stage 1 and the karaoke ensemble (num_overlap 4-8 in YAML) both run with overlap=2."""
os.environ.pop("AUDIO_SEPARATOR_API_URL", None)
stems_dir = "/tmp/stems"
mock_sep1 = MagicMock()
mock_sep1.separate.return_value = [
f"{stems_dir}/Song_(Vocals)_preset_instrumental_clean.flac",
f"{stems_dir}/Song_(Instrumental)_preset_instrumental_clean.flac",
]
mock_sep2 = MagicMock()
mock_sep2.separate.return_value = [
f"{stems_dir}/Artist - Title (Vocals)_(Vocals)_preset_karaoke.flac",
f"{stems_dir}/Artist - Title (Vocals)_(No Vocal)_preset_karaoke.flac",
]
mock_separator_cls.side_effect = [mock_sep1, mock_sep2]
mock_shutil.move.side_effect = lambda src, dst: dst
mock_shutil.copy2 = MagicMock()
with patch.object(self.processor, '_create_stems_directory', return_value=stems_dir):
with patch.object(self.processor, '_normalize_audio_files'):
with patch.object(self.processor, '_generate_combined_instrumentals', return_value={}):
self.processor.process_audio_separation(
"/tmp/test.wav", "Artist - Title", "/tmp/output"
)
assert mock_separator_cls.call_count == 2
for call in mock_separator_cls.call_args_list:
assert call[1]["mdxc_params"]["overlap"] == 2
class TestEnsembleStemTagParsing:
"""Tests for stem tag extraction from ensemble preset output filenames.
@@ -465,3 +499,35 @@ class TestEnsembleStemTagParsing:
# Should not have classified anything
assert result["clean_instrumental"].get("vocals") is None
assert result["clean_instrumental"].get("instrumental") is None
class TestSeparatorOverlapParams:
"""audio-separator >= 0.47 counts RoFormer overlap in windows; gen pins 2 to keep karaoke models fast."""
def _kwargs_for_version(self, installed):
from karaoke_gen import audio_processor
with patch("importlib.metadata.version", return_value=installed):
return audio_processor._separator_kwargs()
def test_window_overlap_versions_get_overlap_two(self):
for installed in ("0.47.0", "0.47.1", "0.48.2", "1.0.0"):
kwargs = self._kwargs_for_version(installed)
assert kwargs["mdxc_params"]["overlap"] == 2, installed
assert kwargs["mdxc_params"]["batch_size"] is None
def test_seconds_overlap_versions_keep_library_defaults(self):
# Before 0.47 overlap=2 meant a 2 s step: 4x the passes of the 8 s default.
for installed in ("0.44.1", "0.44.2", "0.46.0"):
assert self._kwargs_for_version(installed) == {}, installed
def test_unknown_version_keeps_library_defaults(self):
from karaoke_gen import audio_processor
with patch("importlib.metadata.version", side_effect=Exception("not installed")):
assert audio_processor._separator_kwargs() == {}
def test_returns_a_fresh_copy(self):
kwargs = self._kwargs_for_version("0.47.1")
kwargs["mdxc_params"]["overlap"] = 8
assert self._kwargs_for_version("0.47.1")["mdxc_params"]["overlap"] == 2