|
| 1 | +#!/usr/bin/env bash |
| 2 | +# Copyright 2026 VinRobotics - Apache-2.0 |
| 3 | +# |
| 4 | +# Bit-exactness and latency harness for the src/ layer/module/model refactor. |
| 5 | +# |
| 6 | +# eval/refactor_verify.sh <outdir> actions only |
| 7 | +# BENCH=20 eval/refactor_verify.sh <outdir> actions + predict() timing |
| 8 | +# |
| 9 | +# Each arch runs twice: at its shipping defaults, and under the alternate |
| 10 | +# precision. Both must stay byte-identical across a refactor, and neither may |
| 11 | +# regress in latency. |
| 12 | +# |
| 13 | +# eval/refactor_verify.sh outputs/refactor/before |
| 14 | +# ...change... |
| 15 | +# cmake --build build -j"$(nproc)" --target vla_predict_check |
| 16 | +# eval/refactor_verify.sh outputs/refactor/after |
| 17 | +# diff -r outputs/refactor/before outputs/refactor/after |
| 18 | +# |
| 19 | +# Never rebuild while a sweep is running: relinking libvla_core.so under it |
| 20 | +# makes every remaining arch fail to load. |
| 21 | +# |
| 22 | +# ARCHS=... restricts the sweep. The square input side is probed rather than |
| 23 | +# hardcoded, because a tower fed the wrong side returns action_len=0 instead of |
| 24 | +# failing, and a wrong side would silently "pass" a diff. |
| 25 | + |
| 26 | +set -euo pipefail |
| 27 | + |
| 28 | +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" |
| 29 | +REPO_ROOT="$(cd "${SCRIPT_DIR}/.." && pwd)" |
| 30 | + |
| 31 | +BIN="${BIN:-${REPO_ROOT}/build/tests/vla_predict_check}" |
| 32 | +HF="${HF:-/mnt/data/hf_data/vrfai}" |
| 33 | +OUT="${1:-${REPO_ROOT}/outputs/refactor/baseline}" |
| 34 | +SIDES="${SIDES:-224 256 448 512}" |
| 35 | +BENCH="${BENCH:-0}" |
| 36 | +export CUDA_VISIBLE_DEVICES="${CUDA_VISIBLE_DEVICES:-0}" |
| 37 | + |
| 38 | +# arch|ckpt|mmproj|n_images|env|alternate-config CLI flags. |
| 39 | +# openvla_oft has no alternate: at f32 its weights need 30 GB. |
| 40 | +MODELS=( |
| 41 | + "smolvla|${HF}/smolvla-libero-gguf/smolvla-libero.gguf|${HF}/backup/mmproj-smolvla-libero.gguf|2||--flash-attn --mm-prec default" |
| 42 | + "pi0|${HF}/pi0-libero-finetuned-v044-gguf/pi0-libero-finetuned-v044.gguf|${HF}/backup/mmproj-pi0-libero-finetuned-v044.gguf|2||--act-dtype bf16 --flash-attn" |
| 43 | + "pi05|${HF}/pi05-libero-gguf/pi05-libero.gguf|${HF}/backup/mmproj-pi05-libero.gguf|2||--weight-dtype f32" |
| 44 | + "evo1|${HF}/evo1-libero-gguf/evo1-libero.gguf||2||--act-dtype bf16 --flash-attn" |
| 45 | + "gr00t_n1_5|${HF}/gr00tn1d5-libero-object-gguf/gr00tn1d5-libero-object.gguf||2||--weight-dtype f32" |
| 46 | + "gr00t_n1_6|${HF}/gr00tn1d6-libero-gguf/gr00tn1d6-libero.gguf||2||--weight-dtype f32" |
| 47 | + "gr00t_n1_7|${HF}/gr00tn1d7-libero-gguf/libero_object/gr00tn1d7-libero-object.gguf||2||--weight-dtype f32" |
| 48 | + "bitvla|${HF}/bitvla-libero-gguf/libero_object/bitvla-libero-object.gguf||2||--weight-dtype bf16" |
| 49 | + "vla_adapter|${HF}/vla-adapter-libero-object-gguf/libero_object/vla-adapter-libero-object.gguf||2||--weight-dtype f32" |
| 50 | + "openvla_oft|${HF}/openvla-oft-libero-gguf/openvla-oft-libero.gguf||2||" |
| 51 | + "vla_jepa|${HF}/vla-jepa-libero/vla-jepa.gguf||2|VLA_EXTRA_TOKEN=151697 VLA_EXTRA_COUNT=32|--weight-dtype f32" |
| 52 | +) |
| 53 | + |
| 54 | +[[ -x "${BIN}" ]] || { echo "ERROR: missing ${BIN} (cmake -DVLA_BUILD_TESTS=ON)" >&2; exit 1; } |
| 55 | +mkdir -p "${OUT}" |
| 56 | + |
| 57 | +run_one() { |
| 58 | + local arch="$1" ckpt="$2" mmproj="$3" nimg="$4" env_str="$5" tag="$6" side="$7" cli="$8" |
| 59 | + # shellcheck disable=SC2086 |
| 60 | + env ${env_str} VLA_IMG_SIZE="${side}" VLA_BENCH_ITERS="${BENCH}" \ |
| 61 | + "${BIN}" "${ckpt}" "${mmproj}" "${nimg}" ${cli} \ |
| 62 | + > "${OUT}/${arch}${tag}.actions.txt" 2> "${OUT}/${arch}${tag}.log" |
| 63 | +} |
| 64 | + |
| 65 | +fail=0 |
| 66 | +for row in "${MODELS[@]}"; do |
| 67 | + IFS='|' read -r arch ckpt mmproj nimg always fastest <<< "${row}" |
| 68 | + |
| 69 | + if [[ -n "${ARCHS:-}" && " ${ARCHS} " != *" ${arch} "* ]]; then |
| 70 | + continue |
| 71 | + fi |
| 72 | + if [[ ! -e "${ckpt}" ]]; then |
| 73 | + echo "[skip] ${arch}: no checkpoint at ${ckpt}" |
| 74 | + continue |
| 75 | + fi |
| 76 | + |
| 77 | + side="" |
| 78 | + for s in ${SIDES}; do |
| 79 | + if run_one "${arch}" "${ckpt}" "${mmproj}" "${nimg}" "${always}" "" "${s}" "" \ |
| 80 | + && ! grep -q '^action_len=0$' "${OUT}/${arch}.actions.txt"; then |
| 81 | + side="${s}" |
| 82 | + echo "${s}" > "${OUT}/${arch}.side" |
| 83 | + break |
| 84 | + fi |
| 85 | + done |
| 86 | + if [[ -z "${side}" ]]; then |
| 87 | + echo "[FAIL] ${arch}: no input side in '${SIDES}' produced a chunk; see ${OUT}/${arch}.log" >&2 |
| 88 | + fail=1 |
| 89 | + continue |
| 90 | + fi |
| 91 | + |
| 92 | + line="[ok ] ${arch} side=${side}" |
| 93 | + [[ "${BENCH}" -gt 0 ]] && line+=" default=$(grep -oP 'min=\K[0-9.]+' "${OUT}/${arch}.log" | head -1)ms" |
| 94 | + |
| 95 | + if [[ -n "${fastest}" ]]; then |
| 96 | + if run_one "${arch}" "${ckpt}" "${mmproj}" "${nimg}" "${always}" ".alt" "${side}" "${fastest}" \ |
| 97 | + && ! grep -q '^action_len=0$' "${OUT}/${arch}.alt.actions.txt"; then |
| 98 | + line+=" alt=ok" |
| 99 | + [[ "${BENCH}" -gt 0 ]] && line+=" $(grep -oP 'min=\K[0-9.]+' "${OUT}/${arch}.alt.log" | head -1)ms" |
| 100 | + else |
| 101 | + echo "[FAIL] ${arch}: alternate config produced no chunk; see ${OUT}/${arch}.fast.log" >&2 |
| 102 | + fail=1 |
| 103 | + fi |
| 104 | + fi |
| 105 | + echo "${line}" |
| 106 | +done |
| 107 | + |
| 108 | +echo |
| 109 | +echo "written to ${OUT}" |
| 110 | +exit "${fail}" |
0 commit comments