Skip to content

fix hunyuan vidoe 1.5 weight-load bug#1052

Merged
llmc-reviewer merged 1 commit intomainfrom
hy
May 6, 2026
Merged

fix hunyuan vidoe 1.5 weight-load bug#1052
llmc-reviewer merged 1 commit intomainfrom
hy

Conversation

@helloyongyang
Copy link
Copy Markdown
Contributor

No description provided.

@llmc-reviewer llmc-reviewer merged commit 9a3f014 into main May 6, 2026
2 checks passed
@llmc-reviewer llmc-reviewer deleted the hy branch May 6, 2026 04:34
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 updates the checkpoint loading logic in base_model.py to support specific directory structures for hunyuan_video_1.5 and initializes sequence parallel groups in pre_infer.py. Review feedback highlights potential KeyError and AttributeError risks when accessing configuration values directly and recommends using safer access patterns with .get() and null checks to ensure stability across different environments.

Comment on lines +84 to +87
if self.config["seq_parallel"]:
self.seq_p_group = self.config.get("device_mesh").get_group(mesh_dim="seq_p")
else:
self.seq_p_group = None
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

This block has two potential issues:

  1. self.config["seq_parallel"] will raise a KeyError if the key is missing from the configuration.
  2. self.config.get("device_mesh").get_group(...) will raise an AttributeError if device_mesh is not present in the config, as get() returns None by default, and None has no attribute get_group.

Using a safer access pattern ensures the code doesn't crash in distributed environments with incomplete configurations.

Suggested change
if self.config["seq_parallel"]:
self.seq_p_group = self.config.get("device_mesh").get_group(mesh_dim="seq_p")
else:
self.seq_p_group = None
if self.config.get("seq_parallel"):
device_mesh = self.config.get("device_mesh")
self.seq_p_group = device_mesh.get_group(mesh_dim="seq_p") if device_mesh else None
else:
self.seq_p_group = None

Comment on lines +428 to +431
if self.config["model_cls"] == "hunyuan_video_1.5":
safetensors_files = glob.glob(os.path.join(safetensors_path, "transformer", self.config["transformer_model_name"], "*.safetensors"))
else:
safetensors_files = glob.glob(os.path.join(safetensors_path, "*.safetensors"))
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

Using self.config["model_cls"] can raise a KeyError if the key is missing from the configuration. Since BaseTransformerModel is a base class used by multiple model types (such as z_image or qwen_image), this change could cause regressions for other models that do not define model_cls in their config. It is safer to use .get() to check the model class.

Suggested change
if self.config["model_cls"] == "hunyuan_video_1.5":
safetensors_files = glob.glob(os.path.join(safetensors_path, "transformer", self.config["transformer_model_name"], "*.safetensors"))
else:
safetensors_files = glob.glob(os.path.join(safetensors_path, "*.safetensors"))
if self.config.get("model_cls") == "hunyuan_video_1.5":
safetensors_files = glob.glob(os.path.join(safetensors_path, "transformer", self.config.get("transformer_model_name", ""), "*.safetensors"))
else:
safetensors_files = glob.glob(os.path.join(safetensors_path, "*.safetensors"))

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