Buckets:

download
raw
10.7 kB
import"../chunks/DsnmJJEf.js";import{i as k,h as T,C as y,H as m,D as l,E as M,s as D}from"../chunks/CmJXCtRL.js";import{p as w,o as K,s as e,f as z,a as f,b as q,c as _,d as p,n as h,r as u}from"../chunks/DK803DsY.js";const N='{"title":"Krea2Transformer2DModel","local":"krea2transformer2dmodel","sections":[{"title":"Krea2Transformer2DModel","local":"diffusers.Krea2Transformer2DModel","sections":[],"depth":2}],"depth":1}';var L=p('<meta name="hf:doc:metadata"/>'),P=p(`<p></p> <!> <!> <p>The single-stream MMDiT flow-matching transformer used by <a href="https://github.com/krea-ai/krea-2" rel="nofollow">Krea 2</a>.</p> <!> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>The single-stream MMDiT flow-matching backbone used by the Krea 2 pipeline.</p> <p>Text conditioning enters as a stack of hidden states tapped from several layers of a multimodal text encoder. A
small text-fusion transformer collapses the layer axis and refines the token sequence; the result is concatenated
with the patchified image latents into a single <code>[text, image]</code> sequence processed by the transformer blocks. The
timestep conditions every block through one shared modulation vector plus per-block learned tables.</p> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Predict the flow-matching velocity for the image tokens.</p></div></div> <!> <p></p>`,1);function H(g,x){w(x,!1),K(()=>{new URLSearchParams(window.location.search).get("fw")}),k();var o=P();T("rors4q",i=>{var c=L();D(c,"content",N),f(i,c)});var r=e(z(o),2);y(r,{containerStyle:"float: right; margin-left: 10px; display: inline-flex; position: relative; z-index: 10;"});var n=e(r,2);m(n,{title:"Krea2Transformer2DModel",local:"krea2transformer2dmodel",headingTag:"h1"});var a=e(n,4);m(a,{title:"Krea2Transformer2DModel",local:"diffusers.Krea2Transformer2DModel",headingTag:"h2"});var t=e(a,2),s=_(t);l(s,{name:"class diffusers.Krea2Transformer2DModel",anchor:"diffusers.Krea2Transformer2DModel",source:"https://github.com/huggingface/diffusers/blob/vr_13881/src/diffusers/models/transformers/transformer_krea2.py#L330",parameters:[{name:"in_channels",val:": int = 64"},{name:"num_layers",val:": int = 28"},{name:"attention_head_dim",val:": int = 128"},{name:"num_attention_heads",val:": int = 48"},{name:"num_key_value_heads",val:": int = 12"},{name:"intermediate_size",val:": int = 16384"},{name:"timestep_embed_dim",val:": int = 256"},{name:"text_hidden_dim",val:": int = 2560"},{name:"num_text_layers",val:": int = 12"},{name:"text_num_attention_heads",val:": int = 20"},{name:"text_num_key_value_heads",val:": int = 20"},{name:"text_intermediate_size",val:": int = 6912"},{name:"num_layerwise_text_blocks",val:": int = 2"},{name:"num_refiner_text_blocks",val:": int = 2"},{name:"axes_dims_rope",val:": tuple = (32, 48, 48)"},{name:"rope_theta",val:": float = 1000.0"},{name:"norm_eps",val:": float = 1e-05"}],parametersDescription:[{anchor:"diffusers.Krea2Transformer2DModel.in_channels",description:`<strong>in_channels</strong> (<code>int</code>, defaults to 64) &#x2014;
Latent channel count after patchification (<code>vae_channels * patch_size ** 2</code>).`,name:"in_channels"},{anchor:"diffusers.Krea2Transformer2DModel.num_layers",description:`<strong>num_layers</strong> (<code>int</code>, defaults to 28) &#x2014;
Number of transformer blocks.`,name:"num_layers"},{anchor:"diffusers.Krea2Transformer2DModel.attention_head_dim",description:`<strong>attention_head_dim</strong> (<code>int</code>, defaults to 128) &#x2014;
Dimension of each attention head; the total hidden size is <code>attention_head_dim * num_attention_heads</code>.`,name:"attention_head_dim"},{anchor:"diffusers.Krea2Transformer2DModel.num_attention_heads",description:`<strong>num_attention_heads</strong> (<code>int</code>, defaults to 48) &#x2014;
Number of query heads.`,name:"num_attention_heads"},{anchor:"diffusers.Krea2Transformer2DModel.num_key_value_heads",description:`<strong>num_key_value_heads</strong> (<code>int</code>, defaults to 12) &#x2014;
Number of key/value heads for grouped-query attention.`,name:"num_key_value_heads"},{anchor:"diffusers.Krea2Transformer2DModel.intermediate_size",description:`<strong>intermediate_size</strong> (<code>int</code>, defaults to 16384) &#x2014;
Feed-forward hidden size of the SwiGLU MLP inside each block.`,name:"intermediate_size"},{anchor:"diffusers.Krea2Transformer2DModel.timestep_embed_dim",description:`<strong>timestep_embed_dim</strong> (<code>int</code>, defaults to 256) &#x2014;
Width of the sinusoidal timestep embedding before its MLP.`,name:"timestep_embed_dim"},{anchor:"diffusers.Krea2Transformer2DModel.text_hidden_dim",description:`<strong>text_hidden_dim</strong> (<code>int</code>, defaults to 2560) &#x2014;
Hidden size of the text encoder whose hidden states are consumed.`,name:"text_hidden_dim"},{anchor:"diffusers.Krea2Transformer2DModel.num_text_layers",description:`<strong>num_text_layers</strong> (<code>int</code>, defaults to 12) &#x2014;
Number of tapped text-encoder hidden states stacked per token.`,name:"num_text_layers"},{anchor:"diffusers.Krea2Transformer2DModel.text_num_attention_heads",description:`<strong>text_num_attention_heads</strong> (<code>int</code>, defaults to 20) &#x2014;
Number of query heads in the text fusion blocks.`,name:"text_num_attention_heads"},{anchor:"diffusers.Krea2Transformer2DModel.text_num_key_value_heads",description:`<strong>text_num_key_value_heads</strong> (<code>int</code>, defaults to 20) &#x2014;
Number of key/value heads in the text fusion blocks.`,name:"text_num_key_value_heads"},{anchor:"diffusers.Krea2Transformer2DModel.text_intermediate_size",description:`<strong>text_intermediate_size</strong> (<code>int</code>, defaults to 6912) &#x2014;
Feed-forward hidden size of the SwiGLU MLP inside the text fusion blocks.`,name:"text_intermediate_size"},{anchor:"diffusers.Krea2Transformer2DModel.num_layerwise_text_blocks",description:`<strong>num_layerwise_text_blocks</strong> (<code>int</code>, defaults to 2) &#x2014;
Number of text fusion blocks applied across the tapped-layer axis (per token).`,name:"num_layerwise_text_blocks"},{anchor:"diffusers.Krea2Transformer2DModel.num_refiner_text_blocks",description:`<strong>num_refiner_text_blocks</strong> (<code>int</code>, defaults to 2) &#x2014;
Number of text fusion blocks applied across the token sequence.`,name:"num_refiner_text_blocks"},{anchor:"diffusers.Krea2Transformer2DModel.axes_dims_rope",description:`<strong>axes_dims_rope</strong> (<code>tuple[int, int, int]</code>, defaults to <code>(32, 48, 48)</code>) &#x2014;
Head-dim split across the (t, h, w) rotary position axes.`,name:"axes_dims_rope"},{anchor:"diffusers.Krea2Transformer2DModel.rope_theta",description:`<strong>rope_theta</strong> (<code>float</code>, defaults to 1000.0) &#x2014;
Base used by the rotary position embedding.`,name:"rope_theta"},{anchor:"diffusers.Krea2Transformer2DModel.norm_eps",description:`<strong>norm_eps</strong> (<code>float</code>, defaults to 1e-5) &#x2014;
Epsilon used by all RMSNorm modules.`,name:"norm_eps"}]});var d=e(s,6),b=_(d);l(b,{name:"forward",anchor:"diffusers.Krea2Transformer2DModel.forward",source:"https://github.com/huggingface/diffusers/blob/vr_13881/src/diffusers/models/transformers/transformer_krea2.py#L447",parameters:[{name:"hidden_states",val:": Tensor"},{name:"encoder_hidden_states",val:": Tensor"},{name:"timestep",val:": Tensor"},{name:"position_ids",val:": Tensor"},{name:"encoder_attention_mask",val:": torch.Tensor | None = None"},{name:"attention_kwargs",val:": dict[str, typing.Any] | None = None"},{name:"return_dict",val:": bool = True"}],parametersDescription:[{anchor:"diffusers.Krea2Transformer2DModel.forward.hidden_states",description:`<strong>hidden_states</strong> (<code>torch.Tensor</code> of shape <code>(batch_size, image_seq_len, in_channels)</code>) &#x2014;
Packed (patchified) noisy image latents.`,name:"hidden_states"},{anchor:"diffusers.Krea2Transformer2DModel.forward.encoder_hidden_states",description:`<strong>encoder_hidden_states</strong> (<code>torch.Tensor</code> of shape <code>(batch_size, text_seq_len, num_text_layers, text_hidden_dim)</code>) &#x2014;
Stack of tapped text-encoder hidden states per token.`,name:"encoder_hidden_states"},{anchor:"diffusers.Krea2Transformer2DModel.forward.timestep",description:`<strong>timestep</strong> (<code>torch.Tensor</code> of shape <code>(batch_size,)</code>) &#x2014;
Flow-matching time in <code>[0, 1]</code> (1 is pure noise, 0 is clean data).`,name:"timestep"},{anchor:"diffusers.Krea2Transformer2DModel.forward.position_ids",description:`<strong>position_ids</strong> (<code>torch.Tensor</code> of shape <code>(text_seq_len + image_seq_len, 3)</code>) &#x2014;
<code>(t, h, w)</code> rotary coordinates for the combined sequence. Text rows are all-zero; image rows hold the
latent-grid coordinates.`,name:"position_ids"},{anchor:"diffusers.Krea2Transformer2DModel.forward.encoder_attention_mask",description:`<strong>encoder_attention_mask</strong> (<code>torch.Tensor</code> of shape <code>(batch_size, text_seq_len)</code>, <em>optional</em>) &#x2014;
Boolean mask marking valid text tokens. Pass <code>None</code> when every text token is valid.`,name:"encoder_attention_mask"},{anchor:"diffusers.Krea2Transformer2DModel.forward.attention_kwargs",description:`<strong>attention_kwargs</strong> (<code>dict</code>, <em>optional</em>) &#x2014;
A kwargs dictionary that, when it contains a <code>scale</code> entry, sets the LoRA scale applied to this
transformer&#x2019;s adapters for the duration of the forward pass.`,name:"attention_kwargs"},{anchor:"diffusers.Krea2Transformer2DModel.forward.return_dict",description:`<strong>return_dict</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
Whether to return a <a href="/docs/diffusers/pr_13881/en/api/models/sana_video_transformer3d#diffusers.models.modeling_outputs.Transformer2DModelOutput">Transformer2DModelOutput</a> instead of a plain tuple.`,name:"return_dict"}],returnDescription:`<script context="module">export const metadata = 'undefined';<\/script>
<p><a
href="/docs/diffusers/pr_13881/en/api/models/sana_video_transformer3d#diffusers.models.modeling_outputs.Transformer2DModelOutput"
>Transformer2DModelOutput</a> or a <code>tuple</code> whose first element is the velocity
tensor of shape <code>(batch_size, image_seq_len, in_channels)</code>.</p>
`}),h(2),u(d),u(t);var v=e(t,2);M(v,{source:"https://github.com/huggingface/diffusers/blob/main/docs/source/en/api/models/krea2_transformer2d.md"}),h(2),f(g,o),q()}export{H as component};

Xet Storage Details

Size:
10.7 kB
·
Xet hash:
2953879bc3fa23bbe38676e2d90418def167bf259fe365d2e7af7ee9c2f8bfff

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