-
Notifications
You must be signed in to change notification settings - Fork 774
Expand file tree
/
Copy pathlaunch_sft_vision_nano.sh
More file actions
45 lines (38 loc) · 2.21 KB
/
Copy pathlaunch_sft_vision_nano.sh
File metadata and controls
45 lines (38 loc) · 2.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#!/usr/bin/env bash
# SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-License-Identifier: OpenMDW-1.1
# Complete recipe: Vision SFT on Cosmos3-Nano (T2V / I2V / V2V, 8x H100).
# Run from this folder with the cosmos-framework venv active (see README):
# bash launch_sft_vision_nano.sh
# It downloads the data, prepares the base checkpoint, and trains — in order.
# Paths are fixed under this folder; edit them below to relocate.
set -euo pipefail
cd "$(dirname "${BASH_SOURCE[0]}")"
DATASET_DIR="$PWD/data/BridgeData2-Subset-Synthetic-Captions"
CHECKPOINT_DIR="$PWD/checkpoints/Cosmos3-Nano"
VAE_PATH="$PWD/checkpoints/wan22_vae/Wan2.2_VAE.pth"
# 1. Download the SFT dataset (skipped if present; license-gated — accept terms + 'uvx hf@latest auth login').
if [[ ! -f "$DATASET_DIR/sft_dataset_bridge/train/video_dataset_file.jsonl" ]]; then
uvx hf@latest download --repo-type dataset nvidia/BridgeData2-Subset-Synthetic-Captions \
--revision 40d018ac1c1a2a4b9734f17fdb21f3d933c49a01 --local-dir "$DATASET_DIR"
fi
# 2. Download the Wan2.2 VAE (skipped if present).
if [[ ! -f "$VAE_PATH" ]]; then
uvx hf@latest download Wan-AI/Wan2.2-TI2V-5B Wan2.2_VAE.pth --local-dir "$(dirname "$VAE_PATH")"
fi
# 3. Convert the base checkpoint to DCP (skipped if present).
if [[ ! -d "$CHECKPOINT_DIR" ]]; then
python -m cosmos_framework.scripts.convert_model_to_dcp -o "$CHECKPOINT_DIR" --checkpoint-path Cosmos3-Nano
fi
# 4. Train (8-GPU FSDP). The TOML reads these three paths from the environment.
export DATASET_PATH="$DATASET_DIR/sft_dataset_bridge"
export BASE_CHECKPOINT_PATH="$CHECKPOINT_DIR"
export WAN_VAE_PATH="$VAE_PATH"
# The model configs reference their packaged JSONs relative to the framework
# root, so run torchrun from there (recipe paths stay pinned to this folder).
TOML_PATH="$PWD/toml/sft_config/vision_sft_nano.toml"
OUTPUT_ROOT="$PWD/outputs/train"
cd "$(python -c 'import pathlib, cosmos_framework; print(pathlib.Path(cosmos_framework.__file__).resolve().parents[1])')"
# On a 4-GPU node (e.g. GB200x4), set --nproc_per_node=4 instead.
IMAGINAIRE_OUTPUT_ROOT="$OUTPUT_ROOT" torchrun --nproc_per_node=8 \
-m cosmos_framework.scripts.train --sft-toml="$TOML_PATH"