p-doom/crowd-code-dataset-0.2 huggingface dataset:
[tab] experiments/train_tokenizer_lr_1e-4_larger_ffn.sh (shellscript)
#!/usr/bin/env bash

#SBATCH --nodes=2
#SBATCH --ntasks-per-node=4
#SBATCH --time=24: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_franz/big-runs/%x_%j.log
#SBATCH --error=/hkfs/work/workspace/scratch/tum_ind3695-jafa_ws_shared/logs/logs_franz/big-runs/%x_%j.log
#SBATCH --job-name=train_tokenizer_lr_sweep_1e-4_larger_ffn

# 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=$PWD/checkpoints/$job_name
mkdir -p $CHECKPOINT_DIR

env | grep SLURM

srun python train_tokenizer.py \
    --ckpt_dir $CHECKPOINT_DIR \
    --restore_ckpt \
    --save_ckpt \
    --batch_size=96 \
    --ffn_dim=2048 \
    --num_blocks=4 \
    --init_lr=0 \
    --max_lr=1e-4 \
    --decay_end=0.0 \
    --wsd_decay_steps=10000 \
    --log_image_interval=1000 \
    --log_checkpoint_interval=1000 \
    --log \
    --name=mixed-precision-tokenizer-lr-1e-4-larger-ffn \
    --tags tokenizer mixed-precision 1e-4 mixed-precision flash-attention larger-ffn \
    --entity instant-uv \
    --project jafar \
    --data_dir $array_records_dir
[tab] utils/lr_utils.py (python)
import optax

def get_lr_schedule(lr_schedule: str, init_lr: float, max_lr: float, decay_end: float, total_steps: int, warmup_steps: int, wsd_decay_steps: int) -> optax.Schedule:
    supported_schedules = ["wsd", "cos"]
    if lr_schedule == "cos":
        assert warmup_steps <= total_steps, "Warmup steps can't be greater than total steps."
        return optax.warmup_cosine_decay_schedule(
            init_value=init_lr,
            peak_value=max_lr,
            warmup_steps=warmup_steps,
            decay_steps=total_steps, # Note: decay_steps includes the warmup steps, so we need to pass total value
            end_value=decay_end 
        )
    elif lr_schedule == "wsd":
        assert warmup_steps + wsd_decay_steps <= total_steps, "Warmup and decay period is longer than total steps."
        schedules = [
            optax.linear_schedule(init_value=init_lr, end_value=max_lr, transition_steps=warmup_steps),
            optax.constant_schedule(value=max_lr),
            optax.linear_schedule(init_value=max_lr, end_value=decay_end, transition_steps=wsd_decay_steps),
        ]
        boundaries = [warmup_steps, total_steps - wsd_decay_steps]
        return optax.join_schedules(schedules, boundaries)
    else:
        raise ValueError(f"Learning rate schedule not supported. Please use one of {supported_schedules}")