PopTurk / code /scripts /run_college.sh
Jyo-K's picture
Upload folder using huggingface_hub
d231962 verified
Raw
History Blame Contribute Delete
4.02 kB
#!/usr/bin/env bash
# Both college GPUs, end to end. Run from the v2 directory.
#
# bash scripts/run_college.sh test
#
# Everything is niced. The box is shared with ~23 other users and an earlier memmap-heavy job
# at load 37 made SSH unreachable for all of them; that is not a mistake worth repeating.
set -euo pipefail
SPLIT="${1:-test}"
N="${NICE:-nice -n 19 ionice -c3}"
export BERX_DATA="${BERX_DATA:-/scratch/user4/dai/dataset_unstop/dataset}"
export BERX_WORK="${BERX_WORK:-/scratch/user4/dai/v2/work}"
export BERX_EMB="${BERX_EMB:-/scratch/user4/dai/model-3/work/emb}"
export OMP_NUM_THREADS=2 MKL_NUM_THREADS=2 TOKENIZERS_PARALLELISM=false
# The box's /usr/bin/python has no pandas. This is the venv every other pipeline here uses.
PYBIN="${PYBIN:-/home/user4/Jyo/DAI/er_pipeline/.venv/bin/python}"
"$PYBIN" -c 'import pandas, torch' 2>/dev/null || {
echo "PYBIN=$PYBIN cannot import pandas/torch. Set PYBIN to the right interpreter."; exit 1; }
mkdir -p "$BERX_WORK/logs"
L="$BERX_WORK/logs"
echo "== 0. prepare"
$N "$PYBIN" scripts/00_prepare.py --split "$SPLIT" 2>&1 | tee "$L/00_prep.log"
echo "== A. administrative equivalence (CPU, runs beside the GPU work)"
$N "$PYBIN" scripts/02_france_geo.py --split "$SPLIT" 2>&1 | tee "$L/02_geo.log" &
GEO=$!
echo "== C. retrieval, both GPUs, one query shard each"
# Only channels whose matrices are actually on disk. At the time of writing that is e5-small
# alone; the two 1024-d channels are on the Hub and need 07_fetch_embeddings.py first. A run
# that quietly skipped them would report a three-channel union it never computed.
CHANNELS=$($PYBIN -c "
import sys; sys.path.insert(0,'.')
from berx import paths as P
have = P.available_channels('$SPLIT')
miss = [c for c in P.CHANNELS if c not in have]
print(' '.join(have))
print('MISSING: ' + ', '.join(miss) if miss else '', file=sys.stderr)
")
echo " channels present: ${CHANNELS:-none}"
if [ -z "$CHANNELS" ]; then echo " no embeddings found under $BERX_EMB - aborting"; exit 1; fi
for CH in $CHANNELS; do
CUDA_VISIBLE_DEVICES=0 $N "$PYBIN" scripts/03_retrieve.py --split "$SPLIT" --channel "$CH" \
--k 100 --shard 0 --nshards 2 --device cuda:0 2>&1 | tee "$L/retr_${CH}_0.log" &
P0=$!
CUDA_VISIBLE_DEVICES=1 $N "$PYBIN" scripts/03_retrieve.py --split "$SPLIT" --channel "$CH" \
--k 100 --shard 1 --nshards 2 --device cuda:0 2>&1 | tee "$L/retr_${CH}_1.log" &
P1=$!
wait $P0 $P1
echo " $CH done"
done
wait $GEO
echo "== 4. shard the cross-encoder work into 4 lanes"
$N "$PYBIN" scripts/04_make_shards.py --split "$SPLIT" --nshards 4 \
${ALREADY_SCORED:+--already-scored "$ALREADY_SCORED"} 2>&1 | tee "$L/04_shards.log"
echo "== upload lanes 2 and 3 for Colab"
"$PYBIN" scripts/01_upload_hf.py --what code shards geo --split "$SPLIT" 2>&1 | tee "$L/upload.log"
echo "== D. lanes 0 and 1 locally, one per GPU"
CUDA_VISIBLE_DEVICES=0 $N "$PYBIN" scripts/05_ce_score.py \
--shard "$BERX_WORK/shards/${SPLIT}_shard0of4.parquet" \
--model "${CE_MODEL:?set CE_MODEL to the fine-tuned reranker directory}" \
--out "$BERX_WORK/scored/${SPLIT}_shard0_ce.parquet" \
--ckpt "$BERX_WORK/ckpt/shard0_ce" 2>&1 | tee "$L/ce0.log" &
CUDA_VISIBLE_DEVICES=1 $N "$PYBIN" scripts/05_ce_score.py \
--shard "$BERX_WORK/shards/${SPLIT}_shard1of4.parquet" \
--model "$CE_MODEL" \
--out "$BERX_WORK/scored/${SPLIT}_shard1_ce.parquet" \
--ckpt "$BERX_WORK/ckpt/shard1_ce" 2>&1 | tee "$L/ce1.log" &
wait
echo
echo "Lanes 0 and 1 are done. Wait for the two Colab lanes to upload their parquet files to"
echo "the payload repo, download them into \$BERX_WORK/scored/, then run:"
echo
echo " \$PYBIN scripts/06_fuse.py --split $SPLIT --mode test \\"
echo " --ce-glob \"\$BERX_WORK/scored/${SPLIT}_shard*_ce.parquet\" \\"
echo " --bundle \$BERX_WORK/bundle/train_v2.joblib"
echo
echo "06_fuse MUST see every shard: the competitive features and the one-owner pass are"
echo "global, and a missing lane produces a plausible file that is quietly wrong."