|

NVIDIA’s Cosmos-Framework Tutorial: Designing a Colab-Friendly Miniature of Cosmos 3 World Models with Omnimodal Mixture-of-Transformers

✅

In this tutorial, we discover NVIDIA’s cosmos-framework from a sensible Colab-friendly angle whereas staying trustworthy in regards to the {hardware} limits of working actual Cosmos 3 checkpoints. We start by checking the present runtime, GPU capabilities, CUDA availability, reminiscence, and disk house to grasp why full Cosmos 3 inference shouldn’t be life like on customary Colab {hardware}. Instead of stopping there, we use the framework’s actual construction, CLI floor, enter schema, and mannequin modes as the muse for a hands-on miniature implementation. We then construct and practice a compact omnimodal Mixture-of-Transformers world mannequin that mirrors the core Cosmos concept: shared cross-modal consideration with modality-specific knowledgeable routing for textual content, imaginative and prescient, and motion streams. Using artificial physical-world information, training-loss monitoring, and an autoregressive rollout, we present how the mannequin learns relationships throughout modalities and predicts future latent states in a simplified but technically significant manner.

Probing Colab Hardware Limits

import os, sys, json, time, math, textwrap, subprocess, shutil, platform
from pathlib import Path
def rule(title=""):
   line = "=" * 86
   print("n" + line + ("n  " + title if title else "") + "n" + line)
def spark(vals, width=60):
   """Tiny ASCII sparkline for a 1-D sequence (works with no plotting libs)."""
   if not vals: return ""
   blocks = "▁▂▃▄▅▆▇█"
   lo, hello = min(vals), max(vals)
   rng = (hello - lo) or 1.0
   step = max(1, len(vals) // width)
   s = "".be a part of(blocks[min(len(blocks) - 1, int((v - lo) / rng * (len(blocks) - 1)))]
               for v in vals[::step])
   return s
rule("SECTION 0 — Environment probe: what you've gotten vs. what Cosmos 3 really wants")
IN_COLAB = "google.colab" in sys.modules
print(f"Running inside Google Colab : {IN_COLAB}")
print(f"Python                      : {platform.python_version()}  ({platform.system()})")
strive:
   import torch
besides ModuleNotFoundError:
   print("torch not discovered — putting in CPU construct (a few seconds)...")
   subprocess.run([sys.executable, "-m", "pip", "install", "-q", "torch"], test=False)
   import torch
print(f"PyTorch                     : {torch.__version__}")
CUDA_OK = torch.cuda.is_available()
DEVICE = torch.machine("cuda" if CUDA_OK else "cpu")
gpu_name, gpu_mem_gb, cc = "None (CPU)", 0.0, (0, 0)
if CUDA_OK:
   p = torch.cuda.get_device_properties(0)
   gpu_name = p.identify
   gpu_mem_gb = p.total_memory / 1024**3
   cc = torch.cuda.get_device_capability(0)
   print(f"CUDA construct                  : {torch.model.cuda}")
   print(f"GPU                         : {gpu_name}")
   print(f"GPU reminiscence                  : {gpu_mem_gb:.1f} GiB")
   print(f"Compute functionality          : sm_{cc[0]}{cc[1]}")
strive:
   free_gb = shutil.disk_usage('/').free / 1024**3
   print(f"Free disk                   : {free_gb:.0f} GiB")
besides Exception:
   free_gb = 0.0
AMPERE = cc[0] >= 8
reqs = [
   ("GPU architecture", "Ampere+ (sm_80+, A100/RTX30xx)",  "OK" if AMPERE else "TOO OLD (T4=sm_75)"),
   ("GPU memory",       ">=80 GiB for Nano-16B (single H100)", "OK" if gpu_mem_gb >= 79 else f"{gpu_mem_gb:.0f} GiB — insufficient"),
   ("CUDA toolkit",     ">=12.8",                            "check" ),
   ("Free disk",        "~150 GiB first run (~1 TB HF cache)", "OK" if free_gb >= 150 else f"{free_gb:.0f} GiB — insufficient"),
   ("Attention kernels","FlashAttn-3 (Hopper) / FA2 (Ampere)", "needs Ampere+"),
]
print("n  Can this machine run the REAL Cosmos 3 checkpoints?")
print("  " + "-" * 82)
print(f"  {'Requirement':<18}{'Cosmos 3 wants':<38}{'You have'}")
print("  " + "-" * 82)
for okay, want, have in reqs:
   print(f"  {okay:<18}{want:<38}{have}")
print("  " + "-" * 82)
VERDICT = AMPERE and gpu_mem_gb >= 79 and free_gb >= 150
print(f"  VERDICT: {'This machine may try Nano-16B.' if VERDICT else 'NO — actual Cosmos 3 inference shouldn't be attainable right here. Educational path under.'}")

We start by making ready the runtime utilities and checking whether or not the present machine can realistically assist Cosmos 3 inference. We examine Python, PyTorch, CUDA, GPU reminiscence, compute functionality, and out there disk house to match our surroundings in opposition to the precise {hardware} necessities. We then print a clear verdict explaining why the actual 16B+ Cosmos checkpoints can’t often run on customary Colab {hardware}.

rule("SECTION 1 — Clone & map the actual cosmos_framework bundle (supply of reality)")

Mapping The Cosmos-Framework Package

REPO = "https://github.com/NVIDIA/cosmos-framework.git"
DST = Path("/content material/cosmos-framework") if Path("/content material").exists() else Path("cosmos-framework")
cloned = False
strive:
   if not DST.exists():
       print(f"Shallow-cloning {REPO} ...")
       subprocess.run(["git", "clone", "--depth", "1", REPO, str(DST)],
                      test=True, capture_output=True, textual content=True, timeout=180)
   cloned = DST.exists()
besides Exception as e:
   print(f"(Clone skipped/failed — offline is ok, tutorial continues.) {e}")
if cloned:
   print(f"Repo at: {DST}n")
   pkg = DST / "cosmos_framework"
   if pkg.exists():
       print("cosmos_framework/ subpackages (the actual code format):")
       for little one in sorted(pkg.iterdir()):
           if little one.is_dir() and never little one.identify.startswith(("_", ".")):
               n_py = len(checklist(little one.rglob("*.py")))
               print(f"   • {little one.identify:<20} ({n_py:>3} .py recordsdata)")
   instance = DST / "inputs" / "omni" / "t2v.json"
   if instance.exists():
       print(f"nReal instance enter spec  ({instance.relative_to(DST)}):")
       print(textwrap.indent(instance.read_text().strip(), "   "))
else:
   print("Proceeding with out a native clone (we already extracted the actual schema/CLI).")
print("""
Real CLI floor (docs/inference.md):
  Single GPU : python -m cosmos_framework.scripts.inference 
                   --parallelism-preset=latency -i "inputs/omni/t2v.json" 
                   -o outputs/omni_nano --checkpoint-path Cosmos3-Nano --seed 0
  Multi  GPU : torchrun --nproc-per-node=8 -m cosmos_framework.scripts.inference 
                   --parallelism-preset=throughput -i "inputs/omni/*.json" 
                   -o outputs/omni_super --checkpoint-path Cosmos3-Super --seed 0
  Models     : Cosmos3-Nano (16B, all modes) | Cosmos3-Super (65B, t2i/t2v/i2v)
  Modes      : text2image · text2video · image2video · video2video ·
               forward_dynamics · inverse_dynamics · coverage
  Parallelism: FSDP dp-shard / dp-replicate · context (cp) · CFG (cfgp)
               presets {latency, throughput}
  Guardrails : Cosmos-Guardrail1 + Qwen3Guard-Gen-0.6B + RetinaFace (on by default)
""")
rule("SECTION 2 — Omnimodal Mixture-of-Transformers (MoT) world mannequin — the concept")
print(r"""
Cosmos 3 unifies language, picture, video, audio and ACTION in ONE mannequin. The key trick
is a Mixture-of-Transformers: each modality is become tokens positioned on a SINGLE
interleaved sequence; SELF-ATTENTION is SHARED throughout all modalities (so imaginative and prescient could be
conditioned on textual content, actions on imaginative and prescient, and so on.), however every token is processed by a
MODALITY-SPECIFIC knowledgeable feed-forward block ("Mixture-of-Transformers" routing).
       textual content tokens        imaginative and prescient tokens          motion tokens
       [t0 t1 t2 ...]     [v0 v1 v2 ...]         [a0 a1 ...]
                               |                     /
                               |                    /
              +----------- one sequence -----------+
                             |
                ┌─────────── shared causal self-attention (RoPE) ───────────┐
                │  each token attends to all earlier tokens, ANY modality  │
                └───────────────────────────────────────────────────────────┘
                             |
                route every token to its modality's EXPERT FFN (SwiGLU):
                   textual content→Expert0     imaginative and prescient→Expert1     motion→Expert2
                             |
                per-modality heads:  next-token / next-latent / next-action
Physical-AI modes fall proper out of this one mannequin:
  text2video      = generate the vision-token stream from a textual content immediate
  image2video     = situation imaginative and prescient stream on a first body + textual content
  forward_dynamics= given frames + ACTIONS, roll future frames ahead   (a world mannequin)
  inverse_dynamics= given frames, infer the ACTIONS that brought on them
  coverage          = given an commentary + aim, emit ACTIONS (+ imagined rollout)
Below we construct a trustworthy ~4M-param miniature of precisely this and practice it reside.
(The actual mannequin makes use of flow-matching/diffusion for the continual imaginative and prescient stream; our toy
makes use of a easy MSE next-latent goal so it trains in seconds — the ROUTING and
SHARED-ATTENTION construction are the identical.)
""")

We clone and examine the actual cosmos-framework repository to grasp its bundle construction, enter schemas, and CLI workflow immediately from the supply. We additionally print the official inference command patterns for single-GPU and multi-GPU launches, together with modes comparable to text-to-video, image-to-video, ahead dynamics, inverse dynamics, and coverage. We then introduce the omnimodal Mixture-of-Transformers concept, the place textual content, imaginative and prescient, and motion tokens share consideration whereas nonetheless utilizing modality-specific knowledgeable feed-forward blocks.

rule("SECTION 3 — Implement & practice the omnimodal MoT from scratch")

Building The Omnimodal MoT

import torch.nn as nn
import torch.nn.purposeful as F
from dataclasses import dataclass
torch.manual_seed(0)
@dataclass
class Cfg:
   d_model:   int = 192
   n_head:    int = 6
   n_layer:   int = 4
   ffn_mult:  int = 2
   n_mod:     int = 3
   text_vocab:int = 16
   vis_dim:   int = 8
   act_dim:   int = 4
   Lt:        int = 8
   Lv:        int = 8
   La:        int = 6
cfg = Cfg()
class RMSNorm(nn.Module):
   def __init__(self, d, eps=1e-6):
       tremendous().__init__(); self.w = nn.Parameter(torch.ones(d)); self.eps = eps
   def ahead(self, x):
       return self.w * x * torch.rsqrt(x.pow(2).imply(-1, keepdim=True) + self.eps)
def build_rope(T, hd, machine, base=10000.0):
   pos  = torch.arange(T, machine=machine, dtype=torch.float32)[:, None]
   idx  = torch.arange(0, hd, 2, machine=machine, dtype=torch.float32)[None, :]
   freq = 1.0 / (base ** (idx / hd))
   ang  = pos * freq
   cos  = torch.cos(ang).repeat(1, 2)[None, None]
   sin  = torch.sin(ang).repeat(1, 2)[None, None]
   return cos, sin
def rotate_half(x):
   hd = x.form[-1]; x1, x2 = x[..., :hd // 2], x[..., hd // 2:]
   return torch.cat([-x2, x1], -1)
def apply_rope(q, okay, cos, sin):
   return q * cos + rotate_half(q) * sin, okay * cos + rotate_half(okay) * sin
class Attention(nn.Module):
   """Shared cross-modal causal self-attention with rotary embeddings."""
   def __init__(self, c: Cfg):
       tremendous().__init__()
       self.H, self.hd = c.n_head, c.d_model // c.n_head
       self.qkv  = nn.Linear(c.d_model, 3 * c.d_model, bias=False)
       self.proj = nn.Linear(c.d_model, c.d_model, bias=False)
   def ahead(self, x, cos, sin, masks):
       B, T, D = x.form
       q, okay, v = self.qkv(x).chunk(3, -1)
       q = q.view(B, T, self.H, self.hd).transpose(1, 2)
       okay = okay.view(B, T, self.H, self.hd).transpose(1, 2)
       v = v.view(B, T, self.H, self.hd).transpose(1, 2)
       q, okay = apply_rope(q, okay, cos, sin)
       att = (q @ okay.transpose(-2, -1)) / math.sqrt(self.hd)
       att = att.masked_fill(masks, float("-inf")).softmax(-1)
       o = (att @ v).transpose(1, 2).reshape(B, T, D)
       return self.proj(o)
class Expert(nn.Module):
   """A per-modality SwiGLU feed-forward 'transformer knowledgeable'."""
   def __init__(self, d, mult):
       tremendous().__init__(); h = d * mult
       self.w1 = nn.Linear(d, h, bias=False)
       self.w3 = nn.Linear(d, h, bias=False)
       self.w2 = nn.Linear(h, d, bias=False)
   def ahead(self, x):
       return self.w2(F.silu(self.w1(x)) * self.w3(x))
class MoTBlock(nn.Module):
   """Shared consideration + Mixture-of-Transformers (per-modality knowledgeable) routing."""
   def __init__(self, c: Cfg):
       tremendous().__init__()
       self.attn_norm = RMSNorm(c.d_model)
       self.attn      = Attention(c)
       self.ffn_norm  = nn.ModuleListing([RMSNorm(c.d_model) for _ in range(c.n_mod)])
       self.specialists   = nn.ModuleListing([Expert(c.d_model, c.ffn_mult) for _ in range(c.n_mod)])
   def ahead(self, x, cos, sin, masks, mod_id):
       x = x + self.attn(self.attn_norm(x), cos, sin, masks)
       out = torch.zeros_like(x)
       for i, exp in enumerate(self.specialists):
           sel = (mod_id == i).view(1, -1, 1).to(x.dtype)
           out = out + sel * exp(self.ffn_norm[i](x))
       return x + out
class OmniMoT(nn.Module):
   def __init__(self, c: Cfg):
       tremendous().__init__(); self.c = c
       self.text_emb = nn.Embedding(c.text_vocab, c.d_model)
       self.vis_in   = nn.Linear(c.vis_dim, c.d_model)
       self.act_in   = nn.Linear(c.act_dim, c.d_model)
       self.mod_emb  = nn.Embedding(c.n_mod, c.d_model)
       self.blocks   = nn.ModuleListing([MoTBlock(c) for _ in range(c.n_layer)])
       self.norm     = RMSNorm(c.d_model)
       self.text_head = nn.Linear(c.d_model, c.text_vocab, bias=False)
       self.vis_head  = nn.Linear(c.d_model, c.vis_dim,  bias=False)
       self.act_head  = nn.Linear(c.d_model, c.act_dim,  bias=False)
       ids = torch.cat([torch.zeros(c.Lt), torch.ones(c.Lv), torch.full((c.La,), 2)]).lengthy()
       self.register_buffer("mod_id", ids, persistent=False)
   def ahead(self, textual content, vis, act):
       c = self.c
       x = torch.cat([self.text_emb(text), self.vis_in(vis), self.act_in(act)], 1)
       x = x + self.mod_emb(self.mod_id)[None]
       B, T, D = x.form
       cos, sin = build_rope(T, D // c.n_head, x.machine)
       masks = torch.triu(torch.ones(T, T, dtype=torch.bool, machine=x.machine), 1)[None, None]
       for blk in self.blocks:
           x = blk(x, cos, sin, masks, self.mod_id)
       x = self.norm(x)
       ht = self.text_head(x[:, :c.Lt])
       hv = self.vis_head(x[:, c.Lt:c.Lt + c.Lv])
       ha = self.act_head(x[:, c.Lt + c.Lv:])
       return ht, hv, ha
mannequin = OmniMoT(cfg).to(DEVICE)
n_params = sum(p.numel() for p in mannequin.parameters())
print(f"Model constructed: OmniMoT  |  {n_params/1e6:.2f}M params  |  {cfg.n_layer} MoT blocks "
     f"x {cfg.n_mod} specialists  |  machine={DEVICE}")

We implement the miniature omnimodal Mixture-of-Transformers mannequin from scratch utilizing PyTorch. We outline RMSNorm, rotary embeddings, shared causal self-attention, modality-specific SwiGLU specialists, and the complete OmniMoT structure. We then initialize the mannequin on the out there machine and report its parameter depend, layer depend, knowledgeable construction, and runtime machine.

Ok = 4
g = torch.Generator().manual_seed(1)

Training On Synthetic Data

Ok = 4
g = torch.Generator().manual_seed(1)
Training On Synthetic Data
TEXT_TRANS = torch.stack([torch.softmax(torch.randn(cfg.text_vocab, cfg.text_vocab, generator=g), -1)
                         for _ in range(K)])
VIS_DYN = torch.stack([0.9 * torch.linalg.qr(torch.randn(cfg.vis_dim, cfg.vis_dim, generator=g))[0]
                      for _ in vary(Ok)])
ACT_MAP = torch.randn(cfg.act_dim, cfg.vis_dim, generator=g) * 0.5
def make_batch(B):
   codes = torch.randint(0, Ok, (B,), generator=g)
   textual content = torch.zeros(B, cfg.Lt, dtype=torch.lengthy)
   textual content[:, 0] = torch.randint(0, cfg.text_vocab, (B,), generator=g)
   for t in vary(1, cfg.Lt):
       probs = TEXT_TRANS[codes, text[:, t-1]]
       textual content[:, t] = torch.multinomial(probs, 1, generator=g).squeeze(1)
   vis = torch.zeros(B, cfg.Lv, cfg.vis_dim)
   vis[:, 0] = torch.randn(B, cfg.vis_dim, generator=g)
   for t in vary(1, cfg.Lv):
       vis[:, t] = torch.einsum("bij,bj->bi", VIS_DYN[codes], vis[:, t-1]) 
                   + 0.02 * torch.randn(B, cfg.vis_dim, generator=g)
   vis_state = vis.imply(1)
   act = torch.zeros(B, cfg.La, cfg.act_dim)
   for t in vary(cfg.La):
       act[:, t] = (ACT_MAP @ (vis_state * (0.8 ** t)).T).T 
                   + 0.02 * torch.randn(B, cfg.act_dim, generator=g)
   return textual content.to(DEVICE), vis.to(DEVICE), act.to(DEVICE), codes
def loss_fn(mannequin, textual content, vis, act):
   ht, hv, ha = mannequin(textual content, vis, act)
   l_text = F.cross_entropy(ht[:, :-1].reshape(-1, cfg.text_vocab), textual content[:, 1:].reshape(-1))
   l_vis  = F.mse_loss(hv[:, :-1], vis[:, 1:])
   l_act  = F.mse_loss(ha[:, :-1], act[:, 1:])
   return l_text + l_vis + l_act, (l_text.merchandise(), l_vis.merchandise(), l_act.merchandise())
decide = torch.optim.AdamW(mannequin.parameters(), lr=3e-3, weight_decay=0.01)
STEPS, BATCH = 400, 64
hist, t0 = [], time.time()
print(f"nTraining for {STEPS} steps (batch={BATCH})...")
mannequin.practice()
for step in vary(1, STEPS + 1):
   textual content, vis, act, _ = make_batch(BATCH)
   loss, components = loss_fn(mannequin, textual content, vis, act)
   decide.zero_grad(); loss.backward()
   torch.nn.utils.clip_grad_norm_(mannequin.parameters(), 1.0)
   decide.step()
   hist.append(loss.merchandise())
   if step % 50 == 0 or step == 1:
       print(f"  step {step:4d}  complete {loss.merchandise():6.3f}  "
             f"| textual content {components[0]:5.3f}  imaginative and prescient {components[1]:6.4f}  motion {components[2]:6.4f}")
print(f"Trained in {time.time()-t0:.1f}s  |  loss {hist[0]:.3f} -> {hist[-1]:.3f}")
print("  loss curve: " + spark(hist))
strive:
   import matplotlib.pyplot as plt
   plt.determine(figsize=(7, 3))
   plt.plot(hist); plt.title("OmniMoT coaching loss"); plt.xlabel("step"); plt.ylabel("loss")
   plt.grid(alpha=0.3); plt.tight_layout(); plt.present()
besides Exception:
   move

We create a artificial physical-world dataset the place textual content, imaginative and prescient, and motion streams rely upon hidden scene codes. We practice the miniature world mannequin to foretell subsequent textual content tokens, future imaginative and prescient latents, and future motion vectors utilizing a mixed cross-entropy and MSE goal. We observe the coaching loss over a number of steps and optionally plot the curve to indicate how the mannequin learns the cross-modal dynamics.

rule("SECTION 4 — Autoregressive world-model rollout (forward_dynamics analog)")
print(textwrap.dedent("""
   A world mannequin predicts the FUTURE. Here we give the educated mannequin a partial imaginative and prescient
   trajectory and let it roll the imaginative and prescient latents ahead one step at a time — precisely
   the loop Cosmos 3 runs for `forward_dynamics` (predict future frames) and `coverage`
   (predict future frames + actions). We evaluate the mannequin's imagined trajectory to the
   ground-truth physics (the hidden VIS_DYN map) it by no means noticed explicitly.
"""))
@torch.no_grad()

Autoregressive World-Model Rollout

def rollout(mannequin, textual content, vis_prefix, act, n_future):
   """Predict n_future imaginative and prescient latents autoregressively from a imaginative and prescient prefix."""
   mannequin.eval()
   vis = vis_prefix.clone()
   preds = []
   for _ in vary(n_future):
       pad = cfg.Lv - vis.form[1]
       vis_in = vis if pad <= 0 else torch.cat(
           [vis, vis[:, -1:].repeat(1, pad, 1)], 1)
       _, hv, _ = mannequin(textual content, vis_in[:, :cfg.Lv], act)
       nxt = hv[:, min(vis.shape[1], cfg.Lv) - 1:min(vis.form[1], cfg.Lv)]
       preds.append(nxt)
       vis = torch.cat([vis, nxt], 1)
   return torch.cat(preds, 1)
textual content, vis, act, codes = make_batch(4)
prefix_len, n_future = 3, 5
pred = rollout(mannequin, textual content, vis[:, :prefix_len], act, n_future)
gt = vis[:, prefix_len-1:prefix_len].clone()
true_steps = [gt]
cur = gt
for _ in vary(n_future):
   cur = torch.einsum("bij,bj->bi", VIS_DYN[codes].to(DEVICE), cur[:, -1]).unsqueeze(1)
   true_steps.append(cur)
gt_traj = torch.cat(true_steps[1:], 1)
err = F.mse_loss(pred, gt_traj).merchandise()
print(f"Rolled out {n_future} future imaginative and prescient latents for {textual content.form[0]} scenes.")
print(f"Imagined-vs-true-physics MSE : {err:.4f}   (a small quantity = it realized the dynamics)")
print(f"Example (scene 0) latent[0] over time:")
print(f"   predicted : {pred[0,:,0].detach().cpu().numpy().spherical(3).tolist()}")
print(f"   true      : {gt_traj[0,:,0].detach().cpu().numpy().spherical(3).tolist()}")

We check the educated mannequin utilizing an autoregressive rollout that mirrors the forward-dynamics strategy utilized in real-world fashions. We give the mannequin a brief imaginative and prescient prefix and let it predict future latent states step-by-step. We then evaluate the imagined trajectory in opposition to the true artificial physics and report the MSE to judge how properly the mannequin captures future dynamics.

rule("SECTION 5 — Real Cosmos 3 inference: legitimate enter specs, instructions, {hardware} desk")

Real Cosmos 3 Inference

specs = {
   "t2i.json": {
       "model_mode": "text2image",
       "immediate": "a robotic arm neatly stacking three wood blocks on a lab bench, cinematic",
       "decision": "480", "aspect_ratio": "16,9", "num_frames": 1, "seed": 0,
   },
   "t2v.json": {
       "model_mode": "text2video",
       "immediate": "first-person view of a warehouse AMR navigating round pallets, clean movement",
       "decision": "480", "aspect_ratio": "16,9", "fps": 16, "num_frames": 121, "seed": 0,
   },
   "t2vs.json": {
       "model_mode": "text2video", "enable_sound": True,
       "immediate": "rain falling on a tin roof at night time, distant thunder, puddles rippling",
       "decision": "480", "fps": 16, "num_frames": 121, "seed": 0,
   },
   "i2v.json": {
       "model_mode": "image2video",
       "immediate": "the digital camera slowly pushes in as steam rises from the cup",
       "vision_path": "property/first_frame.jpg",
       "decision": "480", "fps": 16, "num_frames": 121, "seed": 0,
   },
   "action_forward_dynamics_robot.json": {
       "model_mode": "forward_dynamics",
       "domain_name": "bridge_orig_lerobot", "view_point": "ego_view",
       "vision_path": "property/obs.mp4", "action_path": "property/actions.json",
       "action_chunk_size": 12, "image_size": 256, "seed": 0,
   },
   "action_policy_robot.json": {
       "model_mode": "coverage",
       "domain_name": "bridge_orig_lerobot", "view_point": "ego_view",
       "vision_path": "property/obs.mp4", "immediate": "decide up the purple dice and place it within the bowl",
       "action_chunk_size": 12, "image_size": 256, "seed": 0,
   },
}
spec_dir = (Path("/content material") if Path("/content material").exists() else Path(".")) / "cosmos_inputs"
spec_dir.mkdir(exist_ok=True)
for identify, obj in specs.gadgets():
   (spec_dir / identify).write_text(json.dumps(obj, indent=2))
print(f"Wrote {len(specs)} ready-to-use, schema-correct enter specs to: {spec_dir}n")
print("Example — text2video spec (inputs/omni/t2v.json):")
print(textwrap.indent(json.dumps(specs["t2v.json"], indent=2), "   "))
print("""
EXACT launch instructions (run these the place you've gotten the {hardware}; do NOT count on them on Colab):
 # Single 80GB H100 — Nano solely, latency preset (lowest per-sample wall time)
 python -m cosmos_framework.scripts.inference 
     --parallelism-preset=latency 
     -i "cosmos_inputs/t2v.json" -o outputs/nano 
     --checkpoint-path Cosmos3-Nano --seed 0
 # Whole batch on 8x H100 — Nano, throughput preset
 torchrun --nproc-per-node=8 -m cosmos_framework.scripts.inference 
     --parallelism-preset=throughput 
     -i "cosmos_inputs/*.json" -o outputs/nano_batch 
     --checkpoint-path Cosmos3-Nano --seed 0
 # Cosmos3-Super (65B) — should shard throughout GPUs (does NOT match on one H100)
 torchrun --nproc-per-node=4 -m cosmos_framework.scripts.inference 
     --parallelism-preset=throughput --dp-shard-size=4 --dp-replicate-size=1 
     --cp-size=1 --cfgp-size=1 
     -i "cosmos_inputs/t2v.json" -o outputs/tremendous 
     --checkpoint-path Cosmos3-Super --seed 0
 # Tight on reminiscence? climb this ladder (from docs/faq.md):
 export PYTORCH_CUDA_ALLOC_CONF=expandable_segments:True
 ... --offload-guardrail-models         # preserve guardrails on CPU between calls
 ... --no-guardrails                     # (final resort; disables security filters)
""")
print("  Model / {hardware} actuality desk")
print("  " + "-" * 82)
print(f"  {'Model':<16}{'Params':<9}{'Fits on 1x H100 80GB?':<24}{'Recommended':<18}")
print("  " + "-" * 82)
for m, pr, one, rec in [
   ("Cosmos3-Nano",  "16B", "Yes (latency preset)",   "1-8x H100"),
   ("Cosmos3-Super", "65B", "No — must shard (FSDP)",  "4-8x H100"),
]:
   print(f"  {m:<16}{pr:<9}{one:<24}{rec:<18}")
print("  " + "-" * 82)
rule("SECTION 6 — Summary")
print(textwrap.dedent(f"""
   You ran, finish to finish on {'a ' + gpu_name if CUDA_OK else 'CPU'}:
     1. An trustworthy functionality probe (this field can't run the 16B+ Cosmos 3 checkpoints).
     2. A map of the actual cosmos_framework bundle, CLI, modes, and enter schema.
     3. A from-scratch ~{n_params/1e6:.1f}M-param omnimodal Mixture-of-Transformers world
        mannequin — shared cross-modal causal consideration + per-modality knowledgeable FFNs, RoPE,
        RMSNorm, SwiGLU — TRAINED reside (loss {hist[0]:.2f} -> {hist[-1]:.2f}).
     4. An autoregressive world-model rollout (forward_dynamics/coverage), imagined-vs-true
        physics MSE = {err:.4f}.
     5. Six schema-correct Cosmos 3 enter specs + the precise launch instructions.
   To run the REAL fashions, use a machine with Ampere+ GPUs (Hopper/Blackwell beneficial),
   CUDA>=12.8 and ~150GB free disk, then:
     git clone https://github.com/NVIDIA/cosmos-framework && cd cosmos-framework
     curl -LsSf https://astral.sh/uv/set up.sh | sh && supply $HOME/.native/bin/env
     uv sync --all-extras --group=cu130-train        # or cu128-train for CUDA 12.8
     supply .venv/bin/activate && export LD_LIBRARY_PATH=
     export HF_TOKEN=...                              # settle for mannequin licenses on HF first
     python -m cosmos_framework.scripts.inference --parallelism-preset=latency 
         -i cosmos_inputs/t2v.json -o outputs/nano --checkpoint-path Cosmos3-Nano --seed 0
   Docs:  setup → docs/setup.md · inference → docs/inference.md · coaching → docs/coaching.md
   Models: https://huggingface.co/collections/nvidia/cosmos3
"""))
print("Done. ✅  This complete tutorial ran with out a single gated obtain or 80GB GPU.")

We generate schema-correct Cosmos 3 enter specs for text-to-image, text-to-video, audio-enabled video, image-to-video, ahead dynamics, and policy-style robotic duties. We additionally print the precise instructions wanted to launch actual Cosmos 3 inference on appropriate H100-class {hardware} with the right parallelism settings. We end by summarizing what we run in Colab and the way the identical workflow scales to the actual NVIDIA Cosmos fashions when the required {hardware} and setup can be found.

Conclusion

In conclusion, we linked the sensible constraints of large-scale Cosmos 3 deployment with a runnable instructional implementation that helps us perceive the structure fairly than simply examine it. We educated a small omnimodal transformer, inspected how textual content, imaginative and prescient, and motion tokens work together by way of shared consideration, and ran a forward-dynamics-style rollout that demonstrates the world-modeling idea at a manageable scale. We additionally generated schema-correct enter specs and actual launch instructions for actual Cosmos 3 inference, so the identical workflow can scale as soon as we now have entry to the required Ampere or Hopper-class {hardware}, adequate GPU reminiscence, CUDA assist, and disk capability.


Check out the (*3*). Also, be at liberty to comply with us on Twitter and don’t overlook to hitch our 150k+ML SubReddit and Subscribe to our Newsletter. Wait! are you on telegram? now you can join us on telegram as well.

Need to associate with us for selling your GitHub Repo OR Hugging Face Page OR Product Release OR Webinar and so on.? Connect with us

The put up NVIDIA’s Cosmos-Framework Tutorial: Designing a Colab-Friendly Miniature of Cosmos 3 World Models with Omnimodal Mixture-of-Transformers appeared first on MarkTechPost.

Similar Posts