Skip to content

About

Cosmos3-H-Embodied-Nano

Resources

Contributing

Security policy

Stars

6 stars

Watchers

0 watching

Forks

Repository files navigation

Cosmos3-H-Embodied-Nano

Cosmos3-H-Embodied-Nano is Cosmos3-Nano (16B) post-trained for surgical robotics on the Open-H Embodiment dataset. One model predicts robot actions and endoscopic video for dVRK-style and other surgical robots: it is a world model (forward dynamics), a policy and an inverse-dynamics model in one checkpoint. Its predecessor, Cosmos-H-Surgical-Simulator, is a world model only.

This repository contains everything needed to use and adapt it, built as a plugin package (cosmos3_h_embodied) on an unmodified cosmos-framework:

  • data loading for Open-H (and your own LeRobot data) with the H16 action history;
  • scripts that rebuild the training data from the Hugging Face dataset;
  • the training recipe of the released checkpoint, to fine-tune it further;
  • dataset-driven evaluation and an HTTP policy server.

The model

One model handles three tasks on 2.4 s clips (25 frames and 24 actions at 10 Hz, 256-pixel resolution tier):

Mode Input Output
Forward dynamics first frame, actions video
Inverse dynamics video actions
Policy (wam in cosmos-framework) first frame, text, action history actions and video
  • Actions. Per arm and step: the end-effector pose relative to the current pose (translation as a world-frame offset, rotation in the current pose's frame as a 6D representation) and the gripper command, 20 values for a two-arm robot, zero-padded to 64. Each dataset family is normalized with its own statistics (1st/99th percentiles to [-1, 1]); an embodiment ID selects the action input and output projections. See cosmos3_h_embodied/README_ACTION_SPACE.md for the full action space design.
  • Action history. Up to 16 past action steps, relative to the current pose like the future ones, are given to the model as clean conditioning. At episode boundaries the history is shorter.
  • Text. The task instruction, prefixed with a short description of the robot and setting for each dataset.
  • Training. 50,000 iterations on 15 dataset families (55 dataset roots; 11 families are on Hugging Face), with the three modes mixed 0.4 / 0.2 / 0.4, on 32 GPUs. The last 3,063 iterations used the H16 recipe in this repository; the earlier ones an Open-H recipe without action history (see training history).

Released weights: nvidia/Cosmos3-H-Embodied-Nano on Hugging Face, file checkpoints/h16_50000/c3-h-e-n_model_bf16.safetensors (the network weights in bf16).

Install

  1. Install cosmos-framework following its instructions (uv sync ...). This package was validated against revision 7cfaf78 (git checkout 7cfaf7854b2114eda5deb36250a7e8f00c64d69e).
  2. With that environment activated (source <cosmos-framework>/.venv/bin/activate), from this repository's root: uv pip install -e . (the uv environment has no pip of its own).

All commands below run from this repository's root with the cosmos-framework environment active.

Convert the released weights to a DCP checkpoint once; cosmos-framework loads checkpoints in this format:

python tools/convert_checkpoint_to_dcp.py --checkpoint c3-h-e-n_model_bf16.safetensors -o <ckpt_dcp>

<ckpt_dcp>/model is used for evaluation and serving; <ckpt_dcp> is the training checkpoint.load_path.

The first evaluation or serving run downloads the VAE and the text tokenizer from Hugging Face. The datasets switch the hub to offline mode (HF_HUB_OFFLINE=1) unless the variable is set, so start the first run with HF_HUB_OFFLINE=0.

Serve a policy

python -m cosmos_framework.scripts.export_config -o h16.yaml \
    --config-file cosmos3_h_embodied/configs/config.py --experiment openh_h16_task_prompt
python -m cosmos3_h_embodied.scripts.policy_server \
    --checkpoint-path <ckpt_dcp>/model --config-file h16.yaml \
    --normalizer dvrk_hamlyn_backward_anchored_worldtrans_rot6d_wxyz_c24_20260910.json \
    --domain-name hamlyn --port 8000

POST /predict takes the current frame, the caption and up to 16 past actions (normalized); it returns 24 actions (denormalized) and the predicted video. With "mode": "forward_dynamics" and 24 normalized "action" rows it returns the video for those actions instead. The request format is described in the module docstring of cosmos3_h_embodied/scripts/policy_server.py. --normalizer and --domain-name select the action statistics and the embodiment (see Fine-tune on your own data).

Simulate

scripts/simulate.py rolls the model out from a start frame, chunk by chunk (each 2.4 s chunk starts from the last generated frame): forward dynamics generates the video for an action trajectory, --mode policy --num-chunks N lets the policy act in the generated scene.

python -m cosmos3_h_embodied.scripts.simulate --no-guardrails \
    --checkpoint-path <ckpt_dcp>/model --config-file cosmos3_h_embodied/configs/config.py \
    --experiment openh_h16_task_prompt --num-steps 35 --guidance 6.0 --seed 0 \
    --image frame.png --actions actions.npy --history history.npy \
    --normalizer dvrk_hamlyn_backward_anchored_worldtrans_rot6d_wxyz_c24_20260910.json \
    --caption "<caption>" --embodiment hamlyn -o outputs/simulate

Actions are in the model's representation (action space): [K, 24, D], each chunk relative to the pose at its start; --history holds up to 16 past actions of the first chunk. The output is rollout.mp4 and rollout.npz (frames and actions). To start from a recorded episode, quant_eval.py --save-inputs (see README_EVALUATION.md) writes each rollout's inputs to inputs.npz; simulate.py --inputs inputs.npz reproduces that rollout (up to the small run-to-run variation of sampling on GPUs), and changing the actions in the file shows their effect.

Evaluate

Evaluation runs the three modes on samples of a dataset family and scores them against the recorded data. It needs the prepared data (next section):

python -m cosmos3_h_embodied.scripts.eval --no-guardrails \
    --checkpoint-path <ckpt_dcp>/model \
    --config-file cosmos3_h_embodied/configs/config.py --experiment openh_h16_task_prompt \
    --dataset.dataset dvrk_hamlyn --dataset.model-mode joint --dataset.dataset-split val \
    --dataset.num-samples 32 --seed 20260908 --num-steps 35 --guidance 6.0 -o outputs/eval

--dataset.model-mode joint runs forward dynamics, inverse dynamics and policy (wam). Per-sample metrics.json and metrics_aggregate.json hold video PSNR (forward dynamics, policy) and action MSE (inverse dynamics, policy) in normalized action space; history rows are excluded from the action MSE. On the val and full splits the eval turns off the training-time video augmentation (EVAL_DATASET_OVERRIDES in cosmos3_h_embodied/configs/experiment_h16.py), so the model is conditioned on and scored against clean frames. --spread-samples takes the samples evenly spaced over the split instead of the first ones.

Quantitative evaluation. On held-out clips of the 10 public families with validation episodes (640 clips), inverse dynamics (20% of the training samples; forward dynamics and policy 40% each) reaches an action MSE of 0.009 and the policy 0.052 (best of 4 rollouts: 0.033), against 0.075 for the mean recorded trajectory, in normalized action space; forward dynamics reaches 26.1 dB PSNR. cosmos3_h_embodied/scripts/quant_eval.py rolls out forward dynamics autoregressively over held-out episodes, the one mode shared with Cosmos-H-Surgical-Simulator. On episodes held out by both models: on dVRK (4.8 s), dynamic PSNR +1.75 dB and PSNR +2.0 dB (better in 88% of the rollouts); on CMR Versius (7.2 s), on par in the pixel metrics, better in FID (44 vs 55) and tool consistency (GATC +0.047), worse in FVD (274 vs 225) and tool centroid distance (+7.7 px). Over 31.2 s rollouts, Cosmos-H-Surgical-Simulator degrades more slowly from about 6 s on. See cosmos3_h_embodied/README_EVALUATION.md for the protocol, metrics and all results.

Fine-tune on Open-H

1. Prepare the data

Follow tools/data_prep/README.md: download from Hugging Face, convert LeRobot v2.1 → v3.0, apply the per-root repairs, install modality.json files, and build the CMR valid-window index into <data root>/indices/. Then:

export OPENH_DATA_ROOT=<data root>     # mirrors the Hugging Face layout below Surgical/

2. Choose an experiment

Experiment Data Captions LR schedule
openh_h16_task_prompt the Open-H roots on Hugging Face (11 families) per-root robot description constant 1e-5 after 100 warm-up steps (the rate training ended at)
openh_h16_task_prompt_reference the exact 55-root training mixture (15 families; some roots are not public) as trained (caption_prefix_mode: legacy) as trained (linear 8e-5 → 1e-5 over 50,000 iterations)
openh_h16_task_prompt_smoke 2 families (obuda, UCSD), window cap, per-sample family mixing per-root constant

The experiments use rank-based family mixing: each GPU rank serves one dataset family, and ranks are allocated by mixture ratio. This needs at least as many ranks as families (11 for the Hugging Face mixture). With fewer ranks, set shard_across_workers=false on the dataset (per-sample mixing: each dataloader worker draws a family per sample).

3. Train

export IMAGINAIRE_OUTPUT_ROOT=<checkpoint directory>   # default: /tmp/imaginaire4-output
python -m cosmos_framework.scripts.export_config -o h16.yaml \
    --config-file cosmos3_h_embodied/configs/config.py --experiment openh_h16_task_prompt
torchrun --nproc_per_node=8 --nnodes=<N> ... -m cosmos_framework.scripts._train \
    --config-file h16.yaml -o outputs \
    --config-overrides checkpoint.load_path=<ckpt_dcp> model.config.parallelism.data_parallel_shard_degree=<world size>

The recipe was trained on 32 GPUs (FSDP, 2-step gradient accumulation, 5,040 tokens per packed sequence). Checkpoints (model, EMA and optimizer state, several times the size of the released weights) are written to $IMAGINAIRE_OUTPUT_ROOT/cosmos3_h_embodied/openh_h16/<experiment>/checkpoints/iter_<N>/; -o outputs holds the logs and a job link to that directory. Restarting the same command resumes from the latest checkpoint, with the action dataloader position and RNG state restored per worker.

Smoke test on one GPU with a 2-layer model, on a few episodes of two families:

python tools/download_openh_samples.py --output-dir samples_v21 --families dvrk_obuda dvrk_ucsd
python tools/data_prep/convert_v21_to_v30.py --src-root samples_v21 --dst-root samples
export OPENH_DATA_ROOT=$PWD/samples
python -m cosmos_framework.scripts.export_config -o smoke.yaml \
    --config-file cosmos3_h_embodied/configs/config.py --experiment openh_h16_task_prompt_smoke
COSMOS_SMOKE=1 torchrun --nproc_per_node=1 -m cosmos_framework.scripts._train --config-file smoke.yaml -o outputs \
    --config-overrides model.config.parallelism.data_parallel_shard_degree=1 model.config.compile.enabled=false

Fine-tune on your own data

Data from a bimanual (or single-arm) surgical robot with Cartesian end-effector kinematics fits the GeneralizedDvrkHistoryDataset loader. Prepare it once, then fine-tune for the mode you need.

Prepare your dataset

  1. LeRobot v3.0 format, one root per task, below OPENH_DATA_ROOT (for example $OPENH_DATA_ROOT/my_lab/task_a); the loaders sample clips at 10 Hz. The state holds each arm's measured end-effector pose, the action each arm's gripper command (and, with pose_source="action", the commanded pose).

  2. meta/modality.json that names the columns per arm, in both the state and the action block: <arm>_pose (7 columns: position + quaternion, set quaternion_order to xyzw or wxyz; or 6 columns: position + Euler XYZ in radians) and <arm>_gripper (1 column, optional). For two arms with 16-D state and action:

    {"state":  {"psm1_pose": {"start": 0, "end": 7}, "psm1_gripper": {"start": 7, "end": 8},
                "psm2_pose": {"start": 8, "end": 15}, "psm2_gripper": {"start": 15, "end": 16}},
     "action": {"psm1_pose": {"start": 0, "end": 7}, "psm1_gripper": {"start": 7, "end": 8},
                "psm2_pose": {"start": 8, "end": 15}, "psm2_gripper": {"start": 15, "end": 16}}}
  3. An embodiment. The model has 32 embodiment slots for its action projections, all of them assigned (EMBODIMENT_TO_DOMAIN_ID in cosmos3_h_embodied/data/domain_utils.py). Reuse the embodiment of the most similar robot: for example, hamlyn or dvrk_obuda for a dVRK with two patient-side manipulators. Captions are prefixed with a robot and setting description; add one for your data to EMBODIMENT_CAPTION_CONTEXT in the same file (key my_lab below).

  4. A dataset family. Append it to FAMILIES in cosmos3_h_embodied/configs/openh_datasets.py:

    Family(
        "my_lab",
        1.0,  # sampling ratio relative to the other families of an experiment
        GeneralizedDvrkHistoryDataset,
        (Root("my_lab/task_a", "my_lab"), Root("my_lab/task_b", "my_lab")),  # path, caption key
        _dvrk(
            "hamlyn",  # embodiment
            "my_lab_backward_anchored_worldtrans_rot6d.json",  # action statistics (next step)
            "observation.images.left",
            quaternion_order="wxyz",
        ),
    ),
  5. Action statistics of the family with tools/compute_action_normalizer.py, written to the family's normalizer file under cosmos3_h_embodied/data/normalizers/ (the procedure of the released checkpoint's most recent statistics files, which it reproduces exactly):

    python tools/compute_action_normalizer.py --family my_lab
    OPENH_TEST_FAMILIES=my_lab pytest tests/test_prepared_data.py   # check a few samples

Each tutorial below registers an experiment, trains from the released checkpoint (<ckpt_dcp>, see Install), and uses the result. Experiments are registered at the end of cosmos3_h_embodied/configs/experiment_h16.py with register_experiment, which builds them like openh_h16_task_prompt (the continue learning rate: constant 1e-5, the rate the released checkpoint finished its training at). shard_across_workers=False mixes families per sample, needed when there are fewer GPU ranks than families. Checkpoints are written to $IMAGINAIRE_OUTPUT_ROOT/cosmos3_h_embodied/openh_h16/<experiment>/checkpoints/ (see Train).

Tutorial: forward dynamics (world model)

Train the model to predict video from the first frame and an action sequence:

register_experiment("my_lab_fd", families=["my_lab"], shard_across_workers=False, mode="forward_dynamics")
python -m cosmos_framework.scripts.export_config -o my_lab_fd.yaml \
    --config-file cosmos3_h_embodied/configs/config.py --experiment my_lab_fd
torchrun --nproc_per_node=8 -m cosmos_framework.scripts._train --config-file my_lab_fd.yaml -o outputs \
    --config-overrides checkpoint.load_path=<ckpt_dcp> model.config.parallelism.data_parallel_shard_degree=8

Score the predicted video on held-out episodes (PSNR against the recorded video):

python -m cosmos3_h_embodied.scripts.eval --no-guardrails \
    --checkpoint-path $IMAGINAIRE_OUTPUT_ROOT/cosmos3_h_embodied/openh_h16/my_lab_fd/checkpoints/iter_<N>/model \
    --config-file cosmos3_h_embodied/configs/config.py --experiment my_lab_fd \
    --dataset.dataset my_lab --dataset.model-mode forward_dynamics --dataset.dataset-split val \
    --dataset.num-samples 32 --num-steps 35 --guidance 6.0 -o outputs/eval_my_lab_fd

Tutorial: policy

Train the model to predict the next 24 actions (and the video) from the current frame, the task text and the action history:

register_experiment("my_lab_policy", families=["my_lab"], shard_across_workers=False, mode="policy")

Export the config and train as above with my_lab_policy. Then serve it:

python -m cosmos3_h_embodied.scripts.policy_server \
    --checkpoint-path $IMAGINAIRE_OUTPUT_ROOT/cosmos3_h_embodied/openh_h16/my_lab_policy/checkpoints/iter_<N>/model \
    --config-file my_lab_policy.yaml \
    --normalizer my_lab_backward_anchored_worldtrans_rot6d.json --domain-name hamlyn --port 8000

--dataset.model-mode wam in the eval command above scores the policy offline (action MSE). If your data labels failed episodes (splits in meta/info.json), the default joint training keeps them out of the policy mode; a policy-only run does not, so list them in the root's meta/exclude_episodes.json (a JSON list of episode indices).

Training on a single mode specializes the model. To keep its other abilities, keep mode="joint" (the recipe mixes forward dynamics, inverse dynamics and policy 0.4 / 0.2 / 0.4, set by joint_mode_weights) or add Open-H families to families.

Tutorial: teacher training and Self-Forcing distillation

The teacher-to-student tutorial documents the reference recipe for four-step and two-step Cosmos3-H-Dreams students, including CMR curation, the 8,000-unit camera-command filter, checkpoint handoffs, optimization, action history, export and evaluation. Causal TF and Self-Forcing training are now public in cosmos-framework. The tutorial links the inspected implementation, includes the integration instructions and acceptance tests, and provides a machine-readable recipe. The companion now includes the CMR28 adapter, a pinned causal H16 extension, six registered stages, and a restartable smoke-test driver. An independent eight-H100 smoke completed all six stages, C24/SF4 save/resume, both student exports and native autoregressive inference. A separate fresh setup run passed all 55 tests, media decoding and eight-GPU BF16 checks using the tutorial's image prerequisites. Eight GPUs are a reference configuration: adapt the GPU count and resources to your hardware and qualify that setup. This bounded run does not establish full-training convergence or released-checkpoint quality. The tutorial also includes released-student inference without training, full-budget research-spec generation and explicit checkpoint selection. A reported two-48-GB setup passed installation/preflight but exhausted GPU memory at the first training stage; released-student inference passed on a single 48 GB GPU. The tutorial documents workstation setup, memory observations, integrated evaluator fixes and the automatically applied H16 framework patch. See the qualification record for remaining gaps. Existing H16 teacher fine-tuning remains available as documented above.

Tests

pytest runs the package's CPU tests. Two checks are opt-in: H16_CHECKPOINT=c3-h-e-n_model_bf16.safetensors pytest tests/test_released_checkpoint.py (the model built from the config matches the released weights), and OPENH_DATA_ROOT=<data root> OPENH_TEST_FAMILIES=dvrk_hamlyn,my_lab pytest tests/test_prepared_data.py (samples of prepared families have the expected shapes and ranges).

Repository layout

Path What
cosmos3_h_embodied/README_ACTION_SPACE.md Action space: per-embodiment layout, normalization, padding, data mixture
cosmos3_h_embodied/README_EVALUATION.md Quantitative evaluation and benchmark against Cosmos-H-Surgical-Simulator
cosmos3_h_embodied/data/ Open-H datasets (generalized dVRK, CMR clinical), H16 history, normalization, transforms, family mixing, history-matched sequence packing
cosmos3_h_embodied/data/normalizers/ Action normalization statistics of the released checkpoint (15 families)
cosmos3_h_embodied/data/exclusions/ Episodes excluded from training (302), keyed by dataset path
cosmos3_h_embodied/model/ HistoryOmniMoTModel: action loss averaged over the noised action rows only
cosmos3_h_embodied/callbacks/ Dataloader resume state (per-worker sample index and RNG state)
cosmos3_h_embodied/configs/ Dataset mixture and experiments (config.py registers them with cosmos-framework)
cosmos3_h_embodied/scripts/eval.py Dataset-driven evaluation
cosmos3_h_embodied/scripts/quant_eval.py Autoregressive forward-dynamics rollouts and video metrics (rollout_metrics.py)
cosmos3_h_embodied/scripts/policy_server.py HTTP server: policy or forward dynamics, with action history
cosmos3_h_embodied/scripts/simulate.py Forward-dynamics and policy rollouts from a start frame (rollout_utils.py)
tools/data_prep/ Rebuild the training data from the Hugging Face dataset (README)
tools/convert_checkpoint_to_dcp.py Released weights (.safetensors or .pt) → DCP checkpoint
tools/compute_action_normalizer.py Action normalization statistics for your own dataset
tools/download_openh_samples.py Download a few episodes per dataset for a local smoke test
tools/benchmark/ Benchmark against Cosmos-H-Surgical-Simulator: episode plan, its rollouts, cross-model scoring, tool metrics, results
tests/ CPU tests; checks of the released weights and of prepared data

Reproducibility

The training data of the released checkpoint can be rebuilt from Hugging Face for 11 of its 15 dataset families; some roots, captions and one video stream were never published. The code was validated against the original training code on the original data: identical samples, matching training loss, and matching evaluation metrics. cosmos3_h_embodied/training_differences.md lists every difference between the released checkpoint's training run and what this repository reproduces, and what was validated.

Citation and license

@techreport{nvidia2026cosmos3,
  title  = {Cosmos 3: Omnimodal World Models for physical AI},
  author = {{NVIDIA Cosmos Team}},
  year   = {2026},
  url    = {https://research.nvidia.com/labs/cosmos-lab/cosmos3/technical-report.pdf}
}

Source code and models are released under OpenMDW-1.1. The Open-H datasets carry their own licenses; see the dataset card.

About

Cosmos3-H-Embodied-Nano

Resources

Contributing

Security policy

Stars

6 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages