import{s as re,n as ae,o as ie}from"../chunks/scheduler.53228c21.js";import{S as de,i as me,e as m,s,c as f,h as le,a as l,d as o,b as r,f as q,g as c,j as Q,k as X,l as I,m as n,n as p,t as u,o as h,p as _}from"../chunks/index.100fac89.js";import{C as fe}from"../chunks/CopyLLMTxtMenu.b0ff86f3.js";import{D as se}from"../chunks/Docstring.db856a1e.js";import{C as ce}from"../chunks/CodeBlock.d30a6509.js";import{H as Y,E as pe}from"../chunks/MermaidChart.svelte_svelte_type_style_lang.136ef3fd.js";function ue(K){let a,Z,k,L,g,E,T,H,b,ee='A Diffusion Transformer model for 3D video-like data was introduced in <a href="https://huggingface.co/papers/2501.03575" rel="nofollow">Cosmos World Foundation Model Platform for Physical AI</a> by NVIDIA.',P,$,te="The model can be loaded with the following code snippet.",N,M,R,y,j,i,x,B,w,oe='A Transformer model for video-like data used in <a href="https://github.com/NVIDIA/Cosmos" rel="nofollow">Cosmos</a>.',V,D,W,d,v,F,z,ne='The output of <a href="/docs/diffusers/main/en/api/models/transformer2d#diffusers.Transformer2DModel">Transformer2DModel</a>.',O,C,U,J,A;return g=new fe({props:{containerStyle:"float: right; margin-left: 10px; display: inline-flex; position: relative; z-index: 10;"}}),T=new Y({props:{title:"CosmosTransformer3DModel",local:"cosmostransformer3dmodel",headingTag:"h1"}}),M=new ce({props:{code:"ZnJvbSUyMGRpZmZ1c2VycyUyMGltcG9ydCUyMENvc21vc1RyYW5zZm9ybWVyM0RNb2RlbCUwQSUwQXRyYW5zZm9ybWVyJTIwJTNEJTIwQ29zbW9zVHJhbnNmb3JtZXIzRE1vZGVsLmZyb21fcHJldHJhaW5lZCglMjJudmlkaWElMkZDb3Ntb3MtMS4wLURpZmZ1c2lvbi03Qi1UZXh0MldvcmxkJTIyJTJDJTIwc3ViZm9sZGVyJTNEJTIydHJhbnNmb3JtZXIlMjIlMkMlMjB0b3JjaF9kdHlwZSUzRHRvcmNoLmJmbG9hdDE2KQ==",highlighted:`<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> CosmosTransformer3DModel

transformer = CosmosTransformer3DModel.from_pretrained(<span class="hljs-string">&quot;nvidia/Cosmos-1.0-Diffusion-7B-Text2World&quot;</span>, subfolder=<span class="hljs-string">&quot;transformer&quot;</span>, torch_dtype=torch.bfloat16)`,wrap:!1}}),y=new Y({props:{title:"CosmosTransformer3DModel",local:"diffusers.CosmosTransformer3DModel",headingTag:"h2"}}),x=new se({props:{name:"class diffusers.CosmosTransformer3DModel",anchor:"diffusers.CosmosTransformer3DModel",parameters:[{name:"in_channels",val:": int = 16"},{name:"out_channels",val:": int = 16"},{name:"num_attention_heads",val:": int = 32"},{name:"attention_head_dim",val:": int = 128"},{name:"num_layers",val:": int = 28"},{name:"mlp_ratio",val:": float = 4.0"},{name:"text_embed_dim",val:": int = 1024"},{name:"adaln_lora_dim",val:": int = 256"},{name:"max_size",val:": typing.Tuple[int, int, int] = (128, 240, 240)"},{name:"patch_size",val:": typing.Tuple[int, int, int] = (1, 2, 2)"},{name:"rope_scale",val:": typing.Tuple[float, float, float] = (2.0, 1.0, 1.0)"},{name:"concat_padding_mask",val:": bool = True"},{name:"extra_pos_embed_type",val:": typing.Optional[str] = 'learnable'"}],parametersDescription:[{anchor:"diffusers.CosmosTransformer3DModel.in_channels",description:`<strong>in_channels</strong> (<code>int</code>, defaults to <code>16</code>) &#x2014;
The number of channels in the input.`,name:"in_channels"},{anchor:"diffusers.CosmosTransformer3DModel.out_channels",description:`<strong>out_channels</strong> (<code>int</code>, defaults to <code>16</code>) &#x2014;
The number of channels in the output.`,name:"out_channels"},{anchor:"diffusers.CosmosTransformer3DModel.num_attention_heads",description:`<strong>num_attention_heads</strong> (<code>int</code>, defaults to <code>32</code>) &#x2014;
The number of heads to use for multi-head attention.`,name:"num_attention_heads"},{anchor:"diffusers.CosmosTransformer3DModel.attention_head_dim",description:`<strong>attention_head_dim</strong> (<code>int</code>, defaults to <code>128</code>) &#x2014;
The number of channels in each attention head.`,name:"attention_head_dim"},{anchor:"diffusers.CosmosTransformer3DModel.num_layers",description:`<strong>num_layers</strong> (<code>int</code>, defaults to <code>28</code>) &#x2014;
The number of layers of transformer blocks to use.`,name:"num_layers"},{anchor:"diffusers.CosmosTransformer3DModel.mlp_ratio",description:`<strong>mlp_ratio</strong> (<code>float</code>, defaults to <code>4.0</code>) &#x2014;
The ratio of the hidden layer size to the input size in the feedforward network.`,name:"mlp_ratio"},{anchor:"diffusers.CosmosTransformer3DModel.text_embed_dim",description:`<strong>text_embed_dim</strong> (<code>int</code>, defaults to <code>4096</code>) &#x2014;
Input dimension of text embeddings from the text encoder.`,name:"text_embed_dim"},{anchor:"diffusers.CosmosTransformer3DModel.adaln_lora_dim",description:`<strong>adaln_lora_dim</strong> (<code>int</code>, defaults to <code>256</code>) &#x2014;
The hidden dimension of the Adaptive LayerNorm LoRA layer.`,name:"adaln_lora_dim"},{anchor:"diffusers.CosmosTransformer3DModel.max_size",description:`<strong>max_size</strong> (<code>Tuple[int, int, int]</code>, defaults to <code>(128, 240, 240)</code>) &#x2014;
The maximum size of the input latent tensors in the temporal, height, and width dimensions.`,name:"max_size"},{anchor:"diffusers.CosmosTransformer3DModel.patch_size",description:`<strong>patch_size</strong> (<code>Tuple[int, int, int]</code>, defaults to <code>(1, 2, 2)</code>) &#x2014;
The patch size to use for patchifying the input latent tensors in the temporal, height, and width
dimensions.`,name:"patch_size"},{anchor:"diffusers.CosmosTransformer3DModel.rope_scale",description:`<strong>rope_scale</strong> (<code>Tuple[float, float, float]</code>, defaults to <code>(2.0, 1.0, 1.0)</code>) &#x2014;
The scaling factor to use for RoPE in the temporal, height, and width dimensions.`,name:"rope_scale"},{anchor:"diffusers.CosmosTransformer3DModel.concat_padding_mask",description:`<strong>concat_padding_mask</strong> (<code>bool</code>, defaults to <code>True</code>) &#x2014;
Whether to concatenate the padding mask to the input latent tensors.`,name:"concat_padding_mask"},{anchor:"diffusers.CosmosTransformer3DModel.extra_pos_embed_type",description:`<strong>extra_pos_embed_type</strong> (<code>str</code>, <em>optional</em>, defaults to <code>learnable</code>) &#x2014;
The type of extra positional embeddings to use. Can be one of <code>None</code> or <code>learnable</code>.`,name:"extra_pos_embed_type"}],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/models/transformers/transformer_cosmos.py#L387"}}),D=new Y({props:{title:"Transformer2DModelOutput",local:"diffusers.models.modeling_outputs.Transformer2DModelOutput",headingTag:"h2"}}),v=new se({props:{name:"class diffusers.models.modeling_outputs.Transformer2DModelOutput",anchor:"diffusers.models.modeling_outputs.Transformer2DModelOutput",parameters:[{name:"sample",val:": torch.Tensor"}],parametersDescription:[{anchor:"diffusers.models.modeling_outputs.Transformer2DModelOutput.sample",description:`<strong>sample</strong> (<code>torch.Tensor</code> of shape <code>(batch_size, num_channels, height, width)</code> or <code>(batch size, num_vector_embeds - 1, num_latent_pixels)</code> if <a href="/docs/diffusers/main/en/api/models/transformer2d#diffusers.Transformer2DModel">Transformer2DModel</a> is discrete) &#x2014;
The hidden states output conditioned on the <code>encoder_hidden_states</code> input. If discrete, returns probability
distributions for the unnoised latent pixels.`,name:"sample"}],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/models/modeling_outputs.py#L21"}}),C=new pe({props:{source:"https://github.com/huggingface/diffusers/blob/main/docs/source/en/api/models/cosmos_transformer3d.md"}}),{c(){a=m("meta"),Z=s(),k=m("p"),L=s(),f(g.$$.fragment),E=s(),f(T.$$.fragment),H=s(),b=m("p"),b.innerHTML=ee,P=s(),$=m("p"),$.textContent=te,N=s(),f(M.$$.fragment),R=s(),f(y.$$.fragment),j=s(),i=m("div"),f(x.$$.fragment),B=s(),w=m("p"),w.innerHTML=oe,V=s(),f(D.$$.fragment),W=s(),d=m("div"),f(v.$$.fragment),F=s(),z=m("p"),z.innerHTML=ne,O=s(),f(C.$$.fragment),U=s(),J=m("p"),this.h()},l(e){const t=le("svelte-u9bgzb",document.head);a=l(t,"META",{name:!0,content:!0}),t.forEach(o),Z=r(e),k=l(e,"P",{}),q(k).forEach(o),L=r(e),c(g.$$.fragment,e),E=r(e),c(T.$$.fragment,e),H=r(e),b=l(e,"P",{"data-svelte-h":!0}),Q(b)!=="svelte-1pjw3fi"&&(b.innerHTML=ee),P=r(e),$=l(e,"P",{"data-svelte-h":!0}),Q($)!=="svelte-1vuni30"&&($.textContent=te),N=r(e),c(M.$$.fragment,e),R=r(e),c(y.$$.fragment,e),j=r(e),i=l(e,"DIV",{class:!0});var S=q(i);c(x.$$.fragment,S),B=r(S),w=l(S,"P",{"data-svelte-h":!0}),Q(w)!=="svelte-y8uhes"&&(w.innerHTML=oe),S.forEach(o),V=r(e),c(D.$$.fragment,e),W=r(e),d=l(e,"DIV",{class:!0});var G=q(d);c(v.$$.fragment,G),F=r(G),z=l(G,"P",{"data-svelte-h":!0}),Q(z)!=="svelte-1x8c0js"&&(z.innerHTML=ne),G.forEach(o),O=r(e),c(C.$$.fragment,e),U=r(e),J=l(e,"P",{}),q(J).forEach(o),this.h()},h(){X(a,"name","hf:doc:metadata"),X(a,"content",he),X(i,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),X(d,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8")},m(e,t){I(document.head,a),n(e,Z,t),n(e,k,t),n(e,L,t),p(g,e,t),n(e,E,t),p(T,e,t),n(e,H,t),n(e,b,t),n(e,P,t),n(e,$,t),n(e,N,t),p(M,e,t),n(e,R,t),p(y,e,t),n(e,j,t),n(e,i,t),p(x,i,null),I(i,B),I(i,w),n(e,V,t),p(D,e,t),n(e,W,t),n(e,d,t),p(v,d,null),I(d,F),I(d,z),n(e,O,t),p(C,e,t),n(e,U,t),n(e,J,t),A=!0},p:ae,i(e){A||(u(g.$$.fragment,e),u(T.$$.fragment,e),u(M.$$.fragment,e),u(y.$$.fragment,e),u(x.$$.fragment,e),u(D.$$.fragment,e),u(v.$$.fragment,e),u(C.$$.fragment,e),A=!0)},o(e){h(g.$$.fragment,e),h(T.$$.fragment,e),h(M.$$.fragment,e),h(y.$$.fragment,e),h(x.$$.fragment,e),h(D.$$.fragment,e),h(v.$$.fragment,e),h(C.$$.fragment,e),A=!1},d(e){e&&(o(Z),o(k),o(L),o(E),o(H),o(b),o(P),o($),o(N),o(R),o(j),o(i),o(V),o(W),o(d),o(O),o(U),o(J)),o(a),_(g,e),_(T,e),_(M,e),_(y,e),_(x),_(D,e),_(v),_(C,e)}}}const he='{"title":"CosmosTransformer3DModel","local":"cosmostransformer3dmodel","sections":[{"title":"CosmosTransformer3DModel","local":"diffusers.CosmosTransformer3DModel","sections":[],"depth":2},{"title":"Transformer2DModelOutput","local":"diffusers.models.modeling_outputs.Transformer2DModelOutput","sections":[],"depth":2}],"depth":1}';function _e(K){return ie(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class xe extends de{constructor(a){super(),me(this,a,_e,ue,re,{})}}export{xe as component};
