Scriptwriter dataset sync
Browse files- restart-train.sh +27 -22
- scriptwriter-runpod-ready.tgz +2 -2
restart-train.sh
CHANGED
|
@@ -7,8 +7,8 @@ tmux kill-session -t scriptwriter-train 2>/dev/null || true
|
|
| 7 |
tmux kill-server 2>/dev/null || true
|
| 8 |
pkill -9 -f 'train_runpod.py' 2>/dev/null || true
|
| 9 |
pkill -9 -f 'scripts/train_runpod' 2>/dev/null || true
|
|
|
|
| 10 |
sleep 2
|
| 11 |
-
pgrep -af 'train_runpod' >/dev/null 2>&1 && pkill -9 -f train_runpod || true
|
| 12 |
echo "Old session cleared."
|
| 13 |
|
| 14 |
DEST=/workspace/scriptwriter-runpod
|
|
@@ -18,6 +18,9 @@ rm -rf "$DEST"
|
|
| 18 |
mkdir -p "$DEST"
|
| 19 |
tar xzf "$TGZ" -C "$DEST" --strip-components=1 --no-same-owner --no-same-permissions
|
| 20 |
|
|
|
|
|
|
|
|
|
|
| 21 |
export WORKDIR="$DEST"
|
| 22 |
export DATA_DIR=/workspace/data/processed
|
| 23 |
export OUTPUT_DIR=/workspace/models/lora
|
|
@@ -25,13 +28,15 @@ export HF_DATASET_REPO="${HF_DATASET_REPO:-datamatters24/scriptwriter-corpus-ia}
|
|
| 25 |
export HF_MODEL_REPO="${HF_MODEL_REPO:-datamatters24/scriptwriter-lora-ia}"
|
| 26 |
export BASE_MODEL="${BASE_MODEL:-meta-llama/Llama-3.2-3B-Instruct}"
|
| 27 |
export RUNPOD_SKIP_FORCE_PIP=1
|
| 28 |
-
|
| 29 |
export MAX_SEQ_LENGTH=2048
|
| 30 |
export MAX_SEQ_LENGTH_CAP=2048
|
| 31 |
export PER_DEVICE_TRAIN_BATCH_SIZE=1
|
| 32 |
-
export GRADIENT_ACCUMULATION_STEPS=
|
| 33 |
export PYTORCH_CUDA_ALLOC_CONF=expandable_segments:True
|
| 34 |
-
|
|
|
|
|
|
|
| 35 |
|
| 36 |
if [[ ! -f /workspace/data/processed/train.jsonl ]]; then
|
| 37 |
echo "train.jsonl missing — use fix-and-train.sh instead"
|
|
@@ -46,33 +51,33 @@ ln -sfn /workspace/data/processed "$DEST/data/processed"
|
|
| 46 |
apt-get update -qq && DEBIAN_FRONTEND=noninteractive apt-get install -y -qq tmux >/dev/null || true
|
| 47 |
|
| 48 |
WORKER=/workspace/logs/_train_worker.sh
|
| 49 |
-
cat > "$WORKER" <<
|
| 50 |
#!/bin/bash
|
| 51 |
set -euo pipefail
|
| 52 |
cd /workspace/scriptwriter-runpod
|
| 53 |
-
export HF_TOKEN="${HF_TOKEN:-}"
|
| 54 |
-
export HUGGING_FACE_HUB_TOKEN="${HF_TOKEN:-}"
|
| 55 |
-
export HF_HOME="${HF_HOME:-/workspace/.cache/huggingface}"
|
| 56 |
export CONFIG_PATH=/workspace/scriptwriter-runpod/config/training.yaml
|
| 57 |
-
export BASE_MODEL="${BASE_MODEL:-meta-llama/Llama-3.2-3B-Instruct}"
|
| 58 |
export OUTPUT_DIR=/workspace/models/lora
|
| 59 |
-
export HF_MODEL_REPO="${HF_MODEL_REPO:-datamatters24/scriptwriter-lora-ia}"
|
| 60 |
-
|
| 61 |
export MAX_SEQ_LENGTH=2048
|
| 62 |
export MAX_SEQ_LENGTH_CAP=2048
|
| 63 |
export PER_DEVICE_TRAIN_BATCH_SIZE=1
|
| 64 |
-
export GRADIENT_ACCUMULATION_STEPS=
|
| 65 |
export PYTORCH_CUDA_ALLOC_CONF=expandable_segments:True
|
| 66 |
-
export RESUME_FROM_CHECKPOINT=
|
|
|
|
| 67 |
exec > >(tee -a /workspace/logs/train_live.log) 2>&1
|
| 68 |
-
echo "========== TRAIN START $(date -Is) =========="
|
| 69 |
-
echo "
|
| 70 |
-
ls /workspace/models/lora/checkpoint-* 2>/dev/null | tail -5 || echo "no prior checkpoint"
|
| 71 |
nvidia-smi || true
|
| 72 |
-
|
| 73 |
-
echo "========== UPLOAD $(date -Is) =========="
|
| 74 |
-
python3 scripts/sync_hf.py upload-model --repo "$HF_MODEL_REPO" --folder /workspace/models/lora
|
| 75 |
-
echo "========== DONE $(date -Is) =========="
|
| 76 |
echo "STOP THE POD"
|
| 77 |
INNER
|
| 78 |
chmod +x "$WORKER"
|
|
@@ -80,5 +85,5 @@ chmod +x "$WORKER"
|
|
| 80 |
tmux new-session -d -s scriptwriter-train -n train "bash $WORKER"
|
| 81 |
tmux new-window -t scriptwriter-train -n monitor
|
| 82 |
tmux send-keys -t scriptwriter-train:monitor "watch -n 15 'nvidia-smi --query-gpu=index,memory.used,utilization.gpu --format=csv; echo; tail -25 /workspace/logs/train_live.log'" Enter
|
| 83 |
-
echo "Started tmux scriptwriter-train
|
| 84 |
-
echo "
|
|
|
|
| 7 |
tmux kill-server 2>/dev/null || true
|
| 8 |
pkill -9 -f 'train_runpod.py' 2>/dev/null || true
|
| 9 |
pkill -9 -f 'scripts/train_runpod' 2>/dev/null || true
|
| 10 |
+
pkill -9 -f torchrun 2>/dev/null || true
|
| 11 |
sleep 2
|
|
|
|
| 12 |
echo "Old session cleared."
|
| 13 |
|
| 14 |
DEST=/workspace/scriptwriter-runpod
|
|
|
|
| 18 |
mkdir -p "$DEST"
|
| 19 |
tar xzf "$TGZ" -C "$DEST" --strip-components=1 --no-same-owner --no-same-permissions
|
| 20 |
|
| 21 |
+
NPROC="$(python3 -c 'import torch; print(torch.cuda.device_count())' 2>/dev/null || echo 2)"
|
| 22 |
+
if [[ "${NPROC}" -lt 1 ]]; then NPROC=1; fi
|
| 23 |
+
|
| 24 |
export WORKDIR="$DEST"
|
| 25 |
export DATA_DIR=/workspace/data/processed
|
| 26 |
export OUTPUT_DIR=/workspace/models/lora
|
|
|
|
| 28 |
export HF_MODEL_REPO="${HF_MODEL_REPO:-datamatters24/scriptwriter-lora-ia}"
|
| 29 |
export BASE_MODEL="${BASE_MODEL:-meta-llama/Llama-3.2-3B-Instruct}"
|
| 30 |
export RUNPOD_SKIP_FORCE_PIP=1
|
| 31 |
+
unset CUDA_VISIBLE_DEVICES || true
|
| 32 |
export MAX_SEQ_LENGTH=2048
|
| 33 |
export MAX_SEQ_LENGTH_CAP=2048
|
| 34 |
export PER_DEVICE_TRAIN_BATCH_SIZE=1
|
| 35 |
+
export GRADIENT_ACCUMULATION_STEPS=4
|
| 36 |
export PYTORCH_CUDA_ALLOC_CONF=expandable_segments:True
|
| 37 |
+
# Fresh DDP run — old 1-GPU checkpoints won't load cleanly across 2 ranks
|
| 38 |
+
export RESUME_FROM_CHECKPOINT=0
|
| 39 |
+
export NPROC_PER_NODE="${NPROC}"
|
| 40 |
|
| 41 |
if [[ ! -f /workspace/data/processed/train.jsonl ]]; then
|
| 42 |
echo "train.jsonl missing — use fix-and-train.sh instead"
|
|
|
|
| 51 |
apt-get update -qq && DEBIAN_FRONTEND=noninteractive apt-get install -y -qq tmux >/dev/null || true
|
| 52 |
|
| 53 |
WORKER=/workspace/logs/_train_worker.sh
|
| 54 |
+
cat > "$WORKER" <<INNER
|
| 55 |
#!/bin/bash
|
| 56 |
set -euo pipefail
|
| 57 |
cd /workspace/scriptwriter-runpod
|
| 58 |
+
export HF_TOKEN="\${HF_TOKEN:-}"
|
| 59 |
+
export HUGGING_FACE_HUB_TOKEN="\${HF_TOKEN:-}"
|
| 60 |
+
export HF_HOME="\${HF_HOME:-/workspace/.cache/huggingface}"
|
| 61 |
export CONFIG_PATH=/workspace/scriptwriter-runpod/config/training.yaml
|
| 62 |
+
export BASE_MODEL="\${BASE_MODEL:-meta-llama/Llama-3.2-3B-Instruct}"
|
| 63 |
export OUTPUT_DIR=/workspace/models/lora
|
| 64 |
+
export HF_MODEL_REPO="\${HF_MODEL_REPO:-datamatters24/scriptwriter-lora-ia}"
|
| 65 |
+
unset CUDA_VISIBLE_DEVICES || true
|
| 66 |
export MAX_SEQ_LENGTH=2048
|
| 67 |
export MAX_SEQ_LENGTH_CAP=2048
|
| 68 |
export PER_DEVICE_TRAIN_BATCH_SIZE=1
|
| 69 |
+
export GRADIENT_ACCUMULATION_STEPS=4
|
| 70 |
export PYTORCH_CUDA_ALLOC_CONF=expandable_segments:True
|
| 71 |
+
export RESUME_FROM_CHECKPOINT=0
|
| 72 |
+
NPROC=${NPROC}
|
| 73 |
exec > >(tee -a /workspace/logs/train_live.log) 2>&1
|
| 74 |
+
echo "========== TRAIN START \$(date -Is) =========="
|
| 75 |
+
echo "DDP on \${NPROC} GPUs: seq=2048 batch=1/gpu accum=4"
|
|
|
|
| 76 |
nvidia-smi || true
|
| 77 |
+
torchrun --standalone --nproc_per_node=\${NPROC} scripts/train_runpod.py
|
| 78 |
+
echo "========== UPLOAD \$(date -Is) =========="
|
| 79 |
+
python3 scripts/sync_hf.py upload-model --repo "\$HF_MODEL_REPO" --folder /workspace/models/lora
|
| 80 |
+
echo "========== DONE \$(date -Is) =========="
|
| 81 |
echo "STOP THE POD"
|
| 82 |
INNER
|
| 83 |
chmod +x "$WORKER"
|
|
|
|
| 85 |
tmux new-session -d -s scriptwriter-train -n train "bash $WORKER"
|
| 86 |
tmux new-window -t scriptwriter-train -n monitor
|
| 87 |
tmux send-keys -t scriptwriter-train:monitor "watch -n 15 'nvidia-smi --query-gpu=index,memory.used,utilization.gpu --format=csv; echo; tail -25 /workspace/logs/train_live.log'" Enter
|
| 88 |
+
echo "Started tmux scriptwriter-train on ${NPROC} GPU(s) via torchrun DDP"
|
| 89 |
+
echo "Attach: tmux attach -t scriptwriter-train"
|
scriptwriter-runpod-ready.tgz
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:0c65297a24a5afce18c60ab0d70d718c3d3b220f39efe64798ed9ea011d3b638
|
| 3 |
+
size 10317
|