p-doom/crowd-code-dataset-0.2 huggingface dataset:
[tab] slurm/dev/franz/berlin/atari/dynamics_from_continued_from_40k_tokenizer/spawn_dynamics.sh (shellscript)
#!/usr/bin/env bash

set -euo pipefail

REPO_ROOT="/home/franz.srambical/jafar"

DATA_ROOT="${DATA_ROOT:-/fast/project/HFMI_SynergyUnit/jafar_ws/data/atari}"

DYNAMICS_SCRIPT="${DYNAMICS_SCRIPT:-$REPO_ROOT/slurm/dev/franz/berlin/atari/dynamics_from_continued_from_40k_tokenizer/dynamics.sh}"

# Optional override: TOKENIZER_CKPT_DIR points to a specific tokenizer run dir
TOKENIZER_CKPT_DIR_OPT="${TOKENIZER_CKPT_DIR:-}"

if [ "$#" -gt 0 ]; then
    ENV_LIST=("$@")
else
    if [ ! -d "$DATA_ROOT" ]; then
        echo "DATA_ROOT does not exist: $DATA_ROOT" >&2
        exit 1
    fi
    mapfile -t ENV_LIST < <(find "$DATA_ROOT" -mindepth 1 -maxdepth 1 -type d -printf '%f
' | sort)
fi

echo "Submitting Dynamics jobs for environments: ${ENV_LIST[*]}"

for env in "${ENV_LIST[@]}"; do
    env_dir="$DATA_ROOT/$env"
    if [ ! -d "$env_dir/train" ] || [ ! -d "$env_dir/val" ]; then
        echo "Skipping $env (missing train/val under $env_dir)"
        continue
    fi

    job_name="dynamics_atari_${env}_dev_150k_steps_tokenizer"

    # Determine tokenizer checkpoint directory per env
    tokenizer_ckpt_dir=""
    if [ -n "$TOKENIZER_CKPT_DIR_OPT" ]; then
        tokenizer_ckpt_dir="$TOKENIZER_CKPT_DIR_OPT"
    else
        # Heuristic: pick the most recent run whose name is base+exactly 5 digits
        base_dir="/fast/project/HFMI_SynergyUnit/jafar_ws/checkpoints/atari/${env}/tokenizer"
        prefix="tokenizer_atari_${env}_dev_lr_3e-6_"
        if [ -d "$base_dir" ]; then
            # newest directory by mtime matching ..._NNNNN with exactly 5 digits and nothing after
            latest=$(find "$base_dir" -mindepth 1 -maxdepth 1 -type d \
                -regextype posix-extended \
                -regex "$base_dir/${prefix}[0-9]{5}" \
                -printf '%T@ %p
' | sort -nr | awk 'NR==1{print $2}')
            if [ -n "${latest:-}" ] && [ -d "$latest" ]; then
                tokenizer_ckpt_dir="$latest"
            fi
        fi
    fi

    if [ -z "$tokenizer_ckpt_dir" ]; then
        echo "Skipping $env (no TOKENIZER_CKPT_DIR provided and none found under tokenizer ckpts)"
        continue
    fi

    job_id=$(sbatch --parsable \
        --job-name="$job_name" \
        --chdir="$REPO_ROOT" \
        --export=ALL,ENV_NAME="$env",TOKENIZER_CKPT_DIR="$tokenizer_ckpt_dir" \
        "$DYNAMICS_SCRIPT")

    echo "Submitted $job_name (ENV_NAME=$env) using tokenizer ckpt $tokenizer_ckpt_dir as job $job_id"
done
[tab] slurm/dev/franz/berlin/atari/dynamics_fleuret_hparams_patch_size_4/dynamics.sh (shellscript)
#!/usr/bin/env bash

#SBATCH --nodes=1
#SBATCH --ntasks-per-node=1
#SBATCH --time=24:00:00
#SBATCH --cpus-per-task=8
#SBATCH --gres=gpu:1
#SBATCH --output=/fast/project/HFMI_SynergyUnit/jafar_ws/logs/franz/atari/dynamics/%x_%j.log
#SBATCH --error=/fast/project/HFMI_SynergyUnit/jafar_ws/logs/franz/atari/dynamics/%x_%j.log
#SBATCH --job-name=dynamics_atari_alien_dev_150k_steps_tokenizer
#SBATCH --requeue
#SBATCH --signal=b:usr1@300 # 5 min before timeout

# --- signal trap to requeue job before timeout ---
requeue_job() {
    echo "[$(date)] caught sigusr1 (timeout warning), requeueing slurm job $SLURM_JOB_ID..."
    # optional: trigger checkpoint saving here
    # e.g., touch $checkpoint_dir/requeue_trigger
    scontrol requeue $SLURM_JOB_ID
    exit 0
}

trap requeue_job sigusr1

# set checkpoint flag based on restart count
restart_count=$(scontrol show job $SLURM_JOB_ID | grep -o 'Restarts=[0-9]*' | cut -d'=' -f2)

if [ $restart_count -eq 0 ]; then
    restore_ckpt_flag="--no-restore-ckpt"
else
    restore_ckpt_flag="--restore-ckpt"
fi



# Log the sbatch script
cat $0

source .venv/bin/activate

job_name=$SLURM_JOB_NAME
slurm_job_id=$SLURM_JOB_ID

# Require ENV_NAME to be provided via sbatch --export=ENV_NAME=...
if [ -z "${ENV_NAME:-}" ]; then
    echo "ENV_NAME must be provided (e.g., sbatch --export=ALL,ENV_NAME=alien $0)" >&2
    exit 2
fi

tags="atari ${ENV_NAME} dynamics dev 150k_steps_tokenizer"

array_records_dir="/fast/project/HFMI_SynergyUnit/jafar_ws/data/atari/${ENV_NAME}"

# Require TOKENIZER_CKPT_DIR to be provided to avoid hardcoding
if [ -z "${TOKENIZER_CKPT_DIR:-}" ]; then
    echo "TOKENIZER_CKPT_DIR must be provided (e.g., sbatch --export=ALL,ENV_NAME=$ENV_NAME,TOKENIZER_CKPT_DIR=/path/to/tokenizer_ckpt $0)" >&2
    exit 2
fi

tokenizer_ckpt_dir="${TOKENIZER_CKPT_DIR}"
CHECKPOINT_DIR="/fast/project/HFMI_SynergyUnit/jafar_ws/checkpoints/atari/${ENV_NAME}/dynamics/${job_name}/${slurm_job_id}"
mkdir -p $CHECKPOINT_DIR

env | grep SLURM

current_branch=$(git rev-parse --abbrev-ref HEAD)
if [ "$current_branch" != "prepend-action-maskgit" ]; then
    echo "This script must be run from the prepend-action-maskgit branch. Current branch is $current_branch. Exiting."
    exit 1
fi

srun python jasmine/train_dynamics_from_150k_tokenizer.py \
    --patch_size=16 \
    --image_height=84 \
    --image_width=84 \
    --save_ckpt \
    $restore_ckpt_flag \
    --wandb_id $SLURM_JOB_ID \
    --ckpt_dir $CHECKPOINT_DIR \
    --name="${job_name}_${slurm_job_id}" \
    --tags ${tags} \
    --entity instant-uv \
    --project jafar \
    --tokenizer_checkpoint="${tokenizer_ckpt_dir}" \
    --val_data_dir="${array_records_dir}/val" \
    --data_dir="${array_records_dir}/train" &

child_pid=$!

wait $child_pid
[tab] slurm/dev/franz/berlin/atari/dynamics_fleuret_hparams_patch_size_4/spawn_dynamics.sh (shellscript)
#!/usr/bin/env bash

set -euo pipefail

REPO_ROOT="/home/franz.srambical/jafar"

DATA_ROOT="${DATA_ROOT:-/fast/project/HFMI_SynergyUnit/jafar_ws/data/atari}"

DYNAMICS_SCRIPT="${DYNAMICS_SCRIPT:-$REPO_ROOT/slurm/dev/franz/berlin/atari/dynamics_from_continued_from_40k_tokenizer/dynamics.sh}"

# Optional override: TOKENIZER_CKPT_DIR points to a specific tokenizer run dir
TOKENIZER_CKPT_DIR_OPT="${TOKENIZER_CKPT_DIR:-}"

if [ "$#" -gt 0 ]; then
    ENV_LIST=("$@")
else
    if [ ! -d "$DATA_ROOT" ]; then
        echo "DATA_ROOT does not exist: $DATA_ROOT" >&2
        exit 1
    fi
    mapfile -t ENV_LIST < <(find "$DATA_ROOT" -mindepth 1 -maxdepth 1 -type d -printf '%f
' | sort)
fi

echo "Submitting Dynamics jobs for environments: ${ENV_LIST[*]}"

for env in "${ENV_LIST[@]}"; do
    env_dir="$DATA_ROOT/$env"
    if [ ! -d "$env_dir/train" ] || [ ! -d "$env_dir/val" ]; then
        echo "Skipping $env (missing train/val under $env_dir)"
        continue
    fi

    job_name="dynamics_atari_${env}_dev_150k_steps_tokenizer"

    # Determine tokenizer checkpoint directory per env
    tokenizer_ckpt_dir=""
    if [ -n "$TOKENIZER_CKPT_DIR_OPT" ]; then
        tokenizer_ckpt_dir="$TOKENIZER_CKPT_DIR_OPT"
    else
        # Heuristic: pick the most recent run whose name is base+exactly 5 digits
        base_dir="/fast/project/HFMI_SynergyUnit/jafar_ws/checkpoints/atari/${env}/tokenizer"
        prefix="tokenizer_atari_${env}_dev_lr_3e-6_"
        if [ -d "$base_dir" ]; then
            # newest directory by mtime matching ..._NNNNN with exactly 5 digits and nothing after
            latest=$(find "$base_dir" -mindepth 1 -maxdepth 1 -type d \
                -regextype posix-extended \
                -regex "$base_dir/${prefix}[0-9]{5}" \
                -printf '%T@ %p
' | sort -nr | awk 'NR==1{print $2}')
            if [ -n "${latest:-}" ] && [ -d "$latest" ]; then
                tokenizer_ckpt_dir="$latest"
            fi
        fi
    fi

    if [ -z "$tokenizer_ckpt_dir" ]; then
        echo "Skipping $env (no TOKENIZER_CKPT_DIR provided and none found under tokenizer ckpts)"
        continue
    fi

    job_id=$(sbatch --parsable \
        --job-name="$job_name" \
        --chdir="$REPO_ROOT" \
        --export=ALL,ENV_NAME="$env",TOKENIZER_CKPT_DIR="$tokenizer_ckpt_dir" \
        "$DYNAMICS_SCRIPT")

    echo "Submitted $job_name (ENV_NAME=$env) using tokenizer ckpt $tokenizer_ckpt_dir as job $job_id"
done
[tab] slurm/dev/franz/berlin/atari/dynamics.sh (shellscript)
#!/usr/bin/env bash

#SBATCH --nodes=1
#SBATCH --ntasks-per-node=1
#SBATCH --time=24:00:00
#SBATCH --cpus-per-task=8
#SBATCH --gres=gpu:1
#SBATCH --output=/fast/project/HFMI_SynergyUnit/jafar_ws/logs/franz/atari/dynamics/%x_%j.log
#SBATCH --error=/fast/project/HFMI_SynergyUnit/jafar_ws/logs/franz/atari/dynamics/%x_%j.log
#SBATCH --job-name=dynamics_atari_alien_dev
#SBATCH --requeue
#SBATCH --signal=b:usr1@300 # 5 min before timeout

# --- signal trap to requeue job before timeout ---
requeue_job() {
    echo "[$(date)] caught sigusr1 (timeout warning), requeueing slurm job $SLURM_JOB_ID..."
    # optional: trigger checkpoint saving here
    # e.g., touch $checkpoint_dir/requeue_trigger
    scontrol requeue $SLURM_JOB_ID
    exit 0
}

trap requeue_job sigusr1

# set checkpoint flag based on restart count
restart_count=$(scontrol show job $SLURM_JOB_ID | grep -o 'Restarts=[0-9]*' | cut -d'=' -f2)

if [ $restart_count -eq 0 ]; then
    restore_ckpt_flag="--no-restore-ckpt"
else
    restore_ckpt_flag="--restore-ckpt"
fi



# Log the sbatch script
cat $0

source .venv/bin/activate

job_name=$SLURM_JOB_NAME
slurm_job_id=$SLURM_JOB_ID

# Require ENV_NAME to be provided via sbatch --export=ENV_NAME=...
if [ -z "${ENV_NAME:-}" ]; then
    echo "ENV_NAME must be provided (e.g., sbatch --export=ALL,ENV_NAME=alien $0)" >&2
    exit 2
fi

tags="atari ${ENV_NAME} dynamics dev 20k_steps_tokenizer"

array_records_dir="/fast/project/HFMI_SynergyUnit/jafar_ws/data/atari/${ENV_NAME}"

# Require TOKENIZER_CKPT_DIR to be provided to avoid hardcoding
if [ -z "${TOKENIZER_CKPT_DIR:-}" ]; then
    echo "TOKENIZER_CKPT_DIR must be provided (e.g., sbatch --export=ALL,ENV_NAME=$ENV_NAME,TOKENIZER_CKPT_DIR=/path/to/tokenizer_ckpt $0)" >&2
    exit 2
fi

tokenizer_ckpt_dir="${TOKENIZER_CKPT_DIR}"
CHECKPOINT_DIR="/fast/project/HFMI_SynergyUnit/jafar_ws/checkpoints/atari/${ENV_NAME}/dynamics/${job_name}/${slurm_job_id}"
mkdir -p $CHECKPOINT_DIR

env | grep SLURM

current_branch=$(git rev-parse --abbrev-ref HEAD)
if [ "$current_branch" != "prepend-action-maskgit" ]; then
    echo "This script must be run from the prepend-action-maskgit branch. Current branch is $current_branch. Exiting."
    exit 1
fi

srun python jasmine/train_dynamics.py \
    --patch_size=16 \
    --image_height=84 \
    --image_width=84 \
    --save_ckpt \
    $restore_ckpt_flag \
    --wandb_id $SLURM_JOB_ID \
    --ckpt_dir $CHECKPOINT_DIR \
    --name="${job_name}_${slurm_job_id}" \
    --tags ${tags} \
    --entity instant-uv \
    --project jafar \
    --tokenizer_checkpoint="${tokenizer_ckpt_dir}" \
    --val_data_dir="${array_records_dir}/val" \
    --data_dir="${array_records_dir}/train" &

child_pid=$!

wait $child_pid
[tab] slurm/dev/franz/berlin/atari/spawn_dynamics.sh (shellscript)
#!/usr/bin/env bash

set -euo pipefail

REPO_ROOT="/home/franz.srambical/jafar"

DATA_ROOT="${DATA_ROOT:-/fast/project/HFMI_SynergyUnit/jafar_ws/data/atari}"

DYNAMICS_SCRIPT="${DYNAMICS_SCRIPT:-$REPO_ROOT/slurm/dev/franz/berlin/atari/dynamics.sh}"

# Optional override: TOKENIZER_CKPT_DIR points to a specific tokenizer run dir
TOKENIZER_CKPT_DIR_OPT="${TOKENIZER_CKPT_DIR:-}"

if [ "$#" -gt 0 ]; then
    ENV_LIST=("$@")
else
    if [ ! -d "$DATA_ROOT" ]; then
        echo "DATA_ROOT does not exist: $DATA_ROOT" >&2
        exit 1
    fi
    mapfile -t ENV_LIST < <(find "$DATA_ROOT" -mindepth 1 -maxdepth 1 -type d -printf '%f
' | sort)
fi

echo "Submitting Dynamics jobs for environments: ${ENV_LIST[*]}"

for env in "${ENV_LIST[@]}"; do
    env_dir="$DATA_ROOT/$env"
    if [ ! -d "$env_dir/train" ] || [ ! -d "$env_dir/val" ]; then
        echo "Skipping $env (missing train/val under $env_dir)"
        continue
    fi

    job_name="dynamics_atari_${env}_dev"

    # Determine tokenizer checkpoint directory per env
    tokenizer_ckpt_dir=""
    if [ -n "$TOKENIZER_CKPT_DIR_OPT" ]; then
        tokenizer_ckpt_dir="$TOKENIZER_CKPT_DIR_OPT"
    else
        # Heuristic: pick the most recent run under the expected tokenizer ckpt base
        base="/fast/project/HFMI_SynergyUnit/jafar_ws/checkpoints/atari/${env}/tokenizer"
        if [ -d "$base" ]; then
            # get newest directory by mtime
            latest=$(find "$base" -mindepth 1 -maxdepth 1 -type d -printf '%T@ %p
' | sort -nr | head -n1 | awk '{print $2}')
            if [ -n "${latest:-}" ] && [ -d "$latest" ]; then
                tokenizer_ckpt_dir="$latest"
            fi
        fi
    fi

    if [ -z "$tokenizer_ckpt_dir" ]; then
        echo "Skipping $env (no TOKENIZER_CKPT_DIR provided and none found under tokenizer ckpts)"
        continue
    fi

    job_id=$(sbatch --parsable \
        --job-name="$job_name" \
        --chdir="$REPO_ROOT" \
        --export=ALL,ENV_NAME="$env",TOKENIZER_CKPT_DIR="$tokenizer_ckpt_dir" \
        "$DYNAMICS_SCRIPT")

    echo "Submitted $job_name (ENV_NAME=$env) using tokenizer ckpt $tokenizer_ckpt_dir as job $job_id"
done
[tab] slurm/dev/franz/berlin/atari/tokenizer_lr_3e-6_continue_from_40k_to_200k/spawn_tokenizers.sh (shellscript)
#!/usr/bin/env bash

set -euo pipefail

REPO_ROOT="/home/franz.srambical/jafar"

DATA_ROOT="${DATA_ROOT:-/fast/project/HFMI_SynergyUnit/jafar_ws/data/atari}"

TOKENIZER_SCRIPT="${TOKENIZER_SCRIPT:-$REPO_ROOT/slurm/dev/franz/berlin/atari/tokenizer_lr_3e-6_continue_from_40k_to_200k/tokenizer.sh}"

if [ "$#" -gt 0 ]; then
    ENV_LIST=("$@")
else
    if [ ! -d "$DATA_ROOT" ]; then
        echo "DATA_ROOT does not exist: $DATA_ROOT" >&2
        exit 1
    fi
    # list immediate subdirectories (candidate env names)
    mapfile -t ENV_LIST < <(find "$DATA_ROOT" -mindepth 1 -maxdepth 1 -type d -printf '%f
' | sort)
fi

echo "Submitting tokenizer jobs for environments: ${ENV_LIST[*]}"

for env in "${ENV_LIST[@]}"; do
    env_dir="$DATA_ROOT/$env"
    if [ ! -d "$env_dir/train" ] || [ ! -d "$env_dir/val" ]; then
        echo "Skipping $env (missing train/val under $env_dir)"
        continue
    fi

    job_name="tokenizer_atari_${env}_dev_lr_3e-6_continue_from_40k_to_300k"

    job_id=$(sbatch --parsable \
        --job-name="$job_name" \
        --chdir="$REPO_ROOT" \
        --export=ALL,ENV_NAME="$env" \
        "$TOKENIZER_SCRIPT")

    echo "Submitted $job_name (ENV_NAME=$env) as job $job_id"
done
[content] slurm/dev/franz/berlin/atari/dynamics_fleuret_hparams_patch_size_4/dynamics.sh (shellscript)
# Map environments to tokenizer checkpoint directories (default if no override provided)
declare -A TOKENIZER_CKPT_MAP=(
    [alien]="/fast/project/HFMI_SynergyUnit/jafar_ws/checkpoints/atari/alien/tokenizer/tokenizer_atari_alien_dev_lr_3e-6_30130"
    [amidar]="/fast/project/HFMI_SynergyUnit/jafar_ws/checkpoints/atari/amidar/tokenizer/tokenizer_atari_amidar_dev_lr_3e-6_30131"
    [assault]="/fast/project/HFMI_SynergyUnit/jafar_ws/checkpoints/atari/assault/tokenizer/tokenizer_atari_assault_dev_lr_3e-6_30132"
    [asterix]="/fast/project/HFMI_SynergyUnit/jafar_ws/checkpoints/atari/asterix/tokenizer/tokenizer_atari_asterix_dev_lr_3e-6_30133"
    [bank_heist]="/fast/project/HFMI_SynergyUnit/jafar_ws/checkpoints/atari/bank_heist/tokenizer/tokenizer_atari_bank_heist_dev_lr_3e-6_30134"
    [battle_zone]="/fast/project/HFMI_SynergyUnit/jafar_ws/checkpoints/atari/battle_zone/tokenizer/tokenizer_atari_battle_zone_dev_lr_3e-6_30135"
    [boxing]="/fast/project/HFMI_SynergyUnit/jafar_ws/checkpoints/atari/boxing/tokenizer/tokenizer_atari_boxing_dev_lr_3e-6_30136"
    [breakout]="/fast/project/HFMI_SynergyUnit/jafar_ws/checkpoints/atari/breakout/tokenizer/tokenizer_atari_breakout_dev_lr_3e-6_30137"
    [chopper_command]="/fast/project/HFMI_SynergyUnit/jafar_ws/checkpoints/atari/chopper_command/tokenizer/tokenizer_atari_chopper_command_dev_lr_3e-6_30138"
    [crazy_climber]="/fast/project/HFMI_SynergyUnit/jafar_ws/checkpoints/atari/crazy_climber/tokenizer/tokenizer_atari_crazy_climber_dev_lr_3e-6_30139"
    [demon_attack]="/fast/project/HFMI_SynergyUnit/jafar_ws/checkpoints/atari/demon_attack/tokenizer/tokenizer_atari_demon_attack_dev_lr_3e-6_30140"
    [pong]="/fast/project/HFMI_SynergyUnit/jafar_ws/checkpoints/atari/pong/tokenizer/tokenizer_atari_pong_dev_lr_3e-6_30141"
)

# Allow explicit override via TOKENIZER_CKPT_DIR, else look up by ENV_NAME
if [ -n "${TOKENIZER_CKPT_DIR:-}" ]; then
    tokenizer_ckpt_dir="${TOKENIZER_CKPT_DIR}"
else
    if [ -n "${TOKENIZER_CKPT_MAP[$ENV_NAME]:-}" ]; then
        tokenizer_ckpt_dir="${TOKENIZER_CKPT_MAP[$ENV_NAME]}"
    else
        echo "No tokenizer checkpoint mapping found for ENV_NAME=$ENV_NAME. Provide TOKENIZER_CKPT_DIR or add an entry to TOKENIZER_CKPT_MAP." >&2
        exit 2
    fi
[terminal_command] TERMINAL ()
bash /home/franz.srambical/jafar/slurm/dev/franz/berlin/atari/dynamics_fleuret_hparams_patch_size_4/spawn_dynamics.sh alien amidar assault asterix bank_heist battle_zone boxing breakout crazy_climber
[tab] slurm/dev/franz/berlin/atari/tokenizer_lr_3e-6_fleuret_hparams_patch_size_4/tokenizer.sh (shellscript)
#!/usr/bin/env bash

#SBATCH --nodes=1
#SBATCH --ntasks-per-node=1
#SBATCH --gres=gpu:1
#SBATCH --time=24:00:00
#SBATCH --cpus-per-task=8
#SBATCH --output=/fast/project/HFMI_SynergyUnit/jafar_ws/logs/franz/atari/tokenizer/%x_%j.log
#SBATCH --error=/fast/project/HFMI_SynergyUnit/jafar_ws/logs/franz/atari/tokenizer/%x_%j.log
#SBATCH --job-name=tokenizer_atari_dev_lr_3e-6_fleuret_hparams_patch_size_4
#SBATCH --requeue
#SBATCH --signal=b:usr1@300 # 5 min before timeout

# --- signal trap to requeue job before timeout ---
requeue_job() {
    echo "[$(date)] caught sigusr1 (timeout warning), requeueing slurm job $SLURM_JOB_ID..."
    # optional: trigger checkpoint saving here
    # e.g., touch $checkpoint_dir/requeue_trigger
    scontrol requeue $SLURM_JOB_ID
    exit 0
}

trap requeue_job sigusr1

# set checkpoint flag based on restart count
restart_count=$(scontrol show job $SLURM_JOB_ID | grep -o 'Restarts=[0-9]*' | cut -d'=' -f2)

if [ $restart_count -eq 0 ]; then
    restore_ckpt_flag="--no-restore-ckpt"
else
    restore_ckpt_flag="--restore-ckpt"
fi

# Log the sbatch script
cat $0

source .venv/bin/activate

job_name=$SLURM_JOB_NAME
slurm_job_id=$SLURM_JOB_ID

# Require ENV_NAME to be provided via sbatch --export=ENV_NAME=...
if [ -z "${ENV_NAME:-}" ]; then
    echo "ENV_NAME must be provided (e.g., sbatch --export=ALL,ENV_NAME=alien $0)" >&2
    exit 2
fi

tags="atari ${ENV_NAME} tokenizer dev lr_3e-6 fleuret_hparams patch_size_4"

array_records_dir="/fast/project/HFMI_SynergyUnit/jafar_ws/data/atari/${ENV_NAME}"
CHECKPOINT_DIR="/fast/project/HFMI_SynergyUnit/jafar_ws/checkpoints/atari/${ENV_NAME}/tokenizer/${job_name}_${slurm_job_id}"
mkdir -p $CHECKPOINT_DIR

env | grep SLURM

current_branch=$(git rev-parse --abbrev-ref HEAD)
if [ "$current_branch" != "prepend-action-maskgit" ]; then
    echo "This script must be run from the prepend-action-maskgit branch. Current branch is $current_branch. Exiting."
    exit 1
fi

srun python jasmine/train_tokenizer.py \
    --num_latents=512 \
    --latent_dim=512 \
    --model_dim=256 \
    --ffn_dim=256 \
    --num_heads=4 \
    --patch_size=4 \
    --image_height=84 \
    --image_width=84 \
    --num_steps=300_000 \
    --max_lr=3e-6 \
    --warmup_steps=10_000 \
    --wsd_decay_steps=30_000 \
    --save_ckpt \
    $restore_ckpt_flag \
    --wandb_id $SLURM_JOB_ID \
    --ckpt_dir $CHECKPOINT_DIR \
    --name="${job_name}_${slurm_job_id}" \
    --tags $tags \
    --entity instant-uv \
    --project jafar \
    --data_dir="${array_records_dir}/train" \
    --val_data_dir="${array_records_dir}/val" &

child_pid=$!

wait $child_pid