@@ -188,13 +188,10 @@ def __init__(self, block: FluxSingleTransformerBlock, scale_shift: float = 1, **
188188 def forward (
189189 self ,
190190 hidden_states : torch .Tensor ,
191- encoder_hidden_states : torch .Tensor ,
192191 temb : torch .Tensor ,
193192 image_rotary_emb : Optional [Tuple [torch .Tensor , torch .Tensor ]] = None ,
194193 joint_attention_kwargs : Optional [Dict [str , Any ]] = None ,
195194 ) -> torch .Tensor :
196- text_seq_len = encoder_hidden_states .shape [1 ]
197- hidden_states = torch .cat ([encoder_hidden_states , hidden_states ], dim = 1 )
198195
199196 residual = hidden_states
200197 norm_hidden_states , gate = self .norm (hidden_states , emb = temb )
@@ -222,8 +219,7 @@ def forward(
222219 if hidden_states .dtype == torch .float16 :
223220 hidden_states = hidden_states .clip (- 65504 , 65504 )
224221
225- encoder_hidden_states , hidden_states = hidden_states [:, :text_seq_len ], hidden_states [:, text_seq_len :]
226- return encoder_hidden_states , hidden_states
222+ return hidden_states
227223
228224
229225class NunchakuFluxTransformer2DModelV2 (FluxTransformer2DModel , NunchakuModelLoaderMixin ):
@@ -374,10 +370,10 @@ def forward(
374370 if controlnet_block_samples is not None :
375371 raise NotImplementedError ("Controlnet is not supported for FluxTransformer2DModelV2 for now" )
376372
373+ hidden_states = torch .cat ([encoder_hidden_states , hidden_states ], dim = 1 )
377374 for index_block , block in enumerate (self .single_transformer_blocks ):
378- encoder_hidden_states , hidden_states = block (
375+ hidden_states = block (
379376 hidden_states = hidden_states ,
380- encoder_hidden_states = encoder_hidden_states ,
381377 temb = temb ,
382378 image_rotary_emb = rotary_emb_single ,
383379 joint_attention_kwargs = joint_attention_kwargs ,
@@ -387,6 +383,7 @@ def forward(
387383 if controlnet_single_block_samples is not None :
388384 raise NotImplementedError ("Controlnet is not supported for FluxTransformer2DModelV2 for now" )
389385
386+ hidden_states = hidden_states [:, txt_tokens :]
390387 hidden_states = self .norm_out (hidden_states , temb )
391388 output = self .proj_out (hidden_states )
392389
0 commit comments