#191·YuE

Proposal: use native enable_gqa on MPS instead of the repeat_interleave fallback

Author: Isalia20Created Sep 17, 2026Updated Sep 17, 2026

On MPS, sdpa() does repeat_interleave on K/V instead of passing enable_gqa, which copies the full KV cache per layer per token: modeling_yue2.py#L20-L32, nar.py#L74-L78.

The code comment is right that MPS doesn't implement enable_gqa on every release, but that only applies to old ones. By PyTorch releases enable_gqa crashes on <= 2.6, from 2.7 to 2.11 it is accepted but has a copy, after 2.12 there is a native no copy version. I tried rewriting it and it gave me the following perf on M5 Pro:

AR decode context shipped enable_gqa
2,500 36.8 tok/s 44.4
10,000 21.8 tok/s 35.0

torch 2.6 is quite an old package so I think it would be worth to enable this, since most of the people are on more recent versions (like 2.14).

Source: multimodal-art-projection/YuE