• bitcoinBitcoin(BTC)$63,314.002.03%
  • ethereumEthereum(ETH)$1,748.830.77%
  • tetherTether(USDT)$1.00-0.01%
  • binancecoinBNB(BNB)$569.840.70%
  • usd-coinUSDC(USDC)$1.00-0.01%
  • rippleXRP(XRP)$1.100.77%
  • solanaSolana(SOL)$78.091.34%
  • tronTRON(TRX)$0.3318370.71%
  • Figure HelocFigure Heloc(FIGR_HELOC)$1.03-0.06%
  • HyperliquidHyperliquid(HYPE)$67.300.63%
  • dogecoinDogecoin(DOGE)$0.0732301.24%
  • USDSUSDS(USDS)$1.00-0.02%
  • RainRain(RAIN)$0.014446-0.80%
  • leo-tokenLEO Token(LEO)$9.530.71%
  • zcashZcash(ZEC)$487.205.11%
  • whitebitWhiteBIT Coin(WBT)$55.871.42%
  • stellarStellar(XLM)$0.1859323.06%
  • cardanoCardano(ADA)$0.1667620.51%
  • moneroMonero(XMR)$314.69-1.27%
  • chainlinkChainlink(LINK)$7.762.02%
  • CantonCanton(CC)$0.1317164.62%
  • bitcoin-cashBitcoin Cash(BCH)$237.341.95%
  • daiDai(DAI)$1.000.03%
  • USD1USD1(USD1)$1.00-0.03%
  • the-open-networkGram (prev. Toncoin)(GRAM)$1.622.55%
  • Ethena USDeEthena USDe(USDE)$1.000.10%
  • litecoinLitecoin(LTC)$43.901.30%
  • Global DollarGlobal Dollar(USDG)$1.00-0.05%
  • Circle USYCCircle USYC(USYC)$1.130.00%
  • hedera-hashgraphHedera(HBAR)$0.0703731.81%
  • suiSui(SUI)$0.721.55%
  • avalanche-2Avalanche(AVAX)$6.714.39%
  • paypal-usdPayPal USD(PYUSD)$1.00-0.02%
  • crypto-com-chainCronos(CRO)$0.056325-0.05%
  • shiba-inuShiba Inu(SHIB)$0.0000040.86%
  • tether-goldTether Gold(XAUT)$4,109.461.05%
  • nearNEAR Protocol(NEAR)$1.923.06%
  • BlackRock USD Institutional Digital Liquidity FundBlackRock USD Institutional Digital Liquidity Fund(BUIDL)$1.000.00%
  • Ondo US Dollar YieldOndo US Dollar Yield(USDY)$1.14-0.04%
  • uniswapUniswap(UNI)$3.424.77%
  • BittensorBittensor(TAO)$207.872.57%
  • World Liberty FinancialWorld Liberty Financial(WLFI)$0.058335-1.20%
  • pax-goldPAX Gold(PAXG)$4,115.161.09%
  • HTX DAOHTX DAO(HTX)$0.000002-0.58%
  • AsterAster(ASTER)$0.620.66%
  • okbOKB(OKB)$79.551.24%
  • MemeCoreMemeCore(M)$1.20-6.75%
  • Ripple USDRipple USD(RLUSD)$1.000.02%
  • OndoOndo(ONDO)$0.3176431.30%
  • dexeDeXe(DEXE)$32.2812.06%
TradePoint.io
  • Main
  • AI & Technology
  • Stock Charts
  • Market & News
  • Business
  • Finance Tips
  • Trade Tube
  • Blog
  • Shop
No Result
View All Result
TradePoint.io
No Result
View All Result

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

July 8, 2026
in AI & Technology
Reading Time: 3 mins read
A A
NVIDIA’s Cosmos-Framework Tutorial: Designing a Colab-Friendly Miniature of Cosmos 3 World Models with Omnimodal Mixture-of-Transformers
ShareShareShareShareShare

YOU MAY ALSO LIKE

Billion-Dollar Mix-Up Costs Korean Investors a Shot at SpaceX IPO

OpenAI Releases GPT-5.6 (Sol, Terra, Luna): A Three-Tier Model Family With Programmatic Tool Calling in the Responses API

import torch.nn as nn
import torch.nn.functional 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):
       super().__init__(); self.w = nn.Parameter(torch.ones(d)); self.eps = eps
   def forward(self, x):
       return self.w * x * torch.rsqrt(x.pow(2).mean(-1, keepdim=True) + self.eps)
def build_rope(T, hd, device, base=10000.0):
   pos  = torch.arange(T, device=device, dtype=torch.float32)[:, None]
   idx  = torch.arange(0, hd, 2, device=device, 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.shape[-1]; x1, x2 = x[..., :hd // 2], x[..., hd // 2:]
   return torch.cat([-x2, x1], -1)
def apply_rope(q, k, cos, sin):
   return q * cos + rotate_half(q) * sin, k * cos + rotate_half(k) * sin
class Attention(nn.Module):
   """Shared cross-modal causal self-attention with rotary embeddings."""
   def __init__(self, c: Cfg):
       super().__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 forward(self, x, cos, sin, mask):
       B, T, D = x.shape
       q, k, v = self.qkv(x).chunk(3, -1)
       q = q.view(B, T, self.H, self.hd).transpose(1, 2)
       k = k.view(B, T, self.H, self.hd).transpose(1, 2)
       v = v.view(B, T, self.H, self.hd).transpose(1, 2)
       q, k = apply_rope(q, k, cos, sin)
       att = (q @ k.transpose(-2, -1)) / math.sqrt(self.hd)
       att = att.masked_fill(mask, 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 expert'."""
   def __init__(self, d, mult):
       super().__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 forward(self, x):
       return self.w2(F.silu(self.w1(x)) * self.w3(x))
class MoTBlock(nn.Module):
   """Shared attention + Mixture-of-Transformers (per-modality expert) routing."""
   def __init__(self, c: Cfg):
       super().__init__()
       self.attn_norm = RMSNorm(c.d_model)
       self.attn      = Attention(c)
       self.ffn_norm  = nn.ModuleList([RMSNorm(c.d_model) for _ in range(c.n_mod)])
       self.experts   = nn.ModuleList([Expert(c.d_model, c.ffn_mult) for _ in range(c.n_mod)])
   def forward(self, x, cos, sin, mask, mod_id):
       x = x + self.attn(self.attn_norm(x), cos, sin, mask)
       out = torch.zeros_like(x)
       for i, exp in enumerate(self.experts):
           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):
       super().__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.ModuleList([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)]).long()
       self.register_buffer("mod_id", ids, persistent=False)
   def forward(self, text, 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.shape
       cos, sin = build_rope(T, D // c.n_head, x.device)
       mask = torch.triu(torch.ones(T, T, dtype=torch.bool, device=x.device), 1)[None, None]
       for blk in self.blocks:
           x = blk(x, cos, sin, mask, 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
model = OmniMoT(cfg).to(DEVICE)
n_params = sum(p.numel() for p in model.parameters())
print(f"Model built: OmniMoT  |  {n_params/1e6:.2f}M params  |  {cfg.n_layer} MoT blocks "
     f"x {cfg.n_mod} experts  |  device={DEVICE}")

Credit: Source link

ShareTweetSendSharePin

Related Posts

Billion-Dollar Mix-Up Costs Korean Investors a Shot at SpaceX IPO
AI & Technology

Billion-Dollar Mix-Up Costs Korean Investors a Shot at SpaceX IPO

July 9, 2026
OpenAI Releases GPT-5.6 (Sol, Terra, Luna): A Three-Tier Model Family With Programmatic Tool Calling in the Responses API
AI & Technology

OpenAI Releases GPT-5.6 (Sol, Terra, Luna): A Three-Tier Model Family With Programmatic Tool Calling in the Responses API

July 9, 2026
Chip Stocks on Track for Best Quarter Ever | Bloomberg Tech 6/30/2026
AI & Technology

Chip Stocks on Track for Best Quarter Ever | Bloomberg Tech 6/30/2026

July 9, 2026
How Birthright Citizenship Ruling Impacts the Tech Job Sector
AI & Technology

How Birthright Citizenship Ruling Impacts the Tech Job Sector

July 9, 2026
Next Post
Slack’s Slackbot can now pull your CRM data, generate charts, and send DocuSigns — all from a chat message.

Slack’s Slackbot can now pull your CRM data, generate charts, and send DocuSigns — all from a chat message.

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Search

No Result
View All Result
‘Obsession’ director talks YouTube releases, his new film and advice for young directors

‘Obsession’ director talks YouTube releases, his new film and advice for young directors

July 3, 2026
California standoff suspect dead, all hostages freed

California standoff suspect dead, all hostages freed

July 7, 2026
Magnificent Seven Tech Stocks Lose Market Swagger

Magnificent Seven Tech Stocks Lose Market Swagger

July 9, 2026

About

Learn more

Our Services

Legal

Privacy Policy

Terms of Use

Bloggers

Learn more

Article Links

Contact

Advertise

Ask us anything

©2020- TradePoint.io - All rights reserved!

Tradepoint.io, being just a publishing and technology platform, is not a registered broker-dealer or investment adviser. So we do not provide investment advice. Rather, brokerage services are provided to clients of Tradepoint.io by independent SEC-registered broker-dealers and members of FINRA/SIPC. Every form of investing carries some risk and past performance is not a guarantee of future results. “Tradepoint.io“, “Instant Investing” and “My Trading Tools” are registered trademarks of Apperbuild, LLC.

This website is operated by Apperbuild, LLC. We have no link to any brokerage firm and we do not provide investment advice. Every information and resource we provide is solely for the education of our readers. © 2020 Apperbuild, LLC. All rights reserved.

No Result
View All Result
  • Main
  • AI & Technology
  • Stock Charts
  • Market & News
  • Business
  • Finance Tips
  • Trade Tube
  • Blog
  • Shop

© 2023 - TradePoint.io - All Rights Reserved!