tiny-voca-da / recipe /scripts /v4_host.sh
inlanger's picture
tiny-voca-da v0.1: frontend v4 + sm9 vocoder (ONNX fp32/int8, PyTorch, frontend, recipe, samples)
adabee1 verified
Raw History Blame Contribute Delete
3.23 kB
#!/usr/bin/env bash
# Frontend v4, host part. Waits for both G2P runs, scores them on the held-out NST words, packages
# the one with the lower word error rate into kit-v4/resources, rebuilds tiny-voca-dk:v4 (the build
# runs the Danish frontend tests), then starts:
# - GPU 0: scripts/v4_chain.sh (v4 annotations -> T4 -> pairs -> sm9 vocoder);
# - GPU 1: scripts/t3b_control.sh (T3 -> 220k on v3 labels, the equal-steps control);
# - scoring: v4tex1k220k-vocC132k, v4tex1k220k-vocCT4sm9 (KIT_SERVICE=kit-v4), tex1k220k-vocC132k.
# cd ~/stacks/tiny-voca-dk && setsid nohup bash scripts/v4_host.sh > /srv/tiny-voca-dk/checks/v4-host.log 2>&1 &
set -uo pipefail
D=/srv/tiny-voca-dk
cd ~/stacks/tiny-voca-dk
stamp() { echo "== $1 $(date -u +%FT%TZ)"; }
RUNS=(g2p-nst-v1 g2p-nst-v1-ar)
for r in "${RUNS[@]}"; do until grep -q "^exit=" "$D/checks/$r.log" 2>/dev/null; do sleep 60; done; done
stamp "g2p runs done: $(grep -h '^exit=' $D/checks/g2p-nst-v1*.log | tr '\n' ' ')"
G2P="docker compose --profile tools run --rm -T -e CUDA_VISIBLE_DEVICES= g2p"
if [[ -f "$D/work/g2p-package-v1/da_g2p_nst_v1.pt" ]] && cmp -s "$D/work/g2p-package-v1/da_g2p_nst_v1.pt" kit-v4/resources/da_g2p_nst_v1.pt; then
stamp "g2p package already made (rerun after the 2026-11-26 disk-full build failure)"
else
OK=()
for r in "${RUNS[@]}"; do
grep -q "^exit=0" "$D/checks/$r.log" || continue
$G2P python scripts/g2p_package.py --run "work/$r" --report "checks/$r-eval.json" 2>&1 | grep '"wer"' && OK+=("$r")
done
[[ ${#OK[@]} -gt 0 ]] || { echo "exit=1 no G2P run finished"; exit 1; }
BEST=$(cd $D/checks && python3 -c "import json, sys; r = {n: json.load(open(n + '-eval.json'))['wer'] for n in sys.argv[1:]}; print(min(r, key=r.get))" "${OK[@]}")
stamp "package $BEST"
rm -rf "$D/work/g2p-package-v1"
$G2P python scripts/g2p_package.py --run "work/$BEST" --report "checks/$BEST-eval.json" --package work/g2p-package-v1 2>&1 | grep packaged \
|| { echo "exit=1 package"; exit 1; }
cp "$D"/work/g2p-package-v1/* kit-v4/resources/
fi
FREE=$(df --output=avail -B1G "$D" | tail -1) # the v4 chain writes ~18 GB (features, cache, labels, pairs, runs)
[[ $FREE -ge 25 ]] || { echo "exit=1 only ${FREE} GB free on the models disk"; exit 1; }
stamp "build (${FREE} GB free)"
docker compose build kit-v4 > "$D/checks/v4-build.log" 2>&1 || { tail -n 30 "$D/checks/v4-build.log"; echo "exit=1 build"; exit 1; }
grep -E "Ran [0-9]+ tests|OK$" "$D/checks/v4-build.log" | tail -n 2
stamp start
docker compose run -d --name tiny-voca-dk-v4 -e GPU=0 kit-v4 bash -c "bash scripts/v4_chain.sh > checks/v4-chain.log 2>&1"
docker compose run -d --name tiny-voca-dk-t3b -e GPU=1 kit-v3 bash -c "bash scripts/t3b_control.sh > checks/t3b-control.log 2>&1"
KIT_SERVICE=kit-v4 setsid nohup bash "$D/work/eval_when.sh" v4tex1k220k-vocC132k models/v4trim-tex1k-s220000.pt models/vocoder-r7-C-s132000.pt > /dev/null 2>&1 &
KIT_SERVICE=kit-v4 setsid nohup bash "$D/work/eval_when.sh" v4tex1k220k-vocCT4sm9 models/v4trim-tex1k-s220000.pt models/vocoder-r21-CT4-sm9-s152000.pt > /dev/null 2>&1 &
setsid nohup bash "$D/work/eval_when.sh" tex1k220k-vocC132k models/v3trim-tex1k-s220000.pt models/vocoder-r7-C-s132000.pt > /dev/null 2>&1 &
echo "exit=0 $(date -u +%FT%TZ)"