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

Offen
#15,401 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Maintainer antworten meist innerhalb von 1 Tag

Dieses Issue hat noch niemand übernommen.

  • #15393 von @Shan2L — ohne Merge geschlossen

Bewertung

Schwierigkeit
3/5
Geschätzter Aufwand
1-2 Tage
Anfängerfreundlichkeit
15/100
Issue-Typ
Feature
Klarheit
Klar beschrieben
Aktivitätsstatus
Veraltet
Tech-Stack
python, pytorch
Bereich
ai, performance

Rechercherichtung

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.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

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.

Vorherrschende Sprache
Python
Sterne
35k
Forks
7.5k
Ø Merge
2 T. 22 Std.
Gemergte PRs (30 T.)
58

Entwicklungsumgebung

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus huggingface/diffusers

Alle Issues in huggingface/diffusers

Ähnliche Issues

Weitere Issues zu Python

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.