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

Aperta
#15,401 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

  • #15393 di @Shan2L — chiusa senza merge

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
15/100
Tipo di issue
Funzionalità
Chiarezza
Specificata chiaramente
Stato di attività
Ferma
Stack tecnologico
python, pytorch
Ambito
ai, performance

Direzione di ricerca

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.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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.

Lingua principale
Python
Stelle
35k
Fork
7.5k
Merge medio
2g 22h
PR unite (30g)
58

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di huggingface/diffusers

Tutte le issue di huggingface/diffusers

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.