[BugFix] Fix load_weights error when loading HunyuanImage3.0#1598
[BugFix] Fix load_weights error when loading HunyuanImage3.0#1598hsliuustc0106 merged 1 commit intovllm-project:mainfrom
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 01276c1bea
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| custom_pos_emb = self.get_pos_emb(custom_pos_emb, position_ids) | ||
|
|
||
| inputs_embeds = self.model.wte(input_ids) | ||
| inputs_embeds = self.model.embed_tokens(input_ids) |
There was a problem hiding this comment.
Avoid calling embed_tokens on non-first PP ranks
forward_call now unconditionally does self.model.embed_tokens(input_ids), but HunyuanImage3Model.__init__ only creates embed_tokens on the first PP rank (or last when tied embeddings); other pipeline-parallel ranks get PPMissingLayer. With pipeline_parallel_size > 1 and default tie_word_embeddings=False, this change makes non-first ranks invoke a missing layer and fail during inference, whereas the previous self.model.wte path existed on every rank.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Avoid calling embed_tokens on non-first PP ranks
forward_callnow unconditionally doesself.model.embed_tokens(input_ids), butHunyuanImage3Model.__init__only createsembed_tokenson the first PP rank (or last when tied embeddings); other pipeline-parallel ranks getPPMissingLayer. Withpipeline_parallel_size > 1and defaulttie_word_embeddings=False, this change makes non-first ranks invoke a missing layer and fail during inference, whereas the previousself.model.wtepath existed on every rank.Useful? React with 👍 / 👎.
Current model do not support PP, so PP.is_first_rank is always true. No need to check for now.
01276c1 to
883a04c
Compare
Move some submodule load weights code of HunyuanImage3Pipeline to AutoWeightsLoader:load_weights, fix weights not initialized error. Signed-off-by: Semmer2 <semmer@live.cn>
883a04c to
86bbf58
Compare
Move some submodule load weights code of HunyuanImage3Pipeline to AutoWeightsLoader:load_weights, fix weights not initialized error.
PLEASE FILL IN THE PR DESCRIPTION HERE ENSURING ALL CHECKLIST ITEMS (AT THE BOTTOM) HAVE BEEN CONSIDERED.
Purpose
DiffusersPipelineLoader:load_weights added strictly weights load gap verification. Which reports bug when loading HunyuanImage3.0 mode. Move some submodule loading code to AutoWeightsLoader:load_weights to fix this bug.
Test Plan
python examples/offline_inference/text_to_image/text_to_image.py --mode /data/HunyuanImage-3.0/ --prompt "A brown and white dog is running on the grass" --output output_image.png --num-inference-steps 50 --guidance-scale 5.0 --tensor-parallel-size 8 --seed 1234
Test Result
Essential Elements of an Effective PR Description Checklist
supported_models.mdandexamplesfor a new model. Please runmkdocs serveto sync the documentation editions to./docs.BEFORE SUBMITTING, PLEASE READ https://github.com/vllm-project/vllm-omni/blob/main/CONTRIBUTING.md (anything written below this line will be removed by GitHub Actions)