Skip to content

update: Add bridge version#957

Open
Jinnn2 wants to merge 1 commit intoModelTC:mainfrom
Jinnn2:latest-origin-main-20260316
Open

update: Add bridge version#957
Jinnn2 wants to merge 1 commit intoModelTC:mainfrom
Jinnn2:latest-origin-main-20260316

Conversation

@Jinnn2
Copy link

@Jinnn2 Jinnn2 commented Mar 20, 2026

No description provided.

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request enhances the lightx2v project by introducing a new "bridge" version for the WAN model, specifically designed for text-to-video generation with integrated LTX2 upsampling. This allows for a more sophisticated multi-stage resolution changing process, where the LTX2 model is leveraged for high-quality spatial upscaling of clean latents. The changes provide a complete pipeline, from configuration to execution, for utilizing this advanced upsampling technique to produce higher-resolution video outputs.

Highlights

  • New Model Integration: Introduced wan2.1_ltx2_bridge as a new model class, integrating LTX2 upsampling capabilities into the WAN framework.
  • Dedicated Runner and Scheduler: Added WanLTX2BridgeRunner and WanScheduler4LTX2Bridge to manage the specific logic for this multi-stage resolution changing process.
  • Pixel Bridge Resizer: Implemented LTX2PixelBridgeResizer to facilitate the conversion and upscaling of latents between WAN and LTX2 models.
  • Configuration and Scripting: Provided a new configuration file (wan_t2v_ltx2_bridge.json) and a shell script (run_wan_t2v_ltx2_bridge.sh) for easy setup and execution of the new bridge model.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
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

The pull request successfully introduces a new bridge version for WAN models, specifically wan2.1_ltx2_bridge, along with its configuration and runner implementation. This includes new files for the runner, scheduler interface, and pixel resizer, as well as updates to infer.py and pipeline.py to integrate the new model class. The changes appear to correctly implement the new functionality. However, a significant portion of the newly added docstrings and comments in the Python files are in Chinese. For a codebase that appears to be predominantly English, this can hinder maintainability and collaboration for non-Chinese speakers. It is recommended to translate these comments and docstrings into English to improve code readability and maintainability.


@RUNNER_REGISTER("wan2.1_ltx2_bridge")
class WanLTX2BridgeRunner(WanRunner):
"""独立的 WAN + LTX2 upsample 实验链路。"""
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

The docstring for WanLTX2BridgeRunner is in Chinese. For better maintainability and broader understanding within a potentially English-speaking development environment, it is recommended to provide docstrings in English.

Comment on lines +7 to +16
"""把 changing_resolution 能力动态混入任意 WAN scheduler。

这里不直接继承某个固定的 scheduler,而是在运行时构造一个新类:
1. 保留 father_scheduler 的基础采样能力;
2. 用 WanScheduler4ChangingResolution 覆盖 prepare_latents / step_post;
3. 其余方法仍复用 father_scheduler 的实现。

这样同一套 changing_resolution 逻辑就能挂到普通 WAN scheduler、
feature caching scheduler 等不同父类上,而不用为每个父类单独复制代码。
"""
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

The docstring for WanScheduler4ChangingResolutionInterface is in Chinese. Please translate it to English for improved code readability and maintainability.

def __new__(cls, father_scheduler, config):
class NewClass(WanScheduler4ChangingResolution, father_scheduler):
def __init__(self, config):
# 先初始化父 scheduler,再初始化 changing_resolution 相关配置。
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

This comment is in Chinese. Please translate it to English for improved code readability and maintainability.

Comment on lines 28 to +41
class WanScheduler4ChangingResolution:
"""WAN 的分阶段变分辨率采样逻辑。

核心思路:
1. 预先为每个分辨率阶段采样一份噪声 latent;
2. 正常步沿用父类 step_post 的去噪更新;
3. 命中切换步时,把当前 x_t 还原成近似 x0,再插值到下一阶段分辨率;
4. 用下一阶段预先采样好的噪声重新加噪,继续 diffusion 采样。

注意:
- resolution_rate 的顺序就是实际分辨率路径;
- 代码会额外补一份“原始分辨率”的 latent 作为最后阶段;
- changing_resolution_steps 是 1-based,表示“第 N 步结束后切换分辨率”。
"""
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

The docstring for WanScheduler4ChangingResolution is in Chinese. Please translate it to English for improved code readability and maintainability.

"""

def __init__(self, config):
# 默认策略:先在 0.75 倍分辨率上采样,再切回原始分辨率。
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

This comment is in Chinese. Please translate it to English for improved code readability and maintainability.

Comment on lines +39 to +45
# 只在“空间 x2 升分”时走 LTX2 bridge,其余情况继续回退到原始插值逻辑。
can_use_bridge = (
self.clean_latent_resizer is not None
and target_latent_shape[1] == denoised_sample.shape[1]
and target_latent_shape[2] == denoised_sample.shape[2] * 2
and target_latent_shape[3] == denoised_sample.shape[3] * 2
)
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

This comment is in Chinese. Please translate it to English for improved code readability and maintainability.

Comment on lines +47 to +56
logger.info(
"Use LTX2 bridge to resize WAN clean latent: "
f"{tuple(denoised_sample.shape)} -> {tuple(target_latent_shape)}"
)
return self.clean_latent_resizer.resize(
latent=denoised_sample,
target_latent_shape=target_latent_shape,
step_index=self.step_index,
changing_resolution_index=self.changing_resolution_index,
)
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

This logger info message contains Chinese text. Please translate it to English for consistency and maintainability.



class LTX2PixelBridgeResizer:
"""把 WAN clean latent 借道 RGB / LTX2 latent 做一次无训练的 x2 升分。"""
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

The docstring for LTX2PixelBridgeResizer is in Chinese. Please translate it to English for improved code readability and maintainability.

Comment on lines +46 to +49
"LTX2 pixel bridge resize: "
f"step={step_index}, stage={changing_resolution_index}, "
f"wan_latent={current_shape} -> {target_latent_shape}, "
f"target_rgb=({target_pixel_h}, {target_pixel_w})"
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

This logger info message contains Chinese text. Please translate it to English for consistency and maintainability.

Comment on lines +93 to +97
logger.info(
"Pad low-res RGB for LTX2 VAE: "
f"({height}, {width}) -> ({padded_h}, {padded_w}), "
f"pad=(left={left}, right={right}, top={top}, bottom={bottom})"
)
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

This logger info message contains Chinese text. Please translate it to English for consistency and maintainability.

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.

1 participant