@@ -703,3 +703,72 @@ def translate_wan_nnx_path_to_diffusers_lora(nnx_path_str, scan_layers=False):
703703 return f"diffusion_model.blocks.{ idx } .{ suffix_map [inner_suffix ]} "
704704
705705 return None
706+
707+
708+ def translate_ltx2_nnx_path_to_diffusers_lora (nnx_path_str , scan_layers = False ):
709+ """
710+ Translates LTX2 NNX path to Diffusers/LoRA keys.
711+ """
712+ # --- 2. Map NNX Suffixes to LoRA Suffixes ---
713+ suffix_map = {
714+ # Self Attention (attn1)
715+ "attn1.to_q" : "attn1.to_q" ,
716+ "attn1.to_k" : "attn1.to_k" ,
717+ "attn1.to_v" : "attn1.to_v" ,
718+ "attn1.to_out" : "attn1.to_out.0" ,
719+
720+ # Audio Self Attention (audio_attn1)
721+ "audio_attn1.to_q" : "audio_attn1.to_q" ,
722+ "audio_attn1.to_k" : "audio_attn1.to_k" ,
723+ "audio_attn1.to_v" : "audio_attn1.to_v" ,
724+ "audio_attn1.to_out" : "audio_attn1.to_out.0" ,
725+
726+ # Audio Cross Attention (audio_attn2)
727+ "audio_attn2.to_q" : "audio_attn2.to_q" ,
728+ "audio_attn2.to_k" : "audio_attn2.to_k" ,
729+ "audio_attn2.to_v" : "audio_attn2.to_v" ,
730+ "audio_attn2.to_out" : "audio_attn2.to_out.0" ,
731+
732+ # Cross Attention (attn2)
733+ "attn2.to_q" : "attn2.to_q" ,
734+ "attn2.to_k" : "attn2.to_k" ,
735+ "attn2.to_v" : "attn2.to_v" ,
736+ "attn2.to_out" : "attn2.to_out.0" ,
737+
738+ # Audio to Video Cross Attention
739+ "audio_to_video_attn.to_q" : "audio_to_video_attn.to_q" ,
740+ "audio_to_video_attn.to_k" : "audio_to_video_attn.to_k" ,
741+ "audio_to_video_attn.to_v" : "audio_to_video_attn.to_v" ,
742+ "audio_to_video_attn.to_out" : "audio_to_video_attn.to_out.0" ,
743+
744+ # Video to Audio Cross Attention
745+ "video_to_audio_attn.to_q" : "video_to_audio_attn.to_q" ,
746+ "video_to_audio_attn.to_k" : "video_to_audio_attn.to_k" ,
747+ "video_to_audio_attn.to_v" : "video_to_audio_attn.to_v" ,
748+ "video_to_audio_attn.to_out" : "video_to_audio_attn.to_out.0" ,
749+
750+ # Feed Forward
751+ "ff.net_0" : "ff.net.0.proj" ,
752+ "ff.net_2" : "ff.net.2" ,
753+
754+ # Audio Feed Forward
755+ "audio_ff.net_0" : "audio_ff.net.0.proj" ,
756+ "audio_ff.net_2" : "audio_ff.net.2" ,
757+ }
758+
759+ # --- 3. Translation Logic ---
760+ if scan_layers :
761+ if nnx_path_str .startswith ("blocks." ):
762+ inner_suffix = nnx_path_str [len ("blocks." ) :]
763+ if inner_suffix in suffix_map :
764+ return f"diffusion_model.transformer_blocks.{{}}.{ suffix_map [inner_suffix ]} "
765+ else :
766+ m = re .match (r"^blocks\.(\d+)\.(.+)$" , nnx_path_str )
767+ if m :
768+ idx , inner_suffix = m .group (1 ), m .group (2 )
769+ if inner_suffix in suffix_map :
770+ return f"diffusion_model.transformer_blocks.{ idx } .{ suffix_map [inner_suffix ]} "
771+
772+ return None
773+
774+
0 commit comments