Repository navigation
Conversation
…oad hooks fire get_qwen3vl_prompt_embeds called text_encoder.model(...) and fired accelerate's _hf_hook by hand, so hooks that only run on the top-level forward (diffusers group offloading of the unmatched modules, for example) never ran and left the embedding on the CPU. Call text_encoder(...) with logits_to_keep=1 instead: hidden_states[50] is bitwise identical, the language-model head only sees one token. Signed-off-by: Sylvan Liu <Sylvan.Liu@amd.com>
Contributor
|
Hi @Shan2L, thanks for the PR! It does not appear to link an issue it fixes.
See the contribution guide for more details. Please note that PRs without a linked issue are likely to be automatically closed 10 days after this notice. Once the PR links an existing issue, the author box is ticked, or the |
Collaborator
|
@Shan2L |
6 of 10 tasks
Contributor
Author
|
Thanks @yiyixuxu! Understood, I will open an issue first for future fixes. |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Fixes #15399
get_qwen3vl_prompt_embeds(MiniMax-H3, MiniMax-H3-Image, and its copy in Pika-H3-Flex) callstext_encoder.model(...)and fires accelerate's_hf_hook.pre_forwardby hand. The code carries a TODO saying a block should not do this. As a result, hooks that only wrap the top-levelforwardnever fire. With diffusers group offloading on the text encoder, modules that are not in a block (the token embedding) stay on the CPU:This PR calls
text_encoder(...)withlogits_to_keep=1, so the language-model head projects only one token, and it drops the manual hook call.utils/check_copies.py --fix_and_overwritepropagated the change to the Pika-H3-Flex copy.Results
hidden_states[50]is bitwise identical between the old and the new call. Setup: same process, a MiniMax-H3-Image prompt, leaf-level group offloading on one 32 GB Radeon AI PRO R9600D. Encoding takes 2.36 s with the old call and 2.44 s with the new one.tests/modular_pipelines/minimax_h3+tests/modular_pipelines/minimax_h3_imageon a Radeon AI PRO R9700: 142 passed, 52 skipped;tests/modular_pipelines/pika_h3_flex: 81 passed, 41 skipped (at e3f8451)This change makes the following setup work on a single 32 GB GPU: transformer
block_level+ text encoderleaf_levelgroup offloading (use_stream=True, record_stream=True), with the VAE on the GPU. It takes 31.7 s per 2048x2048 image, with 6.2 GiB peak. The documentedComponentsManagerauto offload moves the ~62 GB text encoder as a whole and does not fit there.Self-review notes (diffusers
self-reviewskill)get_qwen3vl_prompt_embedsis used by the H3, H3-Image and Pika-H3-Flex encoder blocks.check_copies.pyand ruff 0.9.10 (check + format) pass.Before submitting
self-reviewskill on the diff?Who can review?
@yiyixuxu @DN6
AI assistance: prepared with the help of an AI coding assistant (GitHub Copilot). All results above were run on the listed hardware.