#!/usr/bin/env bash # Frontend v4, GPU part (AGENTS.md, "Frontend v4"). Runs in the kit-v4 image: # 1. annotations of the trimmed data with the v4 frontend (TAG v4trim; the wav2vec2 states of # the trimmed data are reused, as v3trim did; check-data skipped as for v3trim); # 2. T4 = T3 (runs/v3trim-tex1k-180k, step 180k) branched onto them with --init-from --new-data, # same texture recipe (20 from 1 kHz), 40k steps -> 220k; # 3. vocoder pairs from T4, then the sm9 recipe on them (init C 132k, fresh schedule, 20k steps). # Started by scripts/v4_host.sh: # docker compose run -d --name tiny-voca-dk-v4 kit-v4 bash -c "bash scripts/v4_chain.sh > checks/v4-chain.log 2>&1" set -uo pipefail cd /opt/kit export DATA=data/coral_da_trim TAG=v4trim FEAT=data/v4trim-features WORKERS="${WORKERS:-8}" THREADS=8 export CACHE_REUSE=work/trim-head-cache CACHE_REUSE_TEST=work/trim-head-test-cache GPU=${GPU:-0} ANN=data/v4trim-prepared/annotations OUT=runs/v4trim-tex1k-220k VOICE=models/v4trim-tex1k-s220000.pt PAIRS=data/vocoder-pairs-v4tex1k220k VOC=runs/vocoder-r21-CT4-sm9 stamp() { echo "== stage $1 $(date -u +%FT%TZ)"; } fail() { echo "exit=1 stage=$1 $(date -u +%FT%TZ)"; exit 1; } wait_gpu() { # device index, free bytes needed until CUDA_VISIBLE_DEVICES=$1 python -c "import sys, torch; sys.exit(0 if torch.cuda.mem_get_info(0)[0] > $2 else 1)" 2>/dev/null do sleep 30; done; } if [[ ! -f "$ANN/train.jsonl" ]]; then for s in features cache fit calibrate evaluate test export pack; do stamp "$s"; CUDA_VISIBLE_DEVICES=$GPU bash scripts/gpu_pipeline.sh "$s" || fail "$s" done fi if [[ ! -f "$VOICE" ]]; then START=(--init-from runs/v3trim-tex1k-180k/last.pt --new-data); [[ -f "$OUT/last.pt" ]] && START=(--resume "$OUT/last.pt") wait_gpu "$GPU" 13e9 stamp voice CUDA_VISIBLE_DEVICES=$GPU TEXTURE_LOW_HZ=1000 python scripts/train_texture_low.py \ --train "$ANN/train.jsonl" --validation "$ANN/validation.jsonl" \ --config work/config.v3trim-vml.json --output "$OUT" --device cuda --steps 220000 --batch-frames 9000 --max-batch 32 \ --gan-start 8000 --gan-ratio 0.7 --teacher-final 0 --save-every 1000 --keep-every 5000 --log-every 50 \ --max-seconds inf --stop-file "$OUT/STOP" --texture 20 "${START[@]}" >> "$OUT.log" 2>&1 || fail voice python tiny-voca/scripts/export_checkpoint.py --checkpoint "$OUT/last.pt" --output "$VOICE" > /dev/null || fail export fi if [[ ! -f "$PAIRS/train/pairs.jsonl" ]]; then stamp pairs CUDA_VISIBLE_DEVICES=$GPU python scripts/make_pairs.py --checkpoint "$VOICE" \ --annotations "$ANN/train.jsonl" --output "$PAIRS/train" --device cuda | tail -1 || fail pairs fi START=(--init-from runs/vocoder-r7-C/last.pt --fresh-schedule); [[ -f "$VOC/last.pt" ]] && START=(--resume) wait_gpu "$GPU" 8e9 stamp vocoder CUDA_VISIBLE_DEVICES=$GPU PAIR_SMOOTH=9 python scripts/train_vocoder_smooth.py "${START[@]}" \ --prior --prior-high-hz 2500 --prior-high-gain 0.05 --prior-gain-range 0.0 0.1 --mel-weight 5 \ --manifests data/full-features/train.jsonl --validation data/full-features/validation.jsonl --output "$VOC" \ --steps 152000 --learning-rate 5e-5 --warmup 500 --batch 32 --teacher vocos --distill-mode spectrum --distill-weight 4 \ --pairs "$PAIRS/train/pairs.jsonl" --pair-fraction 0.7 \ --device cuda --workers 6 --save-every 1000 --keep-every 4000 >> "$VOC.log" 2>&1 || fail vocoder cp --update=none "$VOC/vocoder.pt" models/vocoder-r21-CT4-sm9-s152000.pt echo "exit=0 $(date -u +%FT%TZ)"