Skip to content

Commit 8d49e6a

Browse files
foreverlmsclaude
andauthored
Allow llava_ov SFT to start from VLM_SAFETENSORS_PATH (#45)
Mirror launch_sft_videophy2_nano.sh: when VLM_SAFETENSORS_PATH is set, plumb it to model.config.policy.backbone.safetensors_path via a tail override so llava_ov Reasoner-alignment SFT can bootstrap from a merged Cosmos3 reasoner snapshot instead of the public Qwen3-VL-8B-Instruct backbone. Unset behavior is unchanged. Update training.md accordingly. Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 3e33317 commit 8d49e6a

2 files changed

Lines changed: 34 additions & 13 deletions

File tree

docs/training.md

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ uvx hf@latest download Wan-AI/Wan2.2-TI2V-5B Wan2.2_VAE.pth \
7979

8080
<details><summary><b>Reasoner Alignment SFT with LLaVA-OneVision (vfm-vlm)</b></summary>
8181

82-
Alignment SFT for the Reasoner variant on the [lmms-lab/LLaVA-OneVision-Data](https://huggingface.co/datasets/lmms-lab/LLaVA-OneVision-Data) dataset (streamed from HF Hub). Skips Step 2: the backbone is `Qwen/Qwen3-VL-8B-Instruct` (set by the parent experiment's `vlm_policy=qwen3_vl_8b_instruct` default) and is fetched from the HF Hub by the model downloader at startup — no DCP conversion needed and no env-var plumbing required.
82+
Alignment SFT for the Reasoner variant on the [lmms-lab/LLaVA-OneVision-Data](https://huggingface.co/datasets/lmms-lab/LLaVA-OneVision-Data) dataset (streamed from HF Hub). Skips Step 2: by default the backbone `Qwen/Qwen3-VL-8B-Instruct` is fetched from the HF Hub by the model downloader at startup — no DCP conversion needed and no required env vars. To instead start from a merged Cosmos3 reasoner snapshot (Cosmos3-Nano LM merged onto the Qwen3-VL visual tower), build it with `convert_model_to_vlm_safetensors` (see [Step 2](#step-2--prepare-checkpoint)) and point `VLM_SAFETENSORS_PATH` at it — same mechanism as the VideoPhy-2 recipe below.
8383

8484
Launch shell: `examples/launch_sft_llava_ov.sh`
8585

@@ -91,6 +91,11 @@ Launch shell: `examples/launch_sft_llava_ov.sh`
9191
# (optional) HF_TOKEN raises HF Hub rate limits for the streamed dataset
9292
# revision lookup — useful if you're running 8-rank fan-out from a single IP:
9393
# export HF_TOKEN=hf_...
94+
#
95+
# (optional) VLM_SAFETENSORS_PATH starts training from a local pre-converted
96+
# Qwen3-VL safetensors snapshot (e.g. Cosmos3-Nano LM merged with the Qwen3-VL
97+
# visual tower) instead of the public HF backbone:
98+
# export VLM_SAFETENSORS_PATH=$PWD/examples/checkpoints/Cosmos3-Nano-VLM
9499
```
95100

96101
</details>
@@ -127,7 +132,7 @@ python -m cosmos_framework.scripts.convert_model_to_dcp \
127132

128133
`$BASE_CHECKPOINT_NAME` (e.g. `Cosmos3-Nano`, `Cosmos3-Super`) is a registered name in the checkpoint catalog; the converter downloads the matching repo from the Hugging Face Hub and writes the DCP into `examples/checkpoints/$BASE_CHECKPOINT_NAME`.
129134

130-
**Reasoner Alignment SFT with LLaVA-OneVision (vfm-vlm):** Skip this step — the Reasoner alignment SFT loads `Qwen/Qwen3-VL-8B-Instruct` from the HF Hub at startup (no DCP conversion, no env vars).
135+
**Reasoner Alignment SFT with LLaVA-OneVision (vfm-vlm):** Skip this step — the Reasoner alignment SFT loads `Qwen/Qwen3-VL-8B-Instruct` from the HF Hub at startup (no DCP conversion required). To start from a merged Cosmos3 reasoner snapshot instead, build one with `convert_model_to_vlm_safetensors` (see the VideoPhy-2 note below) and pass it via `VLM_SAFETENSORS_PATH`.
131136

132137
**Reasoner Alignment SFT with VideoPhy-2 (Cosmos3-Nano):** Use `cosmos_framework.scripts.convert_model_to_vlm_safetensors` instead.
133138

@@ -154,12 +159,12 @@ bash examples/launch_sft_vision_nano.sh
154159

155160
Each launcher's default paths come from the `DATASET_PATH` + `BASE_CHECKPOINT_PATH` defaults declared at the top of its `.sh` (each uses `: "${VAR:=…}"` so any value you `export` in the shell before launching wins over the default):
156161

157-
| Launch shell | Post-Training Task | Default $DATASET_PATH (under examples/data/) | Default $BASE_CHECKPOINT_PATH (under examples/checkpoints/) |
158-
| ------------------------------ | ------------------ | ---------------------------------------------------------- | ----------------------------------------------------------- |
159-
| `launch_sft_vision_nano.sh` | Generator SFT | `BridgeData2-Subset-Synthetic-Captions/sft_dataset_bridge` | `Cosmos3-Nano` |
160-
| `launch_sft_vision_super.sh` | Generator SFT | `BridgeData2-Subset-Synthetic-Captions/sft_dataset_bridge` | `Cosmos3-Super` |
161-
| `launch_sft_llava_ov.sh` | Reasoner SFT | (none; dataset streams from HF Hub) | (none; backbone fetched at startup) |
162-
| `launch_sft_videophy2_nano.sh` | Reasoner SFT | (none; set `VIDEOPHYSICS_ROOT` env) | (none; set `VLM_SAFETENSORS_PATH` env) |
162+
| Launch shell | Post-Training Task | Default $DATASET_PATH (under examples/data/) | Default $BASE_CHECKPOINT_PATH (under examples/checkpoints/) |
163+
| ------------------------------ | ------------------ | ---------------------------------------------------------- | ------------------------------------------------------------------ |
164+
| `launch_sft_vision_nano.sh` | Generator SFT | `BridgeData2-Subset-Synthetic-Captions/sft_dataset_bridge` | `Cosmos3-Nano` |
165+
| `launch_sft_vision_super.sh` | Generator SFT | `BridgeData2-Subset-Synthetic-Captions/sft_dataset_bridge` | `Cosmos3-Super` |
166+
| `launch_sft_llava_ov.sh` | Reasoner SFT | (none; dataset streams from HF Hub) | (none; backbone fetched at startup, or set `VLM_SAFETENSORS_PATH`) |
167+
| `launch_sft_videophy2_nano.sh` | Reasoner SFT | (none; set `VIDEOPHYSICS_ROOT` env) | (none; set `VLM_SAFETENSORS_PATH` env) |
163168

164169
`WAN_VAE_PATH` defaults to `examples/checkpoints/wan22_vae/Wan2.2_VAE.pth` for every non-reasoner recipe.
165170

examples/launch_sft_llava_ov.sh

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,32 @@
1010
# [job].task = "vlm" — picks cosmos_framework/configs/base/vlm/config.py as the base config.
1111
#
1212
# The dataset streams from the HuggingFace Hub, so DATASET_PATH /
13-
# WAN_VAE_PATH / BASE_CHECKPOINT_PATH are NOT required; only HF_TOKEN may
14-
# be needed for gated tokenizer downloads. Two model knobs that the
15-
# SFTExperimentConfig dataclass does not model live in TAIL_OVERRIDES:
13+
# WAN_VAE_PATH / BASE_CHECKPOINT_PATH are NOT required.
1614
#
17-
# model.config.policy.backbone.model_name=<HF or local path>
18-
# data_setting.max_tokens=<int>
15+
# Optional env:
16+
# HF_TOKEN for gated Qwen3-VL-8B-Instruct downloads.
17+
# VLM_SAFETENSORS_PATH local directory of pre-converted Qwen3-VL safetensors
18+
# (e.g. a Cosmos3-Nano LM merged with Qwen3-VL visual via
19+
# `cosmos_framework.scripts.convert_model_to_vlm_safetensors`).
20+
# When set, plumbed to backbone.safetensors_path via a
21+
# tail override. When unset, the framework falls back
22+
# to the public Qwen/Qwen3-VL-8B-Instruct HF snapshot.
1923
#
2024
# Usage (8-GPU allocation, inside the training container, from the repo root):
2125
# bash examples/launch_sft_llava_ov.sh
2226

2327
TOML_FILE="examples/toml/sft_config/llava_ov.toml"
2428

29+
TAIL_OVERRIDES=(
30+
${EXTRA_TAIL_OVERRIDES:-}
31+
)
32+
33+
# When VLM_SAFETENSORS_PATH is set, plumb it to backbone.safetensors_path so the
34+
# framework loads weights from the local snapshot (e.g. a Cosmos3-Nano LM merged
35+
# with Qwen3-VL visual via `cosmos_framework.scripts.convert_model_to_vlm_safetensors`)
36+
# while keeping the public HF model_name for tokenizer/architecture discovery.
37+
if [[ -n "${VLM_SAFETENSORS_PATH:-}" ]]; then
38+
TAIL_OVERRIDES+=("model.config.policy.backbone.safetensors_path=$VLM_SAFETENSORS_PATH")
39+
fi
40+
2541
source "$(dirname "${BASH_SOURCE[0]}")/_sft_launcher_common.sh"

0 commit comments

Comments
 (0)