jasonfan's picture
2026-03-19: ICL code
64bce2a verified
#!/bin/bash
#SBATCH --partition=scavenger-gpu
#SBATCH --exclude=dcc-youlab-gpu-28,dcc-gehmlab-gpu-56
#SBATCH --array=0-35 # 6 configurations to test
#SBATCH --ntasks=1
#SBATCH --nodes=1
#SBATCH --cpus-per-task=1
#SBATCH --mem-per-cpu=32G
#SBATCH --gres=gpu:1
#SBATCH --time=72:00:00
#SBATCH --output=/work/jf381/code/code/ICL_LOG/ICL_MODEL_TEST_TYPE2_Finetune_Pretrain_swiss_roll_045/%A_%a_%j.out
#SBATCH --error=/work/jf381/code/code/ICL_LOG/ICL_MODEL_TEST_TYPE2_Finetune_Pretrain_swiss_roll_045/%A_%a_%j.err
#SBATCH --nodelist=dcc-allenlab-gpu-[01-04],dcc-allenlab-gpu-[05-12],dcc-majoroslab-gpu-[01-08],dcc-yaolab-gpu-[01-08],dcc-wengerlab-gpu-01,dcc-engelhardlab-gpu-[01-04],dcc-motesa-gpu-[01-04],dcc-pbenfeylab-gpu-[01-04],dcc-vossenlab-gpu-[01-04],dcc-youlab-gpu-[01-56],dcc-mastatlab-gpu-01,dcc-viplab-gpu-01,dcc-youlab-gpu-57
#SBATCH --requeue
set -e
# 30,31,32 softmax use_cf
# 18,19,20 softmax use_ff
# exp 9 10 11
# 678 softmax
# nvidia-smi | grep 'python' | awk '{ print $5 }' | xargs -n1 kill -9
# SLURM_ARRAY_TASK_ID=3
# conda activate /work/jf381/cache/conda_envs/paul31
# source activate /work/jf381/cache/conda_envs/paul31
# use SLURM_ARRAY_TASK_ID to control
# cd /work/jf381/code/code/ICL_Jay
## pretrain useful for pe+lap
## add noise add performance
## test context size
## test model
# distribute 1000 tasks on
# python /work/jf381/code/code/ICL_Jay/train_end2end_new.py --test_mode $SLURM_ARRAY_TASK_ID --n_epochs 3001 --data_type sphere --data_generation --slurm_id --slurm_tasks
# n_epochs_stride
# SLURM_ARRAY_TASK_ID=0
#!/bin/bash
# 定义噪声水平列表
#!/bin/bash
# 获取SLURM任务ID
# SLURM_ARRAY_TASK_ID=34
# SLURM_ARRAY_TASK_ID=0
SLURM_ID=${SLURM_ARRAY_TASK_ID:-0}
# 设置数据类型
# 设置基础噪声水平(或从列表中选择)
add_noises=0 # 也可以从一个列表中基于SLURM_ID选择
# 使用SLURM_ID来确定模型配置
# 假设我们有以下变量组合:
# 1. n_layer_icl: 1, 2, 3, 4
# 2. kernel: 'linear', 'rbf', 'softmax', 'exp'
# 3. 使用选项: 无特殊选项, use_ff, use_ct
# /work/jf381/code/code/ICL_LOG/ICL_MODEL_TEST_TYPE2_Finetune_Pretrain_ENDEND
# NOW
data_type="swiss_roll"
test_data_type="swiss_roll"
# 计算层数 (1, 2, 4)
layer_options=(1 2 4)
layer_idx=$(( SLURM_ID % 3 ))
n_layer_icl=${layer_options[$layer_idx]}
# 计算kernel类型 (0-3)
kernel_idx=$(( (SLURM_ID / 3) % 4 ))
kernels=("linear" "rbf" "softmax" "exp")
kernel=${kernels[$kernel_idx]}
# 计算使用选项 (0-2)
option_idx=$(( (SLURM_ID / 12) % 3 ))
options=("" "--use_ff" "--use_cf")
option=${options[$option_idx]}
icl_type=2
echo "Running with configuration:"
echo "SLURM_ID = $SLURM_ID"
echo "n_layer_icl = $n_layer_icl"
echo "kernel = $kernel"
echo "option = $option"
echo "icl_type = $icl_type"
# 运行Python脚本
python /work/jf381/code/code/ICL_Jay/train_end2end_new.py \
--test_mode 3 \
--n_epochs 3001 \
--data_type $data_type \
--n_layer_icl $n_layer_icl \
--test_data_type $test_data_type \
--add_noises $add_noises \
--kernel $kernel \
--load_pretrain_model 5 \
--fine_tune_n_epochs 3001 \
--icl_type $icl_type \
--faster_test \
$option
# python /work/jf381/code/code/ICL_Jay/train_end2end_new.py --test_mode $SLURM_ARRAY_TASK_ID --n_epochs 3001 --data_type $data_type --n_layer_icl 2 --test_data_type $test_data_type
# python /work/jf381/code/code/ICL_Jay/train_end2end_new_test.py --test_mode 3 --n_epochs 31 --load_model
# Test Mode 0: Full Training
# This is the "full package" mode where everything is turned on. We're training all components simultaneously - Laplacian prediction (lap_weight=1), positional encoding (pe_weight=1), and in-context learning (icl_weight=1). We just give the model raw data and let it handle everything end-to-end. This tests how well all components work together.
# Test Mode 1: Pretrain Laplacian Only
# This focuses just on pretraining the Laplacian prediction component (lap_weight=1) while turning off the other parts (pe_weight=0, icl_weight=0). It's like teaching the model to understand the graph structure first before worrying about embeddings or classification. We're laying the foundation.
# Test Mode 2: Pretrain Positional Encoding
# Here, we're assuming we already have the correct Laplacian (we feed in real_lap), and we're training just the positional encoding component (pe_weight=1). We're skipping the Laplacian prediction (lap_weight=0) and not worrying about classification yet (icl_weight=0). This lets us focus on learning good embeddings from a known graph structure.
# Test Mode 3: Pretrain In-Context Learning
# In this mode, we're assuming we already have the perfect embeddings (we feed in real_ev), and we're only training the classification component (icl_weight=1). Both Laplacian and positional encoding parts are disabled (lap_weight=0, pe_weight=0). This tests how well the model can do classification when given ideal embeddings.
# Test Mode 4: Pretrain Laplacian + Positional Encoding
# This mode trains both the Laplacian prediction and positional encoding components together (lap_weight=1, pe_weight=1), but doesn't train the classification part (icl_weight=0). It's about getting the underlying representation right before trying to do any classification.