segKI: `install_decode_attention` patches non-gated q/k-norm attention (dense Qwen3)

Aperta
#9,163 2 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 2 giorni

@shotsan ci sta già lavorando.

Dal 24/11/2026.

  • #9165 di @shotsan — aperta

Valutazione

Difficoltà
3/5
Tempo stimato
Mezza giornata
Idoneità per principianti
18/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
python, pytorch

Direzione di ricerca

Start in install_decode_attention, where the gated [q|gate] check compares q_proj.out_features against head_dim, and compare it with find_glu_segments. The failing test is TestArenaWeightViews::test_glu_only_model_refresh_clears_backend_cat_cache, and _decode_attn_forward assumes Qwen3.5 semantics. Linked PR #9165 is already open against this issue, so check it before starting.

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

Descrizione

TestArenaWeightViews::test_glu_only_model_refresh_clears_backend_cat_cache fails on master (039bfc9f3) with AttributeError: 'Qwen3RMSNorm' object has no attribute 'eps'. Earlier PR comments (#9077, #9079, #9127) attributed this to a Transformers API change. That is not the cause: it fails the same way on Transformers 5.17.0.

Root cause

install_decode_attention treats a layer as the gated [q|gate] layout when q_proj.out_features is divisible by 2 * head_dim. Dense Qwen3-0.6B has 16 heads × 128 = 2048 = 2 × 8 × 128, so it passes and is patched as 8 gated heads with a (1+w) q/k norm. It then reaches self.q_norm.eps, but Qwen3RMSNorm stores variance_epsilon. Without that crash the output would be wrong anyway, because the head count, the gate split and the norm scale all differ.

In Transformers 5.17, about 40 attention classes have per-head q_norm/k_norm: Qwen3/MoE/VL, Gemma3/4, GLM4-MoE, OLMo2/3, MiniMax-M2, Exaone4, and others. Any of them with an even head count passes the current check. Only qwen3_5, qwen3_5_moe, qwen3_next and qwen4_exp actually use the gated layout.

Proposed fix

Also require q_proj.out_features == 2 * o_proj.in_features. In the gated layout, o_proj consumes only the attention half; in plain attention the two are equal. Both are per-rank under AutoTP, so the ratio holds there too. With Transformers 5.17 this selects exactly the four gated families above. The check only excludes layers, so currently supported models are unaffected. Locally the segKI kernel suite passes (28/28 on L20), and a CPU test covers both the gated and the dense case.

Question

This is still a structural check. A future model with a 2×-wide q_proj but different semantics (plain w norm, a different gate split) would pass it, while _decode_attn_forward already assumes Qwen3.5 semantics (it imports apply_rotary_pos_emb from qwen3_5). Would you prefer:

  1. the structural check above, consistent with find_glu_segments; or
  2. additionally an explicit allowlist (attention class or config.model_type)?

@delock happy to send the PR either way.

Lingua principale
Python
Stelle
43.3k
Fork
5.1k
Merge medio
5g 10h
PR unite (30g)
85

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 deepspeedai/DeepSpeed

Tutte le issue di deepspeedai/DeepSpeed

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.