import{s as fe,n as ce,o as ue}from"../chunks/scheduler.53228c21.js";import{S as pe,i as he,e as r,s as a,c as f,h as ge,a as i,d as t,b as s,f as K,g as c,j as L,k as Q,l as A,m as o,n as u,t as p,o as h,p as g}from"../chunks/index.100fac89.js";import{C as _e}from"../chunks/CopyLLMTxtMenu.494046bd.js";import{D as me}from"../chunks/Docstring.9bbf7d33.js";import{C as Te}from"../chunks/CodeBlock.d30a6509.js";import{H as te,E as be}from"../chunks/MermaidChart.svelte_svelte_type_style_lang.8999c127.js";function ve(oe){let d,H,N,W,_,Z,T,P,b,ae='A Diffusion Transformer model for 3D data (video) from <a href="https://huggingface.co/papers/2509.24695" rel="nofollow">SANA-Video: Efficient Video Generation with Block Linear Diffusion Transformer</a> from NVIDIA and MIT HAN Lab, by Junsong Chen, Yuyang Zhao, Jincheng Yu, Ruihang Chu, Junyu Chen, Shuai Yang, Xianbang Wang, Yicheng Pan, Daquan Zhou, Huan Ling, Haozhe Liu, Hongwei Yi, Hao Zhang, Muyang Li, Yukang Chen, Han Cai, Sanja Fidler, Ping Luo, Song Han, Enze Xie.',j,v,se="The abstract from the paper is:",U,M,re="<em>We introduce SANA-Video, a small diffusion model that can efficiently generate videos up to 720x1280 resolution and minute-length duration. SANA-Video synthesizes high-resolution, high-quality and long videos with strong text-video alignment at a remarkably fast speed, deployable on RTX 5090 GPU. Two core designs ensure our efficient, effective and long video generation: (1) Linear DiT: We leverage linear attention as the core operation, which is more efficient than vanilla attention given the large number of tokens processed in video generation. (2) Constant-Memory KV cache for Block Linear Attention: we design block-wise autoregressive approach for long video generation by employing a constant-memory state, derived from the cumulative properties of linear attention. This KV cache provides the Linear DiT with global context at a fixed memory cost, eliminating the need for a traditional KV cache and enabling efficient, minute-long video generation. In addition, we explore effective data filters and model training strategies, narrowing the training cost to 12 days on 64 H100 GPUs, which is only 1% of the cost of MovieGen. Given its low cost, SANA-Video achieves competitive performance compared to modern state-of-the-art small diffusion models (e.g., Wan 2.1-1.3B and SkyReel-V2-1.3B) while being 16x faster in measured latency. Moreover, SANA-Video can be deployed on RTX 5090 GPUs with NVFP4 precision, accelerating the inference speed of generating a 5-second 720p video from 71s to 29s (2.4x speedup). In summary, SANA-Video enables low-cost, high-quality video generation.</em>",q,y,ie="The model can be loaded with the following code snippet.",B,$,R,D,E,l,V,ee,k,de='A 3D Transformer model introduced in <a href="https://huggingface.co/papers/2509.24695" rel="nofollow">Sana-Video</a> family of models.',F,x,J,m,w,ne,C,le='The output of <a href="/docs/diffusers/main/en/api/models/transformer2d#diffusers.Transformer2DModel">Transformer2DModel</a>.',O,S,G,z,Y;return _=new _e({props:{containerStyle:"float: right; margin-left: 10px; display: inline-flex; position: relative; z-index: 10;"}}),T=new te({props:{title:"SanaVideoTransformer3DModel",local:"sanavideotransformer3dmodel",headingTag:"h1"}}),$=new Te({props:{code:"ZnJvbSUyMGRpZmZ1c2VycyUyMGltcG9ydCUyMFNhbmFWaWRlb1RyYW5zZm9ybWVyM0RNb2RlbCUwQWltcG9ydCUyMHRvcmNoJTBBJTBBdHJhbnNmb3JtZXIlMjAlM0QlMjBTYW5hVmlkZW9UcmFuc2Zvcm1lcjNETW9kZWwuZnJvbV9wcmV0cmFpbmVkKCUyMkVmZmljaWVudC1MYXJnZS1Nb2RlbCUyRlNBTkEtVmlkZW9fMkJfNDgwcF9kaWZmdXNlcnMlMjIlMkMlMjBzdWJmb2xkZXIlM0QlMjJ0cmFuc2Zvcm1lciUyMiUyQyUyMHRvcmNoX2R0eXBlJTNEdG9yY2guYmZsb2F0MTYp",highlighted:`<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> SanaVideoTransformer3DModel
<span class="hljs-keyword">import</span> torch

transformer = SanaVideoTransformer3DModel.from_pretrained(<span class="hljs-string">&quot;Efficient-Large-Model/SANA-Video_2B_480p_diffusers&quot;</span>, subfolder=<span class="hljs-string">&quot;transformer&quot;</span>, torch_dtype=torch.bfloat16)`,wrap:!1}}),D=new te({props:{title:"SanaVideoTransformer3DModel",local:"diffusers.SanaVideoTransformer3DModel",headingTag:"h2"}}),V=new me({props:{name:"class diffusers.SanaVideoTransformer3DModel",anchor:"diffusers.SanaVideoTransformer3DModel",parameters:[{name:"in_channels",val:": int = 16"},{name:"out_channels",val:": typing.Optional[int] = 16"},{name:"num_attention_heads",val:": int = 20"},{name:"attention_head_dim",val:": int = 112"},{name:"num_layers",val:": int = 20"},{name:"num_cross_attention_heads",val:": typing.Optional[int] = 20"},{name:"cross_attention_head_dim",val:": typing.Optional[int] = 112"},{name:"cross_attention_dim",val:": typing.Optional[int] = 2240"},{name:"caption_channels",val:": int = 2304"},{name:"mlp_ratio",val:": float = 2.5"},{name:"dropout",val:": float = 0.0"},{name:"attention_bias",val:": bool = False"},{name:"sample_size",val:": int = 30"},{name:"patch_size",val:": typing.Tuple[int, int, int] = (1, 2, 2)"},{name:"norm_elementwise_affine",val:": bool = False"},{name:"norm_eps",val:": float = 1e-06"},{name:"interpolation_scale",val:": typing.Optional[int] = None"},{name:"guidance_embeds",val:": bool = False"},{name:"guidance_embeds_scale",val:": float = 0.1"},{name:"qk_norm",val:": typing.Optional[str] = 'rms_norm_across_heads'"},{name:"rope_max_seq_len",val:": int = 1024"}],parametersDescription:[{anchor:"diffusers.SanaVideoTransformer3DModel.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.SanaVideoTransformer3DModel.out_channels",description:`<strong>out_channels</strong> (<code>int</code>, <em>optional</em>, defaults to <code>16</code>) &#x2014;
The number of channels in the output.`,name:"out_channels"},{anchor:"diffusers.SanaVideoTransformer3DModel.num_attention_heads",description:`<strong>num_attention_heads</strong> (<code>int</code>, defaults to <code>20</code>) &#x2014;
The number of heads to use for multi-head attention.`,name:"num_attention_heads"},{anchor:"diffusers.SanaVideoTransformer3DModel.attention_head_dim",description:`<strong>attention_head_dim</strong> (<code>int</code>, defaults to <code>112</code>) &#x2014;
The number of channels in each head.`,name:"attention_head_dim"},{anchor:"diffusers.SanaVideoTransformer3DModel.num_layers",description:`<strong>num_layers</strong> (<code>int</code>, defaults to <code>20</code>) &#x2014;
The number of layers of Transformer blocks to use.`,name:"num_layers"},{anchor:"diffusers.SanaVideoTransformer3DModel.num_cross_attention_heads",description:`<strong>num_cross_attention_heads</strong> (<code>int</code>, <em>optional</em>, defaults to <code>20</code>) &#x2014;
The number of heads to use for cross-attention.`,name:"num_cross_attention_heads"},{anchor:"diffusers.SanaVideoTransformer3DModel.cross_attention_head_dim",description:`<strong>cross_attention_head_dim</strong> (<code>int</code>, <em>optional</em>, defaults to <code>112</code>) &#x2014;
The number of channels in each head for cross-attention.`,name:"cross_attention_head_dim"},{anchor:"diffusers.SanaVideoTransformer3DModel.cross_attention_dim",description:`<strong>cross_attention_dim</strong> (<code>int</code>, <em>optional</em>, defaults to <code>2240</code>) &#x2014;
The number of channels in the cross-attention output.`,name:"cross_attention_dim"},{anchor:"diffusers.SanaVideoTransformer3DModel.caption_channels",description:`<strong>caption_channels</strong> (<code>int</code>, defaults to <code>2304</code>) &#x2014;
The number of channels in the caption embeddings.`,name:"caption_channels"},{anchor:"diffusers.SanaVideoTransformer3DModel.mlp_ratio",description:`<strong>mlp_ratio</strong> (<code>float</code>, defaults to <code>2.5</code>) &#x2014;
The expansion ratio to use in the GLUMBConv layer.`,name:"mlp_ratio"},{anchor:"diffusers.SanaVideoTransformer3DModel.dropout",description:`<strong>dropout</strong> (<code>float</code>, defaults to <code>0.0</code>) &#x2014;
The dropout probability.`,name:"dropout"},{anchor:"diffusers.SanaVideoTransformer3DModel.attention_bias",description:`<strong>attention_bias</strong> (<code>bool</code>, defaults to <code>False</code>) &#x2014;
Whether to use bias in the attention layer.`,name:"attention_bias"},{anchor:"diffusers.SanaVideoTransformer3DModel.sample_size",description:`<strong>sample_size</strong> (<code>int</code>, defaults to <code>32</code>) &#x2014;
The base size of the input latent.`,name:"sample_size"},{anchor:"diffusers.SanaVideoTransformer3DModel.patch_size",description:`<strong>patch_size</strong> (<code>int</code>, defaults to <code>1</code>) &#x2014;
The size of the patches to use in the patch embedding layer.`,name:"patch_size"},{anchor:"diffusers.SanaVideoTransformer3DModel.norm_elementwise_affine",description:`<strong>norm_elementwise_affine</strong> (<code>bool</code>, defaults to <code>False</code>) &#x2014;
Whether to use elementwise affinity in the normalization layer.`,name:"norm_elementwise_affine"},{anchor:"diffusers.SanaVideoTransformer3DModel.norm_eps",description:`<strong>norm_eps</strong> (<code>float</code>, defaults to <code>1e-6</code>) &#x2014;
The epsilon value for the normalization layer.`,name:"norm_eps"},{anchor:"diffusers.SanaVideoTransformer3DModel.qk_norm",description:`<strong>qk_norm</strong> (<code>str</code>, <em>optional</em>, defaults to <code>None</code>) &#x2014;
The normalization to use for the query and key.`,name:"qk_norm"}],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/models/transformers/transformer_sana_video.py#L458"}}),x=new te({props:{title:"Transformer2DModelOutput",local:"diffusers.models.modeling_outputs.Transformer2DModelOutput",headingTag:"h2"}}),w=new me({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"}}),S=new be({props:{source:"https://github.com/huggingface/diffusers/blob/main/docs/source/en/api/models/sana_video_transformer3d.md"}}),{c(){d=r("meta"),H=a(),N=r("p"),W=a(),f(_.$$.fragment),Z=a(),f(T.$$.fragment),P=a(),b=r("p"),b.innerHTML=ae,j=a(),v=r("p"),v.textContent=se,U=a(),M=r("p"),M.innerHTML=re,q=a(),y=r("p"),y.textContent=ie,B=a(),f($.$$.fragment),R=a(),f(D.$$.fragment),E=a(),l=r("div"),f(V.$$.fragment),ee=a(),k=r("p"),k.innerHTML=de,F=a(),f(x.$$.fragment),J=a(),m=r("div"),f(w.$$.fragment),ne=a(),C=r("p"),C.innerHTML=le,O=a(),f(S.$$.fragment),G=a(),z=r("p"),this.h()},l(e){const n=ge("svelte-u9bgzb",document.head);d=i(n,"META",{name:!0,content:!0}),n.forEach(t),H=s(e),N=i(e,"P",{}),K(N).forEach(t),W=s(e),c(_.$$.fragment,e),Z=s(e),c(T.$$.fragment,e),P=s(e),b=i(e,"P",{"data-svelte-h":!0}),L(b)!=="svelte-1l9qij5"&&(b.innerHTML=ae),j=s(e),v=i(e,"P",{"data-svelte-h":!0}),L(v)!=="svelte-1cwsb16"&&(v.textContent=se),U=s(e),M=i(e,"P",{"data-svelte-h":!0}),L(M)!=="svelte-1dxpb6d"&&(M.innerHTML=re),q=s(e),y=i(e,"P",{"data-svelte-h":!0}),L(y)!=="svelte-1vuni30"&&(y.textContent=ie),B=s(e),c($.$$.fragment,e),R=s(e),c(D.$$.fragment,e),E=s(e),l=i(e,"DIV",{class:!0});var I=K(l);c(V.$$.fragment,I),ee=s(I),k=i(I,"P",{"data-svelte-h":!0}),L(k)!=="svelte-1aoikol"&&(k.innerHTML=de),I.forEach(t),F=s(e),c(x.$$.fragment,e),J=s(e),m=i(e,"DIV",{class:!0});var X=K(m);c(w.$$.fragment,X),ne=s(X),C=i(X,"P",{"data-svelte-h":!0}),L(C)!=="svelte-1x8c0js"&&(C.innerHTML=le),X.forEach(t),O=s(e),c(S.$$.fragment,e),G=s(e),z=i(e,"P",{}),K(z).forEach(t),this.h()},h(){Q(d,"name","hf:doc:metadata"),Q(d,"content",Me),Q(l,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),Q(m,"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,n){A(document.head,d),o(e,H,n),o(e,N,n),o(e,W,n),u(_,e,n),o(e,Z,n),u(T,e,n),o(e,P,n),o(e,b,n),o(e,j,n),o(e,v,n),o(e,U,n),o(e,M,n),o(e,q,n),o(e,y,n),o(e,B,n),u($,e,n),o(e,R,n),u(D,e,n),o(e,E,n),o(e,l,n),u(V,l,null),A(l,ee),A(l,k),o(e,F,n),u(x,e,n),o(e,J,n),o(e,m,n),u(w,m,null),A(m,ne),A(m,C),o(e,O,n),u(S,e,n),o(e,G,n),o(e,z,n),Y=!0},p:ce,i(e){Y||(p(_.$$.fragment,e),p(T.$$.fragment,e),p($.$$.fragment,e),p(D.$$.fragment,e),p(V.$$.fragment,e),p(x.$$.fragment,e),p(w.$$.fragment,e),p(S.$$.fragment,e),Y=!0)},o(e){h(_.$$.fragment,e),h(T.$$.fragment,e),h($.$$.fragment,e),h(D.$$.fragment,e),h(V.$$.fragment,e),h(x.$$.fragment,e),h(w.$$.fragment,e),h(S.$$.fragment,e),Y=!1},d(e){e&&(t(H),t(N),t(W),t(Z),t(P),t(b),t(j),t(v),t(U),t(M),t(q),t(y),t(B),t(R),t(E),t(l),t(F),t(J),t(m),t(O),t(G),t(z)),t(d),g(_,e),g(T,e),g($,e),g(D,e),g(V),g(x,e),g(w),g(S,e)}}}const Me='{"title":"SanaVideoTransformer3DModel","local":"sanavideotransformer3dmodel","sections":[{"title":"SanaVideoTransformer3DModel","local":"diffusers.SanaVideoTransformer3DModel","sections":[],"depth":2},{"title":"Transformer2DModelOutput","local":"diffusers.models.modeling_outputs.Transformer2DModelOutput","sections":[],"depth":2}],"depth":1}';function ye(oe){return ue(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class ke extends pe{constructor(d){super(),he(this,d,ye,ve,fe,{})}}export{ke as component};
