Skip to content

Commit f2906a4

Browse files
committed
fix: fix E2E CI
1 parent 180828e commit f2906a4

4 files changed

Lines changed: 77 additions & 6 deletions

File tree

‎.github/workflows/ci.yml‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ env:
1212
jobs:
1313
# C++ Build Test
1414
build-cpp:
15-
runs-on: ubuntu-22.04
15+
runs-on: ubuntu-24.04
1616

1717
steps:
1818
- uses: actions/checkout@v4
@@ -37,7 +37,7 @@ jobs:
3737
3838
# Python Converter Tests
3939
test-converters:
40-
runs-on: ubuntu-22.04
40+
runs-on: ubuntu-24.04
4141

4242
steps:
4343
- uses: actions/checkout@v4
@@ -82,7 +82,7 @@ jobs:
8282
8383
# Code Quality Checks
8484
lint-python:
85-
runs-on: ubuntu-22.04
85+
runs-on: ubuntu-24.04
8686

8787
steps:
8888
- uses: actions/checkout@v4
@@ -110,7 +110,7 @@ jobs:
110110

111111
# Gitignore Verification
112112
check-gitignore:
113-
runs-on: ubuntu-22.04
113+
runs-on: ubuntu-24.04
114114

115115
steps:
116116
- uses: actions/checkout@v4

‎.github/workflows/e2e.yml‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,20 @@ env:
2424

2525
jobs:
2626
e2e-test:
27-
runs-on: ubuntu-22.04
27+
runs-on: ubuntu-24.04
2828

2929
steps:
3030
- uses: actions/checkout@v4
3131
with:
3232
submodules: recursive
3333

34+
- name: Set up swap
35+
run: |
36+
sudo fallocate -l 4G /swapfile
37+
sudo chmod 600 /swapfile
38+
sudo mkswap /swapfile
39+
sudo swapon /swapfile
40+
3441
- name: Cache models
3542
uses: actions/cache@v4
3643
with:

‎scripts/converters/wavtokenizer.py‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,25 @@ def model_type(self) -> str:
315315
def architecture(self) -> str:
316316
return "wavtokenizer_large"
317317

318+
def should_quantize_tensor(self, name: str, arr: np.ndarray) -> bool:
319+
if self.quantization not in ("Q4_K_M", "Q5_K_M", "Q8_0"):
320+
return False
321+
322+
if arr.ndim < 2:
323+
return False
324+
325+
# WavTokenizer keeps ".weight" (and may compress ".weight_v" -> ".wv")
326+
is_weight = name.endswith(".weight") or name.endswith(".w") or name.endswith(".wv")
327+
if not is_weight:
328+
return False
329+
330+
ne0 = int(arr.shape[0])
331+
if self.quantization in ("Q4_K_M", "Q5_K_M"):
332+
return (ne0 % 256) == 0
333+
if self.quantization == "Q8_0":
334+
return (ne0 % 32) == 0
335+
return False
336+
318337
def load_from_checkpoint(self, checkpoint_dir: Path) -> None:
319338
checkpoint_path = Path(checkpoint_dir)
320339

‎tests/e2e/runner.py‎

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,11 @@
44
from __future__ import annotations
55

66
import argparse
7+
import gc
78
import importlib
89
import json
910
import math
11+
import multiprocessing
1012
import shutil
1113
import subprocess
1214
import sys
@@ -670,6 +672,9 @@ def run_model(report_dir: Path, model_cfg: dict[str, Any], input_audio: Path, sa
670672
ffmpeg_to_mono_wav(input_audio, input_wav, model_sample_rate, log_path, name)
671673
encode_decode_hf(model_cfg, input_wav, hf_codes, hf_ref_wav, model_sample_rate, log_path, model, encoder_fn, decoder_fn)
672674

675+
del model, encoder_fn, decoder_fn
676+
gc.collect()
677+
673678
n_q = int(model_cfg.get("n_q", 0))
674679
if model_cfg.get("decode_only"):
675680
run_decode(gguf_path, hf_codes, cpp_out_wav, n_q, log_path, name)
@@ -817,6 +822,46 @@ def parse_model_selection(raw_values: list[str] | None) -> list[str]:
817822
return selected
818823

819824

825+
def _run_model_worker(
826+
result_queue: multiprocessing.Queue,
827+
report_dir: Path,
828+
model_cfg: dict[str, Any],
829+
input_audio: Path,
830+
sample_rate: int,
831+
) -> None:
832+
result = run_model(report_dir, model_cfg, input_audio, sample_rate)
833+
result_queue.put(result)
834+
835+
836+
def _run_model_isolated(
837+
report_dir: Path,
838+
model_cfg: dict[str, Any],
839+
input_audio: Path,
840+
sample_rate: int,
841+
) -> ModelResult:
842+
"""Run a single model test in an isolated subprocess so all memory
843+
(PyTorch allocator pools, imported modules, HF caches) is reclaimed
844+
by the OS when the child exits."""
845+
q: multiprocessing.Queue = multiprocessing.Queue()
846+
p = multiprocessing.Process(
847+
target=_run_model_worker,
848+
args=(q, report_dir, model_cfg, input_audio, sample_rate),
849+
)
850+
p.start()
851+
p.join()
852+
if not q.empty():
853+
return q.get_nowait()
854+
name = model_cfg["name"]
855+
return ModelResult(
856+
name=name,
857+
status="failed",
858+
duration_sec=0.0,
859+
log_path=str(report_dir / f"{name}.log"),
860+
reason=f"worker process died (exit code {p.exitcode})",
861+
return_code=p.exitcode,
862+
)
863+
864+
820865
def main() -> int:
821866
args = parse_args()
822867
require_tools()
@@ -842,7 +887,7 @@ def main() -> int:
842887

843888
results: list[ModelResult] = []
844889
for model_cfg in selected_cfgs:
845-
result = run_model(report_dir, model_cfg, input_audio, int(args.sample_rate))
890+
result = _run_model_isolated(report_dir, model_cfg, input_audio, int(args.sample_rate))
846891
results.append(result)
847892
print(f"[{result.name}] result: {result.status}")
848893
if result.reason:

0 commit comments

Comments
 (0)