@@ -94,12 +94,21 @@ def forward(
9494 txt_k = txt_k .unflatten (- 1 , (heads , - 1 ))
9595 txt_v = txt_v .unflatten (- 1 , (heads , - 1 ))
9696
97- img_q = self .img_attn_q_norm (img_q )
98- img_k = self .img_attn_k_norm (img_k )
9997 txt_q = self .txt_attn_q_norm (txt_q )
10098 txt_k = self .txt_attn_k_norm (txt_k )
10199
102- img_q , img_k = comfy_kitchen .apply_rope (img_q , img_k , image_rotary_emb )
100+ img_q_scale , _ , img_q_offload_stream = comfy .ops .cast_bias_weight (self .img_attn_q_norm , img_q , offloadable = True )
101+ img_k_scale , _ , img_k_offload_stream = comfy .ops .cast_bias_weight (self .img_attn_k_norm , img_k , offloadable = True )
102+ img_q , img_k = comfy_kitchen .rms_rope (
103+ img_q ,
104+ img_k ,
105+ image_rotary_emb ,
106+ img_q_scale ,
107+ img_k_scale ,
108+ self .img_attn_q_norm .eps ,
109+ )
110+ comfy .ops .uncast_bias_weight (self .img_attn_q_norm , img_q_scale , None , img_q_offload_stream )
111+ comfy .ops .uncast_bias_weight (self .img_attn_k_norm , img_k_scale , None , img_k_offload_stream )
103112
104113 joint_q = torch .cat ([img_q , txt_q ], dim = 1 )
105114 joint_k = torch .cat ([img_k , txt_k ], dim = 1 )
0 commit comments