notforu777's picture
TTS -> ASR round trip: results, per-clip rows, MP3 clips, tensor types, logs, scripts (part 6)
ba8139c verified
Raw History Blame Contribute Delete
3.76 kB
#!/bin/bash
# ZONOS3-Mini phase 2 on the box: quantize the ladder from the BF16 backbone, record the real tensor types, then
# run the TTS -> ASR eval on every rung with the one F32 mmproj. Ends with "PHASE2 DONE" in /root/p2.log.
# No imatrix: llama-imatrix feeds text, and this backbone reads text + audio-code frames.
# Experts are ~94% of the backbone (64 x latent 256 -> 1536, layers 1-10): they carry the rung's type;
# everything else (token table, GDN/attention, layer-0 dense FFN, latent projections) stays q8_0.
set -uo pipefail
exec >> /root/p2.log 2>&1
OUT=/root/out; Q=/root/llama.cpp/build/bin/llama-quantize; P=/root/venv/bin/python
step() { echo "== $(date -u '+%F %T') $*"; }
cd $OUT
BF=ZONOS3-Mini-BF16.gguf
KEEP=(--token-embedding-type q8_0 --tensor-type "attn_=q8_0" --tensor-type "ssm_=q8_0"
--tensor-type "blk\.0\.ffn_=q8_0" --tensor-type "latent=q8_0")
quant() { # name ftype [rules...]
local name=$1 ft=$2; shift 2
[ -s "ZONOS3-Mini-$name.gguf" ] && return
step "quantize $name"
$Q "$@" $BF "ZONOS3-Mini-$name.gguf" $ft 30 > q_$name.log 2>&1 || { tail -20 q_$name.log; echo "QUANT FAILED $name"; }
}
quant Q8_0 Q8_0
quant AD-Q6_K Q6_K --tensor-type "_exps=q6_k" "${KEEP[@]}"
quant AD-Q5_K_M Q5_K_M --tensor-type "ffn_down_exps=q6_k" --tensor-type "_exps=q5_k" "${KEEP[@]}"
quant AD-Q4_K_M Q4_K_M --tensor-type "ffn_down_exps=q5_k" --tensor-type "_exps=q4_k" "${KEEP[@]}"
quant AD-Q3_K_M Q3_K_M --tensor-type "ffn_down_exps=q4_k" --tensor-type "_exps=q3_k" "${KEEP[@]}"
quant Q4_K_M Q4_K_M
ls -la $OUT/*.gguf
step "real tensor types"
for f in ZONOS3-Mini-*.gguf; do
echo "--- $f $(stat -c %s $f) bytes"
PYTHONPATH=/root/llama.cpp/gguf-py $P - "$f" <<'EOF'
import sys, re, collections
from gguf import GGUFReader
r = GGUFReader(sys.argv[1])
groups = collections.defaultdict(collections.Counter); nbytes = collections.Counter(); total = 0
for t in r.tensors:
g = re.sub(r"blk\.\d+\.", "blk.N.", t.name)
groups[g][t.tensor_type.name] += 1; nbytes[g] += int(t.n_bytes); total += int(t.n_bytes)
n = sum(int(t.n_elements) for t in r.tensors)
for g in sorted(groups, key=lambda g: -nbytes[g])[:14]:
print(f" {g:34s} {dict(groups[g])} {nbytes[g] / 1e6:8.1f} MB")
print(f" total {total / 1e9:.3f} GB {n / 1e6:.1f} M params {8 * total / n:.3f} bpw")
EOF
done > types.txt 2>&1
cat types.txt
step "eval"
R=(--rung BF16=$OUT/ZONOS3-Mini-BF16.gguf --rung Q8_0=$OUT/ZONOS3-Mini-Q8_0.gguf
--rung AD-Q6_K=$OUT/ZONOS3-Mini-AD-Q6_K.gguf --rung AD-Q5_K_M=$OUT/ZONOS3-Mini-AD-Q5_K_M.gguf
--rung AD-Q4_K_M=$OUT/ZONOS3-Mini-AD-Q4_K_M.gguf --rung AD-Q3_K_M=$OUT/ZONOS3-Mini-AD-Q3_K_M.gguf
--rung Q4_K_M=$OUT/ZONOS3-Mini-Q4_K_M.gguf)
$P /root/zonos3/eval_tts.py --out $OUT/eval --mmproj $OUT/mmproj-ZONOS3-Mini-F32.gguf "${R[@]}" --jobs ${JOBS:-4} --stage all \
|| echo "EVAL FAILED"
step "mmproj F16 vs F32 (BF16 backbone)"
[ -s mmproj-ZONOS3-Mini-F16.gguf ] || ( cd /root/llama.cpp && $P convert_hf_to_gguf.py /root/zonos3-src --mmproj --outtype f16 \
--outfile $OUT/mmproj-ZONOS3-Mini-F16.gguf > $OUT/convert_mm16.log 2>&1 ) || tail -20 $OUT/convert_mm16.log
ls -la $OUT/mmproj-*.gguf
$P /root/zonos3/eval_tts.py --out $OUT/eval_mm16 --mmproj $OUT/mmproj-ZONOS3-Mini-F16.gguf \
--rung BF16-mmF16=$OUT/ZONOS3-Mini-BF16.gguf --jobs ${JOBS:-4} --stage gen || echo "EVAL16 FAILED"
# score against the F32 run of the same backbone: copy its wavs in as the reference rung
mkdir -p $OUT/eval_mm16/wav && cp -rn $OUT/eval/wav/BF16 $OUT/eval_mm16/wav/
$P /root/zonos3/eval_tts.py --out $OUT/eval_mm16 --mmproj $OUT/mmproj-ZONOS3-Mini-F16.gguf \
--rung BF16=$OUT/ZONOS3-Mini-BF16.gguf --rung BF16-mmF16=$OUT/ZONOS3-Mini-BF16.gguf --stage asr || echo "ASR16 FAILED"
step "PHASE2 DONE"