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

Abierto
#9,163 2 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 2 días

@shotsan ya está trabajando en esto.

Desde el 24/11/2026.

  • #9165 de @shotsan — abierto

Evaluación

Dificultad
3/5
Tiempo estimado
Medio día
Aptitud para principiantes
18/100
Tipo de issue
Error
Claridad
Bastante claro
Estado de actividad
Activo
Stack tecnológico
python, pytorch

Línea de trabajo

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.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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.

Lenguaje dominante
Python
Estrellas
43.3k
Forks
5.1k
Merge medio
5 d 10 h
PR fusionados (30 d)
85

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de deepspeedai/DeepSpeed

Todos los issues de deepspeedai/DeepSpeed

Issues similares

Más issues de Python

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.