跳到正文
FunCoding

cosmos3-post-train-simulation-transfer

官方

Post-train Cosmos3-Nano-Sim-Transfer on Cosmos Framework: build a local bundle of aligned control, RGB and caption data, convert the pinned Cosmos3-Nano weights to DCP, train Stage 0 (bidirectional teacher) from them and Stages 1 to 3 (teacher forcing, four-step distillation, self-forcing) from your own EMA checkpoints with cosmos_framework.scripts.train_experiment under torchrun on eight GPUs, resume full-state checkpoints and run inference from your Stage 3 checkpoint. Use when the user asks "train Sim-Transfer on my data", "run Sim-Transfer Stage 0 to 3", "distill Sim-Transfer to four steps", "resume Sim-Transfer training" or "run inference with my trained Sim-Transfer checkpoint". Not for inference with the released checkpoint (cosmos3-inference-simulation-transfer), Generator or Reasoner supervised fine-tuning (cosmos3-post-training), or the Auto and Sim-Bimanual models (start at cosmos3-post-train-simulation).

Star
674
最近提交
2026年11月30日

.agents/skills/cosmos3-post-train-simulation-transfer/SKILL.md

在 GitHub 上查看

Post-train Cosmos3-Nano-Sim-Transfer

Cosmos3-Nano-Sim-Transfer generates RGB video from a spatial-control clip and a caption. Controls can be edge, blur, depth or segmentation. Train on aligned control/RGB clips and captions with Cosmos Framework. Start at Stage 0 with compatible base regular weights, then pass your selected EMA outputs through teacher forcing, four-step distillation and self-forcing.

Prepare aligned spatial controls, RGB targets and captions for Cosmos3-Nano-Sim-Transfer; run native Cosmos Framework Stage 0–3 training with local assets; resume full-state checkpoints; pass selected EMA to inference.

When to use this skill

  • Use to train your own Cosmos3-Nano-Sim-Transfer chain on Cosmos Framework: prepare the local training bundle, convert the pinned Cosmos3-Nano weights, run Stages 0 to 3 on eight GPUs, resume a stage from its full-state checkpoint, and run inference from your Stage 3 checkpoint.
  • Not for inference with the released checkpoint, see the Sim-Transfer inference skill; not for Generator or Reasoner supervised fine-tuning, see ../cosmos3-post-training/SKILL.md.

Choose your starting point

GoalStart withFollow
Start a new training chainCompatible base regular weights and a prepared local bundleStage 0 Quickstart
Continue your training chainYour completed stage checkpoints and saved configurationContinue training
Generate RGB videoMatched release checkpoint or your selected Stage 3 student EMAInference

Prerequisites

Framework checkout and environment: ../cosmos3-setup/SKILL.md. Sim-Transfer training adds the environment setup below and the requirements that these references state:

  • Training resources, references/local-training.md, section "Plan training resources": "For the example2 configuration, the resource-planning reference is eight H200 GPUs with roughly 140 GB of device memory each and approximately 126 GB per GPU at the Stage 3 peak." "Keeping both checkpoints from all four stages requires roughly 1.6 TB of output space."
  • Nano conversion, references/nano-conversion.md: "Conversion runs on CPU. Allocate 160 GiB of host memory and disk space for the Nano source, auxiliary cache and converted output."
  • Tokenizer compilation, references/environment.md: "Compute hosts need nvcc, CUDA runtime/CRT/CCCL headers, a C++ compiler and a valid CUDA_HOME."

Set up the environment

Export FRAMEWORK_DIR as the absolute Framework checkout root and SIM_TRANSFER_SKILL as the absolute location of this skill bundle. Follow the Sim-Transfer setup guide to prepare Python 3.13 and CUDA in the Framework checkout containing this skill. Run training commands from FRAMEWORK_DIR.

Skill note (not in the source): "this skill bundle" in the sentence above was the folder of the Sim-Transfer skill family in the source. The setup guide sets SIM_TRANSFER_SKILL to the Sim-Transfer inference skill folder (.agents/skills/cosmos3-inference-simulation-transfer under FRAMEWORK_DIR), which holds the sample-preparation script; keep that value, not the folder of this skill. The commands of this skill address its own scripts (scripts/qa_transfer_stage.py, scripts/prepare_nano_dcp.py and scripts/paibench_local_bundle.py) from FRAMEWORK_DIR, under .agents/skills/cosmos3-post-train-simulation-transfer.

# Skill note (not in the source): the setup guide's block for an existing checkout, from its first line to its install line, without the clone. "Activate the Framework environment" below holds the activation and the other exports of that guide.
export FRAMEWORK_DIR="${FRAMEWORK_DIR:?set it to the absolute root of the existing Framework checkout}"
export SIM_TRANSFER_SKILL="$FRAMEWORK_DIR/.agents/skills/cosmos3-inference-simulation-transfer"
cd "$FRAMEWORK_DIR"
uvx --from uv==0.11.29 uv sync --locked --python 3.13 --all-extras --group cu130-train

Skill note (not in the source): measured in four runs on H100 NVL GPUs with NVIDIA driver 615.71.10, for which nvidia-smi reports CUDA UMD Version: 13.4. In the environment that the block above installs (three runs), every step of this Quickstart up to the Stage 0 dry run runs. In the environment of --group cu128-train with the same driver (one run), bundle preparation stops with RuntimeError: cudart shared object not found.; it runs once nvidia/cudart and nvidia/cuda_cudart are linked to nvidia/cuda_runtime in the site-packages of that environment. No other driver is measured.

Quickstart: train Stage 0

Activate the Framework environment

The native entry point is cosmos_framework.scripts.train_experiment; the native local config is cosmos_framework/configs/simulation/local.py.

Activate the prepared environment from the Framework root:

export FRAMEWORK_DIR="${FRAMEWORK_DIR:?Set the absolute Framework checkout root}"
: "${SIM_TRANSFER_SKILL:?Set the absolute skill bundle location}"
cd "$FRAMEWORK_DIR"
source .venv/bin/activate
export COSMOS_INTERNAL=0 COSMOS_TRAINING=1 COSMOS_SMOKE=0
export COSMOS_DEVICE=cuda WANDB_MODE=disabled
export OMP_NUM_THREADS=1 TOKENIZERS_PARALLELISM=false

Prepare the training data

  1. Split complete recordings into train/validation before constructing windows. Preserve camera, source FPS, dimensions, frame counts and sample identity.
  2. Prepare aligned RGB, depth and segmentation. Edge and blur are derived from resized RGB. Use equal weights for the four controls.
  3. Review each structured caption and its nonempty temporal_caption against first, middle and last RGB frames. Retained captions use the same-window 93% structured / 7% dense mixture. See caption preparation.
  4. Follow the data contract and local bundle layout. Inspect aligned decoded controls, RGB and packed tensors. Normalize pixels to pixels / 127.5 - 1; a 121-frame clip becomes 31 temporal latents. Reject aspect distortion above 3%.
  5. Bind local video VAE, Nano text tokenizer and completed DCP roots with the local training walkthrough. Stage 0 also initializes its inherited audio tokenizer and needs both audio assets.

Use Hugging Face example2 for this workflow. Download its RGB, depth, segmentation, short prompt and structured caption, then follow bundle preparation to create the training manifest and add the tokenizer.

Select a stage

StageNative local experimentInitial weights
0, bidirectional teachersim_local_transfer_stage0_bidirCompatible base regular weights
1, teacher forcingsim_local_transfer_stage1_tfYour Stage 0 EMA
2, TF-dCMsim_local_transfer_stage2_tfdcmYour Stage 1 EMA for student and frozen teacher
3, SF-DMDsim_local_transferYour Stage 2 EMA for student; your Stage 0 EMA for teacher and score model

1. Bind local resources

Complete bundle preparation and Nano conversion first. These workflows set SIM_TRANSFER_TRAINING_BUNDLE, NANO_HF_DIR, VIDEO_VAE_PATH and BASE_CKPT_ROOT. Stage 0 also uses the audio assets derived during conversion. Set IMAGINAIRE_OUTPUT_ROOT to a writable directory. All model, data and output paths must resolve identically on every training rank.

Skill note (not in the source): the block below and the block of "2. Resolve Stage 0" are one shell session. The block below reads FRAMEWORK_DIR, SIM_TRANSFER_TRAINING_BUNDLE, NANO_HF_DIR, VIDEO_VAE_PATH, BASE_CKPT_ROOT and IMAGINAIRE_OUTPUT_ROOT, and it sets TRANSFER_BUNDLE_PATH, the two audio paths, RUN_ID, STAGE_HELPER and ARGS_FILE for the block of "2. Resolve Stage 0". None of these exists in a new shell. Where each command starts a new shell, write one file that exports those six variables and SIM_TRANSFER_SKILL, then holds the blocks of "Activate the Framework environment", of this section and of "2. Resolve Stage 0", unchanged and in this order, and run it with bash: it exits with status 0 (measured). With the exports typed by hand in place of the block below, the stage helper stops with Local Transfer argument binding failed: Set TRANSFER_BUNDLE_PATH; see references/local-training.md. (measured).

set -euo pipefail
export TRANSFER_BUNDLE_PATH="${SIM_TRANSFER_TRAINING_BUNDLE:?Prepare the example2 training bundle first}"
export NANO_HF_DIR="${NANO_HF_DIR:?Complete the HF Nano download and conversion first}"
export VIDEO_VAE_PATH="${VIDEO_VAE_PATH:?Complete the HF video VAE download first}"
export AUDIO_VAE_PATH="$NANO_HF_DIR/sound_tokenizer/avae_48k_noncausal_25hz_64ch.ckpt"
export AUDIO_VAE_CONFIG_PATH="$NANO_HF_DIR/sound_tokenizer/avae_48k_noncausal_25hz_64ch.json"
export BASE_CKPT_ROOT="${BASE_CKPT_ROOT:?Set the converted base DCP root}"
export TRANSFER_QA_BASE_MODEL_ONLY=1
export IMAGINAIRE_OUTPUT_ROOT="${IMAGINAIRE_OUTPUT_ROOT:?Set the writable output directory shared by all ranks}"
mkdir -p "$IMAGINAIRE_OUTPUT_ROOT"
RUN_ID="local_example2_$(date -u +%Y%m%dT%H%M%SZ)"
# Skill note (not in the source): SIM_TRANSFER_SKILL is the Sim-Transfer inference skill folder, so this script, which is in the scripts folder of this skill, is addressed from FRAMEWORK_DIR. The source path was "$SIM_TRANSFER_SKILL/post-training/scripts/qa_transfer_stage.py".
STAGE_HELPER="$FRAMEWORK_DIR/.agents/skills/cosmos3-post-train-simulation-transfer/scripts/qa_transfer_stage.py"
ARGS_FILE="$IMAGINAIRE_OUTPUT_ROOT/${RUN_ID}.args"

Use TRANSFER_QA_BASE_MODEL_ONLY=1 only when the converted base lacks EMA; use 0 when it already contains EMA. Regular-weight loading remains strict. The native same-job resume restores full state. Keep RUN_ID and resource bindings unchanged while resuming; generating a new ID starts a different run.

2. Resolve Stage 0

The argument helper binds local assets and checkpoints to the native recipe. This example saves every six iterations and resumes to iteration 12. Select Stage 0 for a new chain and capture its arguments:

stage=0
python "$STAGE_HELPER" --stage "$stage" > "$ARGS_FILE"
mapfile -t STAGE_ARGS < "$ARGS_FILE"
ARGS=(
  "${STAGE_ARGS[@]}"
  job.project=cosmos3_sim_transfer
  job.group=local
  job.wandb_mode=disabled
  "job.name=${RUN_ID}_stage${stage}"
  checkpoint.save_iter=6
  checkpoint.dcp_async_mode_enabled=False
  trainer.logging_iter=1
)
python -m cosmos_framework.scripts.train_experiment \
  --dryrun "${ARGS[@]}" trainer.max_iter=6

Skill note (not in the source): documented result of the Stage 0 command above (measured, four of four): exit status 0 and the output below, which ends with the path of the config.yaml that the command writes. The two log lines at level ERROR belong to this output: cosmos_framework/scripts/train_experiment.py calls to_yaml, logs these two lines when to_yaml raises, writes config.yaml with LazyConfig.save_yaml and prints its path. The step is complete with this output: the stage helper, its arguments and the Framework sources stay unchanged, and the dry run is not repeated. The dry runs of Stages 1 to 3 are not measured.

<time> | ERROR    | __main__:main:258 - to_yaml failed, falling back to LazyConfig.save_yaml:
<time> | ERROR    | __main__:main:259 - Traceback: Traceback (most recent call last):
  ...
omegaconf.errors.ConfigKeyError: Key 'restart_data_iterator_on_handoff' is not in struct
    full_key: dataloader_train.restart_data_iterator_on_handoff
    object_type=dict

Config is saved using omegaconf at <IMAGINAIRE_OUTPUT_ROOT>/cosmos3_sim_transfer/local/<RUN_ID>_stage0/config.yaml.
<IMAGINAIRE_OUTPUT_ROOT>/cosmos3_sim_transfer/local/<RUN_ID>_stage0/config.yaml

Inspect config.yaml under $IMAGINAIRE_OUTPUT_ROOT/cosmos3_sim_transfer/local/${RUN_ID}_stage0/ for your local assets, base checkpoint and stage settings. A dry run does not construct weights or loaders. This short walkthrough uses synchronous saving to avoid the additional shared, pinned-memory staging allocation. It preserves the full-state checkpoint format. See checkpoint memory when enabling asynchronous saving.

3. Train, save and resume

Use an existing eight-GPU allocation sized for the training resource requirements. For two four-GPU nodes, use the multi-node launcher instead of the single-node TRAIN array below.

TRAIN=(torchrun --standalone --nproc_per_node=8 -m cosmos_framework.scripts.train_experiment)
"${TRAIN[@]}" "${ARGS[@]}" trainer.max_iter=6
"${TRAIN[@]}" "${ARGS[@]}" trainer.max_iter=12
stage_checkpoint="$IMAGINAIRE_OUTPUT_ROOT/cosmos3_sim_transfer/local/${RUN_ID}_stage${stage}/checkpoints/iter_000000012"
test -f "$stage_checkpoint/model/.metadata"

The second launch resumes the same run from iteration 6 and continues to the absolute endpoint 12. trainer.max_iter is the total iteration limit, including restored iterations. The full-state checkpoint includes weights, optimizer, scheduler, trainer and local-loader state. Wait for checkpoint writes to finish before using the output in the next stage.

Continue training

After Stage 0 succeeds, export its exact output:

export STAGE0_CKPT_ROOT="$stage_checkpoint"

Change stage=0 to stage=1 in step 2 and repeat argument preparation and the two launches, keeping the chain's RUN_ID. After Stage 1, export STAGE1_CKPT_ROOT="$stage_checkpoint"; after Stage 2, export STAGE2_CKPT_ROOT="$stage_checkpoint". Select stages 2 and 3 in the same way. The complete walkthrough provides a loop for all four stages. Each stage uses a new run name and fresh optimization state; same-stage resume retains the run name and output root.

The example uses six fresh and six resumed iterations per stage. For your dataset, choose training durations and checkpoints using held-out outputs. The method reference lists the full recipe defaults, and the parameter guide explains settings you can tune.

Stage 0 uses mixed 480/720 streams. Stages 1–3 use 480. Text dropout is 0.1 in Stages 0–2 and 0 in Stage 3. These stage settings override the bundle's transform policy. The native recipes use eight GPU processes and one latent per causal chunk. Stages 2–3 use teacher guidance 3. Stage 3 uses equal-length rollouts, alternates five score-model updates with one student update, and saves both optimizer states.

Resume and hand off

Keep the same run identity, bundle, topology and parent artifacts when resuming. See checkpoint and resume for full-state requirements and explicit checkpoint selection.

Pass your selected Stage 3 student EMA and resolved configuration to the inference Skill, together with the tokenizer/VAE, preprocessing, caption policy and sampling settings. Retain the full checkpoint for further training.

Run inference from your trained checkpoint

Skill note (not in the source): this section is the Stage 3 DCP route of the Sim-Transfer inference skill, moved here because its block reads variables of the training shell. In the source it follows the Hugging Face download block of 1. Select the matched inference checkpoint, which defines SIM_TRANSFER_RESOURCE_OVERRIDES ("the HF resource overrides") and the checkpoint argument array that the block below replaces, and it precedes 2. Prepare the example2 controls and prompt and the generation commands of that skill.

For a Stage 3 DCP produced by the training walkthrough, replace only the checkpoint argument array below. Keep the HF resource overrides:

: "${SIM_TRANSFER_DCP_ROOT:?Select a completed Stage 3 checkpoint from your training run}"
export COSMOS_SIM_TRANSFER_STAGE0_CHECKPOINT="${STAGE0_CKPT_ROOT:?Use the Stage 0 parent from the training walkthrough}"
export COSMOS_SIM_TRANSFER_STAGE2_CHECKPOINT="${STAGE2_CKPT_ROOT:?Use the Stage 2 parent from the training walkthrough}"
export COSMOS_SIM_TRANSFER_LOCAL_BUNDLE="${SIM_TRANSFER_TRAINING_BUNDLE:?Use the prepared example2 training bundle}"
SIM_TRANSFER_CHECKPOINT_ARGS=(
  --checkpoint-path "$SIM_TRANSFER_DCP_ROOT"
  --config-file cosmos_framework/configs/simulation/local.py
  --experiment sim_local_transfer
  --credential-path ""
  --use-ema-weights
)

Framework resolves the recipe before loading a native checkpoint, so retain its parent-checkpoint and prepared-bundle bindings. Inference then skips training loaders, parent initialization and teacher/score-model construction. The native route selects EMA from the checkpoint's model/ child. Earlier stages use their own inference profiles.

Skill note (not in the source): the block below adds one override for this route. Framework inference sets the key _auto_camera_fps on the model configuration of every checkpoint it loads; here that configuration comes from the recipe (--config-file with --experiment), which does not declare the key. In a Framework checkout without attach_auto_camera_fps in cosmos_framework/inference/common/auto_fps.py, the run stops before generation with Key '_auto_camera_fps' not in 'SelfForcingDMDConfig' unless the override adds the key (measured on H200 GPUs with a Stage 3 checkpoint of the training walkthrough: the run stops without the override and completes with +model.config._auto_camera_fps=null). In a checkout with that function, Framework adds the key itself and the run completes without the override (measured with a second Stage 3 checkpoint and the depth request). There the override is redundant: ++ adds the key the same way as + and replaces it where it already exists, and Framework then sets the value. Not measured on GPUs: the ++ form together with that function. Run the block after the Hugging Face block of 1. Select the matched inference checkpoint, in the same shell, and for this route only: the release directory is loaded with its own config.json and needs no such override.

: "${SIM_TRANSFER_RESOURCE_OVERRIDES:?Run the Hugging Face block of step 1 of the Sim-Transfer inference skill in this shell first}" &&
  SIM_TRANSFER_RESOURCE_OVERRIDES+=("++model.config._auto_camera_fps=null")

Troubleshooting

Start with references/troubleshooting.md: the training-state symptoms (full-state resume against a new warm start, a run that restarts at an old iteration, parent bindings, nonfinite loss) and their failure table. Setup, model-loading, media and inference symptoms are in the Sim-Transfer inference skill's troubleshooting reference, and the environment diagnostics in its environment reference. For CUDA, import and container failures that are not specific to this model, use ../cosmos3-env-troubleshoot/SKILL.md.

Reference files

FileRead it when
references/local-training.mdYou run all four stages in one loop, plan training resources or need the local overrides the helper passes
references/local-dataset.mdYou build the example2 training bundle or prepare a bundle from your own clips
references/data-contract.mdYou collect and align control videos, RGB and captions for a new dataset
references/caption-manifest.mdYou need a generic video-caption JSONL manifest for a loader other than the local Sim-Transfer bundle
references/nano-conversion.mdYou convert the pinned Cosmos3-Nano weights to the DCP that Stage 0 starts from
references/environment.mdYou set up tokenizer compilation on the compute hosts
references/multinode-training.mdThe eight training processes span two four-GPU nodes
references/canonical-recipe.mdYou need the training method, the full recipe defaults of each stage or the inference profile of an earlier stage
references/parameter-guide.mdYou change data, conditioning, optimization or execution settings
references/checkpoint-and-resume.mdYou bind stage parents, resume, rewind, size checkpoint memory or pass the selected model to inference
references/troubleshooting.mdA restart loads the wrong state or training fails
scripts/qa_transfer_stage.pyCalled by the stage commands: prints the native training arguments with local assets and stage parents
scripts/prepare_nano_dcp.pyCalled by Nano conversion: checks the converter, downloads and converts the pinned snapshot, verifies receipts
scripts/paibench_local_bundle.pyCalled by bundle preparation: builds a structured-caption bundle (prepare-custom) and validates one

The reference list of the source skill, carried over:

SkillWhen to use
../cosmos3-post-train-simulation/SKILL.mdEntry skill of the Simulation post-training row: routes to the Auto, Sim-Bimanual and Sim-Transfer block skills
../cosmos3-inference-simulation-transfer/SKILL.mdInference with the released Sim-Transfer checkpoint; setup, example data and captioning
../cosmos3-setup/SKILL.mdFramework checkout and environment
../cosmos3-env-troubleshoot/SKILL.mdCUDA, import and container failures
../cosmos3-post-training/SKILL.mdGenerator and Reasoner supervised fine-tuning

相似的 Skill

blender-motion-state-inspection

AFaffaan-m/ECC314k近 7 天新增 4,125 个 star

官方

slack-gif-creator

ANanthropics/skills203k近 7 天新增 3,333 个 star

精选

algorithmic-art

用 p5.js 生成流场和粒子系统,通过种子随机性创作原创算法艺术。

ANanthropics/skills203k近 7 天新增 3,333 个 star

moneyprinterturbo-video

HAharry0703/MoneyPrinterTurbo147k近 7 天新增 1,663 个 star

thinking-out-loud

SHShubhamsaboo/awesome-llm-apps146k近 7 天新增 895 个 star

design-motion

GAgarrytan/gstack143k近 7 天新增 636 个 star