PWM / PWM_code /reward_model /scripts /archive /launch_3pointr_train.sh
hchen657Naza's picture
Add files using upload-large-folder tool
23e1f91 verified
Raw History Blame Contribute Delete
2.2 kB
#!/bin/bash
# Launch 3-PoinTr flow pretraining on the Stack-Can dataset we built.
# Splits are computed automatically from #episodes available (90/10 train/val).
set -e
DATA_ROOT="/home/hongyi/PWM/external/3pointr_data"
TASK="stack_can"
N_POINTS=512 # must match build_3pointr_dataset.py --n_points
SPLIT_NAME="${TASK}_flow"
EPOCHS="${EPOCHS:-2000}"
BATCH_SIZE="${BATCH_SIZE:-4}"
cd /home/hongyi/PWM/reward_model/3PoinTr_repo
# Ensure conda is available; use the 'pointr' env.
source /home/hongyi/miniconda3/etc/profile.d/conda.sh
conda activate pointr
# Auto-pick split sizes from #available episodes
TOTAL=$(ls -d "${DATA_ROOT}/no_actions/${TASK}"/[0-9][0-9][0-9][0-9] 2>/dev/null | wc -l)
if [ "$TOTAL" -lt 5 ]; then
echo "ERROR: only ${TOTAL} episodes built; need at least 5"; exit 1
fi
N_VAL=$((TOTAL / 10))
[ "$N_VAL" -lt 1 ] && N_VAL=1
N_TRAIN=$((TOTAL - N_VAL))
echo "[launch] $TOTAL episodes -> train=$N_TRAIN, val=$N_VAL, test=0"
# Splitter expects [train_actions, val_actions, test_actions, train_flows, val_flows, test_flows]
TASK_SPLITS="{\"${TASK}\": [0, 0, 0, ${N_TRAIN}, ${N_VAL}, 0]}"
python scripts_training/splitter.py \
--dataset "${DATA_ROOT}/" \
--task-splits "${TASK_SPLITS}" \
--out-dir "${DATA_ROOT}/" \
--name "${SPLIT_NAME}"
SPLIT_FILE="${DATA_ROOT}/${SPLIT_NAME}.json"
echo "[launch] split saved to ${SPLIT_FILE}"
# Pretrain. Architecture roughly matches their default 'glass' run but with
# subsample = N_POINTS so we use all our 512 query points per episode.
mkdir -p /home/hongyi/PWM/reward_model/3pointr_models
python scripts_training/pretrain_flow.py \
--device cuda:0 \
--epochs "${EPOCHS}" \
--batch_size "${BATCH_SIZE}" \
--lr 1e-4 \
--arch_dim 256 \
--arch_depth 2 \
--arch_heads 4 \
--arch_query_depth 1 \
--arch_query_heads 1 \
--subsample "${N_POINTS}" \
--dataset "${DATA_ROOT}/" \
--model_name "${TASK}_flowonly_${N_POINTS}pts" \
--tasks "${TASK}" \
--save_dir "/home/hongyi/PWM/reward_model/3pointr_models" \
--split_file "${SPLIT_FILE}" \
--flow_data_only \
--eval_every 50 \
--save_vis_every 250 \
--weight_decay 1e-4 \
--seed 42 \
--num_workers 4 \
--cache_data \
--flow_loss_w 10.0