Fix cross-device encoder_hidden_states / position_ids in MiniMax-H3 transformer - #14795
Open
chakshu-dhannawat wants to merge 1 commit into
Open
chakshu-dhannawat wants to merge 1 commit into
chakshu-dhannawat wants to merge 1 commit into
Conversation
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.
Hi,
This PR fixes #14379.
The documented multi-GPU setup for MiniMax-H3 puts the text encoder on a different device than the transformer. Two places in
MiniMaxH3Transformer3DModel.forwardassumed all inputs were already on the transformer's device:MiniMaxH3RotaryPosEmbed.forwardmultipliedposition_idsagainstself.inv_freq, which fails when the two tensors live on different devices.forwardconsumedencoder_hidden_stateswithout aligning its device, causing later layers to hit cross-device errors.Changes:
position_idstoself.inv_freq.devicebefore computing rope embeddings.encoder_hidden_statestoself.deviceat the start offorwardwhen needed.TestMiniMaxH3TransformerMultiGPU.test_cross_device_text_encoder_forwardto cover the documented setup.I ran the new test on a 4xH100 box and it passes. A few existing context-parallel tests in the same file fail locally due to an NCCL bootstrap issue (
no socket interface found), which is unrelated to this change.Thanks for the review.