Skip to content

support LTX2.3 hot switch (multiple) lora && support LTX2.3 S2V mode#1028

Merged
helloyongyang merged 4 commits intomainfrom
ltx23_hot_switch_lora
Apr 21, 2026
Merged

support LTX2.3 hot switch (multiple) lora && support LTX2.3 S2V mode#1028
helloyongyang merged 4 commits intomainfrom
ltx23_hot_switch_lora

Conversation

@xinyiqin
Copy link
Copy Markdown
Contributor

No description provided.

@xinyiqin xinyiqin requested a review from helloyongyang April 20, 2026 20:16
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces the ltx2_s2v task for audio-conditioned video generation and adds functionality to apply multiple LoRA adapters simultaneously by merging their weights. Review feedback identifies a bug in the LoRA merging logic where keys not present in the first file are ignored, and notes redundant audio assignment logic in the LTX2 runner. Additionally, suggestions were provided to reduce code duplication in the LTX2 model's LoRA update method and to improve shell script robustness through proper variable quoting.

Comment on lines +586 to +588
for k, v in weight_dict.items():
if k in merged:
merged[k] = merged[k] + v * s
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

There's a bug in the logic for merging multiple LoRA weight dictionaries. If a LoRA file contains weights (keys) that were not present in the first LoRA file, they will be ignored. The loop only updates keys that are already in the merged dictionary.

You should handle cases where a key exists in the new weight_dict but not in merged by adding it to merged.

                    for k, v in weight_dict.items():
                        if k in merged:
                            merged[k] += v * s
                        else:
                            merged[k] = v * s

Comment on lines +132 to +139
def _update_lora(self, lora_path, strength):
if isinstance(lora_path, dict):
lora_weight = self._remap_lora_dict_keys_for_mm_weight(lora_path)
else:
lora_weight = self._load_lora_file(lora_path)
self.pre_weight.update_lora(lora_weight, strength)
self.transformer_weights.update_lora(lora_weight, strength)
self.post_weight.update_lora(lora_weight, strength)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This _update_lora method duplicates a lot of logic from the base class BaseTransformerModel._update_lora. You can simplify this by calling the super method and handling the LTX2-specific key remapping before the call. This improves maintainability by reducing code duplication.

Suggested change
def _update_lora(self, lora_path, strength):
if isinstance(lora_path, dict):
lora_weight = self._remap_lora_dict_keys_for_mm_weight(lora_path)
else:
lora_weight = self._load_lora_file(lora_path)
self.pre_weight.update_lora(lora_weight, strength)
self.transformer_weights.update_lora(lora_weight, strength)
self.post_weight.update_lora(lora_weight, strength)
def _update_lora(self, lora_path, strength):
if isinstance(lora_path, dict):
lora_path = self._remap_lora_dict_keys_for_mm_weight(lora_path)
super()._update_lora(lora_path, strength)

Comment on lines +695 to 696
save_audio = self._ltx2_s2v_mux_audio
save_video(
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The logic to assign self._ltx2_s2v_mux_audio to save_audio is redundant. The end_run_segment method, which is called before this method, already updates self.gen_audio_final with the correct audio for the ltx2_s2v task. You can remove this if block and simply use self.gen_audio_final.

export CUDA_VISIBLE_DEVICES=0

# set environment variables
source ${lightx2v_path}/scripts/base/base.sh
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

It's a good practice in shell scripting to quote variable expansions to prevent issues with paths that contain spaces or other special characters. Please wrap ${lightx2v_path} in double quotes.

Suggested change
source ${lightx2v_path}/scripts/base/base.sh
source "${lightx2v_path}/scripts/base/base.sh"

@helloyongyang helloyongyang merged commit 4d059cb into main Apr 21, 2026
2 checks passed
@helloyongyang helloyongyang deleted the ltx23_hot_switch_lora branch April 21, 2026 07:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants