p-doom/crowd-code-dataset-0.2 huggingface dataset:
[tab] jasmine/utils/dataloader_torch.py (python)
# file copied from https://raw.githubusercontent.com/FLAIROx/jafar/refs/heads/main/utils/dataloader.py
from pathlib import Path

import jax.numpy as jnp
import numpy as np
from torch.utils.data import Dataset, DataLoader


class VideoDataset(Dataset):
    def __init__(self, data_dir, seq_len):
        self.data_dir = Path(data_dir)
        self.seq_len = seq_len
        self.metadata = np.load(self.data_dir / "metadata.npy", allow_pickle=True)

    def __len__(self):
        return len(self.metadata)

    def __getitem__(self, idx):
        episode = np.load(self.metadata[idx]["path"])
        start_idx = np.random.randint(0, len(episode) - self.seq_len + 1)
        seq = episode[start_idx : start_idx + self.seq_len]
        return seq.astype(np.float32) / 255.0


def collate_fn(batch):
    """Convert batch of numpy arrays to JAX array"""
    return {"videos": jnp.array(np.stack(batch))}


def get_dataloader(data_dir, seq_len, batch_size):
    dataset = VideoDataset(data_dir, seq_len)
    return DataLoader(
        dataset,
        batch_size=batch_size,
        shuffle=True,
        collate_fn=collate_fn,
    )
[tab] slurm/jobs/mihir/horeka/coinrun/train_dyn_single_gpu.sh (shellscript)
#!/usr/bin/env bash

#SBATCH --nodes=1
#SBATCH --ntasks-per-node=1
#SBATCH --time=00:40: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/coinrun/dynamics/%x_%j.log
#SBATCH --error=/hkfs/work/workspace/scratch/tum_ind3695-jafa_ws_shared/logs/logs_mihir/coinrun/dynamics/%x_%j.log
#SBATCH --job-name=train_dyn_single_gpu
#SBATCH --requeue
#SBATCH --signal=b:usr1@300 # 5 min before timeout

# 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_train=/hkfs/work/workspace/scratch/tum_ind3695-jafa_ws_shared/data_coinrun/npy_test
array_records_dir_val=/hkfs/work/workspace/scratch/tum_ind3695-jafa_ws_shared/data_coinrun/npy_test

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/dyn/$job_name/$slurm_job_id
mkdir -p $CHECKPOINT_DIR

tokenizer_checkpoint=/hkfs/work/workspace/scratch/tum_ind3695-jafa_ws_shared/checkpoints/big-runs/tokenizer/interactive/3536670

env | grep SLURM


srun python jasmine/train_dynamics.py \
    --save_ckpt \
    --image_height=64 \
    --image_width=64 \
    --ckpt_dir $CHECKPOINT_DIR \
    --batch_size=110 \
    --patch_size=4 \
    --init_lr=0 \
    --max_lr=1e-4 \
    --log_image_interval=50 \
    --log_checkpoint_interval=50 \
    --dyna_type=maskgit \
    --log \
    --name=coinrun-dyn-dev-$slurm_job_id \
    --tags dyn coinrun dev \
    --entity instant-uv \
    --project jafar \
    --warmup_steps 0 \
    --wsd_decay_steps 0 \
    --num_steps 10 \
    --data_dir $array_records_dir_train \
    --tokenizer_checkpoint $tokenizer_checkpoint \
    --val_data_dir $array_records_dir_val \
    --log_interval 1 \
    --val_interval 50 \
    --eval_full_frame \
    --val_steps 5