[MiniMax-H3] RoPE re-assembles the rotated and pass-through channels with torch.cat, which is slow on ROCm

Open
#15,401 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

  • #15393 by @Shan2L — closed without merging

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
15/100
Issue type
Feature
Clarity
Clearly specified
Activity status
Stale
Tech stack
python, pytorch
Domain
ai, performance

Research direction

The RoPE helper in the MiniMax-H3 transformer code is the entry point: it slices the first rotary_dim channels, rotates them, and rebuilds the tensor with torch.cat. Work is already under way in linked pull request #15393, which has the change implemented, so this is not open for a new contributor. Done would mean the same output with the concat replaced by an in-place write into a copy of the input, verified by the existing MiniMax-H3 tests.

Written by the indexing model from the issue text.

Description

Is your feature request related to a problem? Please describe.

The MiniMax-H3 and MiniMax-H3-Image transformers apply RoPE to the first rotary_dim channels of each head and pass the rest through. The helper slices, rotates, and re-assembles the result with torch.cat of last-dimension slices. On ROCm that torch.cat takes a slow generic copy path (pytorch/pytorch#206557), so the RoPE apply costs about twice what it needs to.

Describe the solution you'd like.

Write the rotated part into a copy of the input instead of concatenating. The arithmetic is unchanged and the output is bitwise identical. On one Radeon AI PRO R9600D (gfx1201): RoPE apply 2.15x faster on the MiniMax-H3-Image shape, a 2048x2048 request 31.43 -> 31.00 s.

Describe alternatives you've considered.

Fixing torch.cat itself (pytorch/pytorch#206555) helps every caller but only lands with a future PyTorch release; the model-side change needs no new PyTorch.

Additional context.

Implemented in #15393.

Dominant language
Python
Stars
35k
Forks
7.5k
Avg merge
2d 22h
Merged PRs (30d)
58

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from huggingface/diffusers

All issues in huggingface/diffusers

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.