Skip to content

after add cache, this version support flashinfer#1229

Open
Chernobyllight wants to merge 2 commits into
ModelTC:mainfrom
Chernobyllight:lightx2v-v5
Open

after add cache, this version support flashinfer#1229
Chernobyllight wants to merge 2 commits into
ModelTC:mainfrom
Chernobyllight:lightx2v-v5

Conversation

@Chernobyllight

Copy link
Copy Markdown

No description provided.

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

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.

Code Review

This pull request introduces support for the HunyuanImage3 model, including its architecture, inference logic, and weight loading. It also adds configuration support for cache options and native implementations, along with updated scripts for running the model. The review feedback highlights potential runtime errors when accessing configuration attributes and suggests using safer getattr patterns, as well as replacing hardcoded absolute paths in shell scripts with dynamic path resolution to improve portability. One high-severity issue regarding the detection of runtime diff weights in the MoE implementation was also identified.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment on lines +346 to +347
if hasattr(linear, "weight_diff"):
raise RuntimeError("HunyuanImage3 moe_impl='flashinfer' does not support runtime diff weights.")

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

The condition hasattr(linear, "weight_diff") always evaluates to True because weight_diff is initialized in __init__ as a dummy tensor. This prevents the use of flashinfer even when no runtime diff is active. Using getattr(linear, "has_diff", False) accurately detects active runtime diffs.

Suggested change
if hasattr(linear, "weight_diff"):
raise RuntimeError("HunyuanImage3 moe_impl='flashinfer' does not support runtime diff weights.")
if getattr(linear, "has_diff", False):
raise RuntimeError("HunyuanImage3 moe_impl='flashinfer' does not support runtime diff weights.")

if missing:
raise RuntimeError(f"HunyuanImage3 VAE weights are incomplete; missing {len(missing)} keys, first key: {missing[0]}")

vae_dtype = getattr(torch, self.hunyuan_config.vae_dtype, torch.float32)

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

Directly accessing self.hunyuan_config.vae_dtype can raise an AttributeError if the attribute is missing from the configuration. Using getattr with a default value provides a safe fallback.

Suggested change
vae_dtype = getattr(torch, self.hunyuan_config.vae_dtype, torch.float32)
vae_dtype_str = getattr(self.hunyuan_config, "vae_dtype", "float32")
vae_dtype = getattr(torch, vae_dtype_str, torch.float32)

vae = self.vae_decoder
vae_device = self._vae_device()
image_tensor = image_tensor.unsqueeze(0).to(vae_device)
autocast_dtype = getattr(torch, self.hunyuan_config.vae_autocast_dtype, torch.float16)

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

Directly accessing self.hunyuan_config.vae_autocast_dtype can raise an AttributeError if the attribute is missing from the configuration. Using getattr with a default value provides a safe fallback.

        vae_autocast_dtype_str = getattr(self.hunyuan_config, "vae_autocast_dtype", "float16")
        autocast_dtype = getattr(torch, vae_autocast_dtype_str, torch.float16)

if hasattr(vae, "ffactor_temporal"):
latents = latents.unsqueeze(2)

autocast_dtype = getattr(torch, self.hunyuan_config.vae_autocast_dtype, torch.float16)

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

Directly accessing self.hunyuan_config.vae_autocast_dtype can raise an AttributeError if the attribute is missing from the configuration. Using getattr with a default value provides a safe fallback.

        vae_autocast_dtype_str = getattr(self.hunyuan_config, "vae_autocast_dtype", "float16")
        autocast_dtype = getattr(torch, vae_autocast_dtype_str, torch.float16)

Comment on lines +15 to +16
export lightx2v_path="/data/nvme0/lhd_codes/LightX2V"
export model_path="/data/nvme0/lhd_codes/HunyuanImage-3.0-instruct/HunyuanImage-3-Instruct"

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 script uses hardcoded absolute paths specific to a local environment. Replacing them with dynamic path resolution or placeholder paths makes the script portable across different environments.

Suggested change
export lightx2v_path="/data/nvme0/lhd_codes/LightX2V"
export model_path="/data/nvme0/lhd_codes/HunyuanImage-3.0-instruct/HunyuanImage-3-Instruct"
export lightx2v_path=${lightx2v_path:-$(cd "$(dirname "${BASH_SOURCE[0]}")"/../.. && pwd)}
export model_path=${model_path:-/path/to/HunyuanImage-3-Instruct}

Comment on lines +27 to +28
export lightx2v_path="${lightx2v_path:-/data/nvme0/lhd_codes/LightX2V}"
export model_path="${model_path:-/data/nvme0/lhd_codes/HunyuanImage-3.0-instruct/HunyuanImage-3-Instruct}"

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 script uses hardcoded absolute paths specific to a local environment. Replacing them with dynamic path resolution or placeholder paths makes the script portable across different environments.

Suggested change
export lightx2v_path="${lightx2v_path:-/data/nvme0/lhd_codes/LightX2V}"
export model_path="${model_path:-/data/nvme0/lhd_codes/HunyuanImage-3.0-instruct/HunyuanImage-3-Instruct}"
export lightx2v_path=${lightx2v_path:-$(cd "$(dirname "${BASH_SOURCE[0]}")"/../.. && pwd)}
export model_path=${model_path:-/path/to/HunyuanImage-3-Instruct}

Comment on lines +4 to +5
lightx2v_path="/data/nvme0/lhd_codes/LightX2V"
model_path="/data/nvme0/models/Wan-AI/Wan2.1-I2V-14B-720P"

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 script uses hardcoded absolute paths specific to a local environment. Replacing them with dynamic path resolution or placeholder paths makes the script portable across different environments.

Suggested change
lightx2v_path="/data/nvme0/lhd_codes/LightX2V"
model_path="/data/nvme0/models/Wan-AI/Wan2.1-I2V-14B-720P"
lightx2v_path=${lightx2v_path:-$(cd "$(dirname "${BASH_SOURCE[0]}")"/../.. && pwd)}
model_path=${model_path:-/path/to/Wan2.1-I2V-14B-720P}

Comment on lines +4 to +5
lightx2v_path="/data/nvme0/lhd_codes/LightX2V"
model_path="/data/nvme0/models/Wan-AI/Wan2.1-T2V-1.3B"

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 script uses hardcoded absolute paths specific to a local environment. Replacing them with dynamic path resolution or placeholder paths makes the script portable across different environments.

Suggested change
lightx2v_path="/data/nvme0/lhd_codes/LightX2V"
model_path="/data/nvme0/models/Wan-AI/Wan2.1-T2V-1.3B"
lightx2v_path=${lightx2v_path:-$(cd "$(dirname "${BASH_SOURCE[0]}")"/../.. && pwd)}
model_path=${model_path:-/path/to/Wan2.1-T2V-1.3B}

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