Buckets:

HuggingFaceDocBuilder's picture
download
raw
14.9 kB
import{s as we,n as ye,o as ke}from"../chunks/scheduler.53228c21.js";import{S as Se,i as je,e as d,s as r,c as p,h as ze,a as i,d as n,b as s,f as H,g as h,j as x,k as _,l as t,m as c,n as g,t as b,o as T,p as D}from"../chunks/index.100fac89.js";import{C as Le}from"../chunks/CopyLLMTxtMenu.af3e1493.js";import{D as F}from"../chunks/Docstring.147b33f1.js";import{H as Me,E as Ce}from"../chunks/MermaidChart.svelte_svelte_type_style_lang.b5eefd91.js";function qe(he){let u,G,U,R,M,W,w,J,y,_e='The Transformer model introduced in <a href="https://hf.co/papers/2403.03206" rel="nofollow">Stable Diffusion 3</a>. Its novelty lies in the MMDiT transformer block.',X,k,Y,a,S,re,N,ge='The Transformer model introduced in <a href="https://huggingface.co/papers/2403.03206" rel="nofollow">Stable Diffusion 3</a>.',se,v,j,ae,I,be=`Sets the attention processor to use <a href="https://huggingface.co/blog/reformer#2-chunked-feed-forward-layers" rel="nofollow">feed forward
chunking</a>.`,de,$,z,ie,A,Te='The <a href="/docs/diffusers/pr_13751/en/api/models/sd3_transformer2d#diffusers.SD3Transformer2DModel">SD3Transformer2DModel</a> forward method.',le,m,L,ce,O,De=`Enables fused QKV projections. For self-attention modules, all projection matrices (i.e., query, key, value)
are fused. For cross-attention modules, key and value projection matrices are fused.`,me,C,ve="<p>&gt; This API is 🧪 experimental.</p>",fe,f,q,ue,V,$e="Disables the fused QKV projection if enabled.",pe,P,xe="<p>&gt; This API is 🧪 experimental.</p>",Z,E,ee,B,te;return M=new Le({props:{containerStyle:"float: right; margin-left: 10px; display: inline-flex; position: relative; z-index: 10;"}}),w=new Me({props:{title:"SD3 Transformer Model",local:"sd3-transformer-model",headingTag:"h1"}}),k=new Me({props:{title:"SD3Transformer2DModel",local:"diffusers.SD3Transformer2DModel",headingTag:"h2"}}),S=new F({props:{name:"class diffusers.SD3Transformer2DModel",anchor:"diffusers.SD3Transformer2DModel",parameters:[{name:"sample_size",val:": int = 128"},{name:"patch_size",val:": int = 2"},{name:"in_channels",val:": int = 16"},{name:"num_layers",val:": int = 18"},{name:"attention_head_dim",val:": int = 64"},{name:"num_attention_heads",val:": int = 18"},{name:"joint_attention_dim",val:": int = 4096"},{name:"caption_projection_dim",val:": int = 1152"},{name:"pooled_projection_dim",val:": int = 2048"},{name:"out_channels",val:": int = 16"},{name:"pos_embed_max_size",val:": int = 96"},{name:"dual_attention_layers",val:": tuple = ()"},{name:"qk_norm",val:": str | None = None"}],parametersDescription:[{anchor:"diffusers.SD3Transformer2DModel.sample_size",description:`<strong>sample_size</strong> (<code>int</code>, defaults to <code>128</code>) &#x2014;
The width/height of the latents. This is fixed during training since it is used to learn a number of
position embeddings.`,name:"sample_size"},{anchor:"diffusers.SD3Transformer2DModel.patch_size",description:`<strong>patch_size</strong> (<code>int</code>, defaults to <code>2</code>) &#x2014;
Patch size to turn the input data into small patches.`,name:"patch_size"},{anchor:"diffusers.SD3Transformer2DModel.in_channels",description:`<strong>in_channels</strong> (<code>int</code>, defaults to <code>16</code>) &#x2014;
The number of latent channels in the input.`,name:"in_channels"},{anchor:"diffusers.SD3Transformer2DModel.num_layers",description:`<strong>num_layers</strong> (<code>int</code>, defaults to <code>18</code>) &#x2014;
The number of layers of transformer blocks to use.`,name:"num_layers"},{anchor:"diffusers.SD3Transformer2DModel.attention_head_dim",description:`<strong>attention_head_dim</strong> (<code>int</code>, defaults to <code>64</code>) &#x2014;
The number of channels in each head.`,name:"attention_head_dim"},{anchor:"diffusers.SD3Transformer2DModel.num_attention_heads",description:`<strong>num_attention_heads</strong> (<code>int</code>, defaults to <code>18</code>) &#x2014;
The number of heads to use for multi-head attention.`,name:"num_attention_heads"},{anchor:"diffusers.SD3Transformer2DModel.joint_attention_dim",description:`<strong>joint_attention_dim</strong> (<code>int</code>, defaults to <code>4096</code>) &#x2014;
The embedding dimension to use for joint text-image attention.`,name:"joint_attention_dim"},{anchor:"diffusers.SD3Transformer2DModel.caption_projection_dim",description:`<strong>caption_projection_dim</strong> (<code>int</code>, defaults to <code>1152</code>) &#x2014;
The embedding dimension of caption embeddings.`,name:"caption_projection_dim"},{anchor:"diffusers.SD3Transformer2DModel.pooled_projection_dim",description:`<strong>pooled_projection_dim</strong> (<code>int</code>, defaults to <code>2048</code>) &#x2014;
The embedding dimension of pooled text projections.`,name:"pooled_projection_dim"},{anchor:"diffusers.SD3Transformer2DModel.out_channels",description:`<strong>out_channels</strong> (<code>int</code>, defaults to <code>16</code>) &#x2014;
The number of latent channels in the output.`,name:"out_channels"},{anchor:"diffusers.SD3Transformer2DModel.pos_embed_max_size",description:`<strong>pos_embed_max_size</strong> (<code>int</code>, defaults to <code>96</code>) &#x2014;
The maximum latent height/width of positional embeddings.`,name:"pos_embed_max_size"},{anchor:"diffusers.SD3Transformer2DModel.dual_attention_layers",description:`<strong>dual_attention_layers</strong> (<code>tuple[int, ...]</code>, defaults to <code>()</code>) &#x2014;
The number of dual-stream transformer blocks to use.`,name:"dual_attention_layers"},{anchor:"diffusers.SD3Transformer2DModel.qk_norm",description:`<strong>qk_norm</strong> (<code>str</code>, <em>optional</em>, defaults to <code>None</code>) &#x2014;
The normalization to use for query and key in the attention layer. If <code>None</code>, no normalization is used.`,name:"qk_norm"}],source:"https://github.com/huggingface/diffusers/blob/vr_13751/src/diffusers/models/transformers/transformer_sd3.py#L79"}}),j=new F({props:{name:"enable_forward_chunking",anchor:"diffusers.SD3Transformer2DModel.enable_forward_chunking",parameters:[{name:"chunk_size",val:": int | None = None"},{name:"dim",val:": int = 0"}],parametersDescription:[{anchor:"diffusers.SD3Transformer2DModel.enable_forward_chunking.chunk_size",description:`<strong>chunk_size</strong> (<code>int</code>, <em>optional</em>) &#x2014;
The chunk size of the feed-forward layers. If not specified, will run feed-forward layer individually
over each tensor of dim=<code>dim</code>.`,name:"chunk_size"},{anchor:"diffusers.SD3Transformer2DModel.enable_forward_chunking.dim",description:`<strong>dim</strong> (<code>int</code>, <em>optional</em>, defaults to <code>0</code>) &#x2014;
The dimension over which the feed-forward computation should be chunked. Choose between dim=0 (batch)
or dim=1 (sequence length).`,name:"dim"}],source:"https://github.com/huggingface/diffusers/blob/vr_13751/src/diffusers/models/transformers/transformer_sd3.py#L175"}}),z=new F({props:{name:"forward",anchor:"diffusers.SD3Transformer2DModel.forward",parameters:[{name:"hidden_states",val:": Tensor"},{name:"encoder_hidden_states",val:": Tensor = None"},{name:"pooled_projections",val:": Tensor = None"},{name:"timestep",val:": LongTensor = None"},{name:"block_controlnet_hidden_states",val:": list = None"},{name:"joint_attention_kwargs",val:": dict[str, typing.Any] | None = None"},{name:"return_dict",val:": bool = True"},{name:"skip_layers",val:": list[int] | None = None"}],parametersDescription:[{anchor:"diffusers.SD3Transformer2DModel.forward.hidden_states",description:`<strong>hidden_states</strong> (<code>torch.Tensor</code> of shape <code>(batch size, channel, height, width)</code>) &#x2014;
Input <code>hidden_states</code>.`,name:"hidden_states"},{anchor:"diffusers.SD3Transformer2DModel.forward.encoder_hidden_states",description:`<strong>encoder_hidden_states</strong> (<code>torch.Tensor</code> of shape <code>(batch size, sequence_len, embed_dims)</code>) &#x2014;
Conditional embeddings (embeddings computed from the input conditions such as prompts) to use.`,name:"encoder_hidden_states"},{anchor:"diffusers.SD3Transformer2DModel.forward.pooled_projections",description:`<strong>pooled_projections</strong> (<code>torch.Tensor</code> of shape <code>(batch_size, projection_dim)</code>) &#x2014;
Embeddings projected from the embeddings of input conditions.`,name:"pooled_projections"},{anchor:"diffusers.SD3Transformer2DModel.forward.timestep",description:`<strong>timestep</strong> (<code>torch.LongTensor</code>) &#x2014;
Used to indicate denoising step.`,name:"timestep"},{anchor:"diffusers.SD3Transformer2DModel.forward.block_controlnet_hidden_states",description:`<strong>block_controlnet_hidden_states</strong> (<code>list</code> of <code>torch.Tensor</code>) &#x2014;
A list of tensors that if specified are added to the residuals of transformer blocks.`,name:"block_controlnet_hidden_states"},{anchor:"diffusers.SD3Transformer2DModel.forward.joint_attention_kwargs",description:`<strong>joint_attention_kwargs</strong> (<code>dict</code>, <em>optional</em>) &#x2014;
A kwargs dictionary that if specified is passed along to the <code>AttentionProcessor</code> as defined under
<code>self.processor</code> in
<a href="https://github.com/huggingface/diffusers/blob/main/src/diffusers/models/attention_processor.py" rel="nofollow">diffusers.models.attention_processor</a>.`,name:"joint_attention_kwargs"},{anchor:"diffusers.SD3Transformer2DModel.forward.return_dict",description:`<strong>return_dict</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
Whether or not to return a <code>~models.transformer_2d.Transformer2DModelOutput</code> instead of a plain
tuple.`,name:"return_dict"},{anchor:"diffusers.SD3Transformer2DModel.forward.skip_layers",description:`<strong>skip_layers</strong> (<code>list</code> of <code>int</code>, <em>optional</em>) &#x2014;
A list of layer indices to skip during the forward pass.`,name:"skip_layers"}],source:"https://github.com/huggingface/diffusers/blob/vr_13751/src/diffusers/models/transformers/transformer_sd3.py#L248",returnDescription:`<script context="module">export const metadata = 'undefined';<\/script>
<p>If <code>return_dict</code> is True, an <code>~models.transformer_2d.Transformer2DModelOutput</code> is returned, otherwise a
<code>tuple</code> where the first element is the sample tensor.</p>
`}}),L=new F({props:{name:"fuse_qkv_projections",anchor:"diffusers.SD3Transformer2DModel.fuse_qkv_projections",parameters:[],source:"https://github.com/huggingface/diffusers/blob/vr_13751/src/diffusers/models/transformers/transformer_sd3.py#L217"}}),q=new F({props:{name:"unfuse_qkv_projections",anchor:"diffusers.SD3Transformer2DModel.unfuse_qkv_projections",parameters:[],source:"https://github.com/huggingface/diffusers/blob/vr_13751/src/diffusers/models/transformers/transformer_sd3.py#L239"}}),E=new Ce({props:{source:"https://github.com/huggingface/diffusers/blob/main/docs/source/en/api/models/sd3_transformer2d.md"}}),{c(){u=d("meta"),G=r(),U=d("p"),R=r(),p(M.$$.fragment),W=r(),p(w.$$.fragment),J=r(),y=d("p"),y.innerHTML=_e,X=r(),p(k.$$.fragment),Y=r(),a=d("div"),p(S.$$.fragment),re=r(),N=d("p"),N.innerHTML=ge,se=r(),v=d("div"),p(j.$$.fragment),ae=r(),I=d("p"),I.innerHTML=be,de=r(),$=d("div"),p(z.$$.fragment),ie=r(),A=d("p"),A.innerHTML=Te,le=r(),m=d("div"),p(L.$$.fragment),ce=r(),O=d("p"),O.textContent=De,me=r(),C=d("blockquote"),C.innerHTML=ve,fe=r(),f=d("div"),p(q.$$.fragment),ue=r(),V=d("p"),V.textContent=$e,pe=r(),P=d("blockquote"),P.innerHTML=xe,Z=r(),p(E.$$.fragment),ee=r(),B=d("p"),this.h()},l(e){const o=ze("svelte-u9bgzb",document.head);u=i(o,"META",{name:!0,content:!0}),o.forEach(n),G=s(e),U=i(e,"P",{}),H(U).forEach(n),R=s(e),h(M.$$.fragment,e),W=s(e),h(w.$$.fragment,e),J=s(e),y=i(e,"P",{"data-svelte-h":!0}),x(y)!=="svelte-hv1bl6"&&(y.innerHTML=_e),X=s(e),h(k.$$.fragment,e),Y=s(e),a=i(e,"DIV",{class:!0});var l=H(a);h(S.$$.fragment,l),re=s(l),N=i(l,"P",{"data-svelte-h":!0}),x(N)!=="svelte-18dv5mn"&&(N.innerHTML=ge),se=s(l),v=i(l,"DIV",{class:!0});var ne=H(v);h(j.$$.fragment,ne),ae=s(ne),I=i(ne,"P",{"data-svelte-h":!0}),x(I)!=="svelte-2m23sy"&&(I.innerHTML=be),ne.forEach(n),de=s(l),$=i(l,"DIV",{class:!0});var oe=H($);h(z.$$.fragment,oe),ie=s(oe),A=i(oe,"P",{"data-svelte-h":!0}),x(A)!=="svelte-nqknuo"&&(A.innerHTML=Te),oe.forEach(n),le=s(l),m=i(l,"DIV",{class:!0});var K=H(m);h(L.$$.fragment,K),ce=s(K),O=i(K,"P",{"data-svelte-h":!0}),x(O)!=="svelte-1254b9i"&&(O.textContent=De),me=s(K),C=i(K,"BLOCKQUOTE",{class:!0,"data-svelte-h":!0}),x(C)!=="svelte-6y4o4y"&&(C.innerHTML=ve),K.forEach(n),fe=s(l),f=i(l,"DIV",{class:!0});var Q=H(f);h(q.$$.fragment,Q),ue=s(Q),V=i(Q,"P",{"data-svelte-h":!0}),x(V)!=="svelte-1vhtc74"&&(V.textContent=$e),pe=s(Q),P=i(Q,"BLOCKQUOTE",{class:!0,"data-svelte-h":!0}),x(P)!=="svelte-6y4o4y"&&(P.innerHTML=xe),Q.forEach(n),l.forEach(n),Z=s(e),h(E.$$.fragment,e),ee=s(e),B=i(e,"P",{}),H(B).forEach(n),this.h()},h(){_(u,"name","hf:doc:metadata"),_(u,"content",Pe),_(v,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),_($,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),_(C,"class","warning"),_(m,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),_(P,"class","warning"),_(f,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),_(a,"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,o){t(document.head,u),c(e,G,o),c(e,U,o),c(e,R,o),g(M,e,o),c(e,W,o),g(w,e,o),c(e,J,o),c(e,y,o),c(e,X,o),g(k,e,o),c(e,Y,o),c(e,a,o),g(S,a,null),t(a,re),t(a,N),t(a,se),t(a,v),g(j,v,null),t(v,ae),t(v,I),t(a,de),t(a,$),g(z,$,null),t($,ie),t($,A),t(a,le),t(a,m),g(L,m,null),t(m,ce),t(m,O),t(m,me),t(m,C),t(a,fe),t(a,f),g(q,f,null),t(f,ue),t(f,V),t(f,pe),t(f,P),c(e,Z,o),g(E,e,o),c(e,ee,o),c(e,B,o),te=!0},p:ye,i(e){te||(b(M.$$.fragment,e),b(w.$$.fragment,e),b(k.$$.fragment,e),b(S.$$.fragment,e),b(j.$$.fragment,e),b(z.$$.fragment,e),b(L.$$.fragment,e),b(q.$$.fragment,e),b(E.$$.fragment,e),te=!0)},o(e){T(M.$$.fragment,e),T(w.$$.fragment,e),T(k.$$.fragment,e),T(S.$$.fragment,e),T(j.$$.fragment,e),T(z.$$.fragment,e),T(L.$$.fragment,e),T(q.$$.fragment,e),T(E.$$.fragment,e),te=!1},d(e){e&&(n(G),n(U),n(R),n(W),n(J),n(y),n(X),n(Y),n(a),n(Z),n(ee),n(B)),n(u),D(M,e),D(w,e),D(k,e),D(S),D(j),D(z),D(L),D(q),D(E,e)}}}const Pe='{"title":"SD3 Transformer Model","local":"sd3-transformer-model","sections":[{"title":"SD3Transformer2DModel","local":"diffusers.SD3Transformer2DModel","sections":[],"depth":2}],"depth":1}';function Ee(he){return ke(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Ve extends Se{constructor(u){super(),je(this,u,Ee,qe,we,{})}}export{Ve as component};

Xet Storage Details

Size:
14.9 kB
·
Xet hash:
0e830456634f781ef061751c6125b28fa7cb44a86688cf953e9742a62d71b697

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.