p-doom/crowd-code-dataset-0.2 huggingface dataset:
[tab] slurm/jobs/mihir/horeka/mask_prob_fix/train_dynamics_8_nodes_dev.sbatch (shellscript)
#!/usr/bin/env bash

#SBATCH --nodes=1
#SBATCH --ntasks-per-node=1
#SBATCH --time=00:15:00
#SBATCH --partition=dev_accelerated
#SBATCH --cpus-per-task=5
#SBATCH --gres=gpu:1
#SBATCH --output=/hkfs/work/workspace/scratch/tum_ind3695-jafa_ws_shared/logs/logs_mihir/maskgit-maskprob-fix/dynamics-cotraining/%x_%j.log
#SBATCH --error=/hkfs/work/workspace/scratch/tum_ind3695-jafa_ws_shared/logs/logs_mihir/maskgit-maskprob-fix/dynamics-cotraining/%x_%j.log
#SBATCH --job-name=train_dynamics_maskprob_fix_8_node

# Log the sbatch script
cat $0

module unload mpi/openmpi/5.0
module unload devel/cuda/12.4
source .venv/bin/activate

array_records_dir=/hkfs/work/workspace/scratch/tum_ind3695-jafa_ws_shared/data_new/open_ai_minecraft_arrayrecords_chunked

job_name=$SLURM_JOB_NAME
slurm_job_id=$SLURM_JOB_ID

CHECKPOINT_DIR=/hkfs/work/workspace/scratch/tum_ind3695-jafa_ws_shared/checkpoints/maskgit-maskprob-fix/$job_name/$slurm_job_id
mkdir -p $CHECKPOINT_DIR

# tokenizer with the new structure supporting larger ffn_dim
tokenizer_ckpt_dir=/hkfs/work/workspace/scratch/tum_ind3695-jafa_ws_shared/data/checkpoints/train_tokenizer_lr_sweep_1e-4_larger_ffn/

env | grep SLURM

srun python train_dynamics.py \
    --save_ckpt \
    $restore_ckpt_flag \
    --wandb_id $SLURM_JOB_ID \
    --ckpt_dir $CHECKPOINT_DIR \
    --batch_size=12 \
    --init_lr=0 \
    --max_lr=8e-5 \
    --log_image_interval=1000 \
    --log \
    --log_checkpoint_interval=1000 \
    --name=dynamics-maskprob-fix-dev-$slurm_job_id \
    --tags dynamics maskprob-fix \
    --entity instant-uv \
    --project jafar \
    --tokenizer_checkpoint=$tokenizer_ckpt_dir \
    --data_dir $array_records_dir \
    --dyna_dim=768 \
    --dyna_num_blocks=16 \
    --dyna_num_heads=12
[tab] slurm/jobs/mihir/horeka/modelsize_scaling/dynamics/3_train_dyn_180M.sbatch (shellscript)
#!/usr/bin/env bash

#SBATCH --nodes=12
#SBATCH --ntasks-per-node=4
#SBATCH --time=48:00:00
#SBATCH --partition=accelerated
#SBATCH --cpus-per-task=5
#SBATCH --gres=gpu:4
#SBATCH --output=/hkfs/work/workspace/scratch/tum_ind3695-jafa_ws_shared/logs/logs_mihir/big-runs/dynamics-cotraining-modelsize-scaling/%x_%j.log
#SBATCH --error=/hkfs/work/workspace/scratch/tum_ind3695-jafa_ws_shared/logs/logs_mihir/big-runs/dynamics-cotraining-modelsize-scaling/%x_%j.log
#SBATCH --job-name=train_dynamics_modelsize_scaling_180M_12_node

# Log the sbatch script
cat $0

module unload mpi/openmpi/5.0
module unload devel/cuda/12.4
source .venv/bin/activate

array_records_dir=/hkfs/work/workspace/scratch/tum_ind3695-jafa_ws_shared/data_new/open_ai_minecraft_arrayrecords_chunked

job_name=$SLURM_JOB_NAME
slurm_job_id=$SLURM_JOB_ID

CHECKPOINT_DIR=/hkfs/work/workspace/scratch/tum_ind3695-jafa_ws_shared/checkpoints/big-runs/dynamics-cotraining-modelsize-scaling/$job_name
mkdir -p $CHECKPOINT_DIR

tokenizer_ckpt_dir=/hkfs/work/workspace/scratch/tum_ind3695-jafa_ws_shared/checkpoints/train_tokenizer_batch_size_scaling_16_node/3321526/tokenizer_22000/

env | grep SLURM

srun python train_dynamics.py \
    --save_ckpt \
    --restore_ckpt \
    --ckpt_dir $CHECKPOINT_DIR \
    --batch_size=96 \
    --min_lr=0 \
    --max_lr=1.5e-5 \
    --log_image_interval=1000 \
    --log \
    --log_checkpoint_interval=1000 \
    --name=dynamics-modelsize-scaling-180M-$slurm_job_id \
    --tags dynamics modelsize-scaling 180M \
    --entity instant-uv \
    --project jafar \
    --tokenizer_checkpoint=$tokenizer_ckpt_dir \
    --data_dir $array_records_dir \
    --dyna_dim=1024 \
    --dyna_num_blocks=16 \
    --dyna_num_heads=16
[tab] slurm/jobs/mihir/horeka/modelsize_scaling/dynamics/4_train_dyn_270M.sbatch (shellscript)
#!/usr/bin/env bash

#SBATCH --nodes=12
#SBATCH --ntasks-per-node=4
#SBATCH --time=48:00:00
#SBATCH --partition=accelerated
#SBATCH --cpus-per-task=5
#SBATCH --gres=gpu:4
#SBATCH --output=/hkfs/work/workspace/scratch/tum_ind3695-jafa_ws_shared/logs/logs_mihir/big-runs/dynamics-cotraining-modelsize-scaling/%x_%j.log
#SBATCH --error=/hkfs/work/workspace/scratch/tum_ind3695-jafa_ws_shared/logs/logs_mihir/big-runs/dynamics-cotraining-modelsize-scaling/%x_%j.log
#SBATCH --job-name=train_dynamics_modelsize_scaling_270M_16_node

# Log the sbatch script
cat $0

module unload mpi/openmpi/5.0
module unload devel/cuda/12.4
source .venv/bin/activate

array_records_dir=/hkfs/work/workspace/scratch/tum_ind3695-jafa_ws_shared/data_new/open_ai_minecraft_arrayrecords_chunked

job_name=$SLURM_JOB_NAME
slurm_job_id=$SLURM_JOB_ID

CHECKPOINT_DIR=/hkfs/work/workspace/scratch/tum_ind3695-jafa_ws_shared/checkpoints/big-runs/dynamics-cotraining-modelsize-scaling/$job_name
mkdir -p $CHECKPOINT_DIR

tokenizer_ckpt_dir=/hkfs/work/workspace/scratch/tum_ind3695-jafa_ws_shared/checkpoints/train_tokenizer_batch_size_scaling_16_node/3321526/tokenizer_22000/

env | grep SLURM

srun python train_dynamics.py \
    --save_ckpt \
    --ckpt_dir $CHECKPOINT_DIR \
    --batch_size=96 \
    --min_lr=0 \
    --max_lr=1.5e-5 \
    --log_image_interval=1000 \
    --log \
    --log_checkpoint_interval=1000 \
    --name=dynamics-modelsize-scaling-270M-$slurm_job_id \
    --tags dynamics modelsize-scaling 270M \
    --entity instant-uv \
    --project jafar \
    --tokenizer_checkpoint=$tokenizer_ckpt_dir \
    --data_dir $array_records_dir \
    --dyna_dim=1024 \
    --dyna_num_blocks=24 \
    --dyna_num_heads=16
[tab] slurm/jobs/mihir/horeka/mask_prob_fix/train_dynamics_8_nodes.sbatch (shellscript)
#!/usr/bin/env bash

#SBATCH --nodes=8
#SBATCH --ntasks-per-node=4
#SBATCH --time=48:00:00
#SBATCH --partition=accelerated
#SBATCH --cpus-per-task=5
#SBATCH --gres=gpu:4
#SBATCH --output=/hkfs/work/workspace/scratch/tum_ind3695-jafa_ws_shared/logs/logs_mihir/maskgit-maskprob-fix/dynamics-cotraining/%x_%j.log
#SBATCH --error=/hkfs/work/workspace/scratch/tum_ind3695-jafa_ws_shared/logs/logs_mihir/maskgit-maskprob-fix/dynamics-cotraining/%x_%j.log
#SBATCH --job-name=train_dynamics_maskprob_fix_8_node
#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

module unload mpi/openmpi/5.0
module unload devel/cuda/12.4
source .venv/bin/activate

array_records_dir=/hkfs/work/workspace/scratch/tum_ind3695-jafa_ws_shared/data_new/open_ai_minecraft_arrayrecords_chunked

job_name=$SLURM_JOB_NAME
slurm_job_id=$SLURM_JOB_ID

CHECKPOINT_DIR=/hkfs/work/workspace/scratch/tum_ind3695-jafa_ws_shared/checkpoints/maskgit-maskprob-fix/$job_name/$slurm_job_id
mkdir -p $CHECKPOINT_DIR

# tokenizer with the new structure supporting larger ffn_dim
tokenizer_ckpt_dir=/hkfs/work/workspace/scratch/tum_ind3695-jafa_ws_shared/data/checkpoints/train_tokenizer_lr_sweep_1e-4_larger_ffn/

env | grep SLURM

srun python train_dynamics.py \
    --save_ckpt \
    $restore_ckpt_flag \
    --wandb_id $SLURM_JOB_ID \
    --ckpt_dir $CHECKPOINT_DIR \
    --batch_size=384 \
    --init_lr=0 \
    --max_lr=8e-5 \
    --log_image_interval=1000 \
    --log \
    --log_checkpoint_interval=1000 \
    --name=dynamics-maskprob-fix-8-node-$slurm_job_id \
    --tags dynamics maskprob-fix 8-node \
    --entity instant-uv \
    --project jafar \
    --tokenizer_checkpoint=$tokenizer_ckpt_dir \
    --data_dir $array_records_dir &

child_pid=$!

wait $child_pid
[tab] slurm/utils/mihir/model_sizes.md (markdown)
# Genie 1 - Model Sizes and their configs

## Tokenizer model: sizes

default: 
| Model | model_dim | num_blocks | num_heads | latent_dim | num_latents | Est. Params |
|-------|-----------|------------|-----------|------------|-------------|-------------|
| default | 512 | 8 | 8 | 32 | 1024 | ~38M |

### scaling up 
#### (not tested yet - TODO @mihir)

| Model | model_dim | num_blocks | num_heads | latent_dim | num_latents | Est. Params |
|-------|-----------|------------|-----------|------------|-------------|-------------|
| L1 | 768 | 12 | 12 | 64 | 2048 | ~80M |
| L2 | 1024 | 12 | 16 | 128 | 2048 | ~140M |
| L3 | 1152 | 16 | 16 | 128 | 4096 | ~200M |
| L4 | 896 | 16 | 14 | 96 | 4096 | ~120M |
| L5 | 1536 | 12 | 24 | 256 | 2048 | ~190M |


### tiny models
| Model | model_dim | num_blocks | num_heads | latent_dim | num_latents | Est. Params |
|-------|-----------|------------|-----------|------------|-------------|-------------|
| S1 | 128 | 2 | 2 | 8 | 128 | ~0.6M |
| S2 | 192 | 2 | 3 | 16 | 128 | ~1.3M |
| S3 | 256 | 3 | 4 | 16 | 256 | ~3.6M |
| S4 | 320 | 4 | 5 | 24 | 256 | ~7.4M |
| S5 | 384 | 4 | 6 | 32 | 512 | ~10M |


## Latent Action model: sizes
default: 
| Model | model_dim | num_blocks | num_heads | latent_dim | num_latents | Est. Params |
|-------|-----------|------------|-----------|------------|-------------|-------------|
| default | 512 | 8 | 8 | 32 | 6 | ~39M |

### scaling up 
#### (not tested yet - TODO @mihir)

| Name | model_dim | num_blocks | num_heads | latent_dim | num_latents | Est. Params |
|--------------|-----------|------------|-----------|------------|-------------|-------------|
| XL | 1024 | 12 | 16 | 64 | 12 | ~200M |
| L | 896 | 12 | 14 | 48 | 8 | ~150M |
| M+ | 768 | 10 | 12 | 48 | 8 | ~100M |
| M | 640 | 10 | 10 | 32 | 8 | ~70M |
| Base+ | 512 | 12 | 8 | 32 | 8 | ~55M |


### tiny models
| Name | model_dim | num_blocks | num_heads | latent_dim | num_latents | Est. Params |
|--------------|-----------|------------|-----------|------------|-------------|-------------|
| XS | 128 | 2 | 2 | 8 | 4 | ~0.9M |
| S | 160 | 2 | 2 | 8 | 4 | ~1.3M |
| S+ | 192 | 3 | 3 | 8 | 4 | ~2.4M |
| M- | 256 | 4 | 4 | 16 | 6 | ~5.4M |
| M | 320 | 6 | 4 | 16 | 6 | ~12M |


## Dynamics model: sizes 

| Config | dyna_dim | dyna_num_blocks | dyna_num_heads | Approx. Params |
|--------|----------|-----------------|---------------|----------------|
| 1 | 512 | 12 | 8   | ~36M  |
| 2 | 768 | 16 | 12  | ~110M |
| 3 | 1024 | 16 | 16 | ~180M |
| 4 | 1024 | 24 | 16 | ~270M |
| 5 | 1536 | 24 | 24 | ~500M |


### tiny models
| Config | dyna_dim | dyna_num_blocks | dyna_num_heads | Approx. Params |
|--------|----------|-----------------|---------------|----------------|
| A | 128 | 2 | 4 | ~1.5M |
| B | 256 | 2 | 4 | ~3.5M |
| C | 256 | 4 | 4 | ~6M   |
| D | 384 | 4 | 6 | ~12M  |
| E | 512 | 4 | 8 | ~18M  |
[tab] slurm/jobs/mihir/horeka/batchsize_scaling/dynamics_cotraining/sqrt_lr/train_dynamics_16_nodes.sbatch (shellscript)
#!/usr/bin/env bash

#SBATCH --nodes=16
#SBATCH --ntasks-per-node=4
#SBATCH --time=48:00:00
#SBATCH --partition=accelerated
#SBATCH --cpus-per-task=5
#SBATCH --gres=gpu:4
#SBATCH --output=/hkfs/work/workspace/scratch/tum_ind3695-jafa_ws_shared/logs/logs_mihir/big-runs/dynamics-cotraining-batchsize-scaling/%x_%j.log
#SBATCH --error=/hkfs/work/workspace/scratch/tum_ind3695-jafa_ws_shared/logs/logs_mihir/big-runs/dynamics-cotraining-batchsize-scaling/%x_%j.log
#SBATCH --job-name=train_tokenizer_batch_size_scaling_16_node

# Log the sbatch script
cat $0

module unload mpi/openmpi/5.0
module unload devel/cuda/12.4
source .venv/bin/activate

array_records_dir=/hkfs/work/workspace/scratch/tum_ind3695-jafa_ws_shared/data_new/open_ai_minecraft_arrayrecords_chunked

job_name=$SLURM_JOB_NAME
slurm_job_id=$SLURM_JOB_ID

CHECKPOINT_DIR=/hkfs/work/workspace/scratch/tum_ind3695-jafa_ws_shared/checkpoints/big-runs/dynamics-cotraining-batchsize-scaling/$job_name
mkdir -p $CHECKPOINT_DIR

tokenizer_ckpt_dir=/hkfs/work/workspace/scratch/tum_ind3695-jafa_ws_shared/checkpoints/train_tokenizer_batch_size_scaling_16_node/3321526/tokenizer_22000/

env | grep SLURM

srun python train_dynamics.py \
    --save_ckpt \
    --restore_ckpt \
    --ckpt_dir $CHECKPOINT_DIR \
    --batch_size=768 \
    --min_lr=0 \
    --max_lr=4.2e-5 \
    --log_image_interval=1000 \
    --log \
    --log_checkpoint_interval=1000 \
    --name=dynamics-batch-size-scaling-16-node-$slurm_job_id \
    --tags dynamics batch-size-scaling 16-node \
    --entity instant-uv \
    --project jafar \
    --tokenizer_checkpoint=$tokenizer_ckpt_dir \
    --data_dir $array_records_dir
[content] slurm/utils/mihir/dataset_sizes.md (markdown)
| Batch Size | Steps per Epoch |
|------------|----------------|
| 48         | 234,375        |
| 96         | 117,187        |
| 192        | 58,593         |
| 384        | 29,297         |
| 768        | 14,648         |