ilovesora2/opensora-v21 / job /entrypoint.sh
ilovesora2's picture
download
raw
2.82 kB
#!/usr/bin/env bash
set -euo pipefail
export PYTHONUNBUFFERED=1
export TOKENIZERS_PARALLELISM=false
WORK=/workspace/Open-Sora
OUT=/training-outputs
BASE=/base-model
DATA=/data
mkdir -p "$OUT/checkpoints" "$OUT/logs" "$OUT/reference_encoder" "$OUT/release"
if [[ ! -d "$WORK" ]]; then
git clone --depth 1 https://github.com/hpcaitech/Open-Sora.git "$WORK"
fi
cd "$WORK"
python -m pip install -v .
python -m pip install git+https://github.com/hpcaitech/TensorNVMe.git pandarallel
mkdir -p ckpts/google ckpts/openai
ln -sfn "$BASE/Open_Sora_v2.safetensors" ckpts/Open_Sora_v2.safetensors
ln -sfn "$BASE/hunyuan_vae.safetensors" ckpts/hunyuan_vae.safetensors
ln -sfn /ckpts/google/t5-v1_1-xxl ckpts/google/t5-v1_1-xxl
ln -sfn /ckpts/openai/clip-vit-large-patch14 ckpts/openai/clip-vit-large-patch14
python /workspace/training/scripts/validate_manifest.py \
--csv "$DATA/train.csv" \
--video-root "$DATA/videos" \
--limit 500
# Real Open-Sora v2 stage-1 I2V fine-tuning.
# Upstream documents stage1_i2v.py as the joint T2V/I2V 256px stage.
EXPERIMENT="opensora-v21-stage1-i2v"
ARGS=(
configs/diffusion/train/stage1_i2v.py
--dataset.data-path "$DATA/train.csv"
--model.from_pretrained ckpts/Open_Sora_v2.safetensors
--wandb False
--async-io True
--outputs "$OUT/checkpoints"
--exp_name "$EXPERIMENT"
--ckpt_every 500
--keep_n_latest 3
)
LATEST_CKPT="$(find "$OUT/checkpoints" -type d -name "*global_step*" 2>/dev/null | sort | tail -n1 || true)"
if [[ -n "$LATEST_CKPT" ]]; then
echo "Resuming from $LATEST_CKPT"
ARGS+=(--load "$LATEST_CKPT")
fi
torchrun \
--nproc_per_node=8 \
--master_port=29501 \
scripts/diffusion/train.py \
"${ARGS[@]}" \
2>&1 | tee "$OUT/logs/video-training.log"
# Train the real-video reference adapter.
python /workspace/training/reference/train_reference_encoder.py \
--csv "$DATA/train.csv" \
--video-root "$DATA/videos" \
--output "$OUT/reference_encoder/reference_encoder.safetensors" \
--steps 10000 \
--lr 1e-5 \
2>&1 | tee "$OUT/logs/reference-training.log"
# Preserve configs/manifests and a machine-readable release manifest.
cp /workspace/training/configs/train_v21.yaml "$OUT/release/train_v21.yaml"
cat > "$OUT/release/model_card_metadata.json" <<JSON
{
"model": "creuthecat/Open-Sora-v2.1",
"base_model": "hpcai-tech/Open-Sora-v2",
"training": "real video fine-tuning",
"stage": "stage1_i2v",
"reference_adapter": "trained from real video first frames",
"storage_bucket": "creuthecat/opensora-v21",
"warning": "Reference encoder is an adapter artifact; it requires integration into the v2.1 inference stack."
}
JSON
# Keep the generated artifacts in the persistent bucket. The model repo is
# intentionally not modified automatically by this job.
echo "Cloud training finished. Persistent outputs: $OUT"

Xet Storage Details

Size:
2.82 kB
·
Xet hash:
17bb674478fd7536ffd6abfece60dd783b9bdec13d842d288dbb2eb4a63b7311

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.