Skip to content

Fix cross-device encoder_hidden_states / position_ids in MiniMax-H3 transformer - #14795

Open
chakshu-dhannawat wants to merge 1 commit into
huggingface:mainfrom
chakshu-dhannawat:fix/minimax-h3-cross-device
Open

chakshu-dhannawat wants to merge 1 commit into
huggingface:mainfrom
chakshu-dhannawat:fix/minimax-h3-cross-device

Conversation

@chakshu-dhannawat

Copy link
Copy Markdown

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.forward assumed all inputs were already on the transformer's device:

  • MiniMaxH3RotaryPosEmbed.forward multiplied position_ids against self.inv_freq, which fails when the two tensors live on different devices.
  • forward consumed encoder_hidden_states without aligning its device, causing later layers to hit cross-device errors.

Changes:

  • Move position_ids to self.inv_freq.device before computing rope embeddings.
  • Move encoder_hidden_states to self.device at the start of forward when needed.
  • Add TestMiniMaxH3TransformerMultiGPU.test_cross_device_text_encoder_forward to 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

models size/S PR with diff < 50 LOC tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

MiniMax-H3: references argument ignored and documented multi-GPU example fails with CUDA device mismatch

1 participant