mergebench-property-sweep / code /scripts /run_taskvec_detached.sh
suchirsalhan's picture
Back up code/scripts/run_taskvec_detached.sh
a799bdb verified
Raw
History Blame Contribute Delete
2.07 kB
#!/usr/bin/env bash
# Detached task-vector pass over every family, smallest-first, with a disk gate.
#
# Runs alongside the measurement sweep. Each family waits until there is room for its experts + base
# above a 400 GB floor (the hard floor is 350), so it can never race the sweep's 8B/9B families into
# the floor. Idempotent and resumable: families already carrying tv_* columns are recomputed
# harmlessly, and merging is keyed on pair_id.
#
# bash scripts/run_taskvec_detached.sh
set -u
cd "$(dirname "$0")/.."
PY=${PYTHON:-/root/venvs/mergeability/bin/python}
[ -f /root/.ms_hf_env ] && set -a && . /root/.ms_hf_env && set +a
export MB_THREADS=${MB_THREADS:-8}
export OMP_NUM_THREADS=$MB_THREADS MKL_NUM_THREADS=$MB_THREADS
export OPENBLAS_NUM_THREADS=$MB_THREADS NUMEXPR_NUM_THREADS=$MB_THREADS
export MB_DISK_FLOOR_GB=${MB_DISK_FLOOR_GB:-400}
mkdir -p results/mergebench/logs
# PREFLIGHT. This pass does minutes of downloads before it reaches the cache-write path, so a
# NameError there costs a whole family and is invisible until the coverage check. Exercise the
# persistence round-trip first; it takes milliseconds and it has already caught one such bug.
if ! PYTHONPATH=src "$PY" -c "
from mergeschool.mergebench import taskvec as TV
import json
TV.cache_write('__preflight__', {'__preflight__pair': {'tv_cosine': 0.0}})
d = json.loads(TV.CACHE.read_text()); assert '__preflight__pair' in d
d.pop('__preflight__pair'); TV.CACHE.write_text(json.dumps(d, indent=1))
TV.merge_cached()
" >/dev/null 2>&1; then
echo "PREFLIGHT FAILED: the task-vector cache round-trip does not work; refusing to launch" >&2
PYTHONPATH=src "$PY" -c "from mergeschool.mergebench import taskvec as TV; TV.cache_write('x',{'y':{'tv_cosine':0.0}})"
exit 1
fi
echo "preflight ok (cache round-trip)"
HF_HOME=/root/hf_cache_mergebench/tv CUDA_VISIBLE_DEVICES=${TV_GPU:-5} PYTHONPATH=src \
setsid nohup "$PY" -u -m mergeschool.mergebench.taskvec "$@" \
> results/mergebench/logs/taskvec.log 2>&1 &
echo "taskvec detached (pid $!) -> results/mergebench/logs/taskvec.log"