DeepSpeed
78259714 - fix(segki): do not patch dense non-gated q/k-norm attention in install_decode_attention (#9163) (#9165)

Commit
1 day ago
fix(segki): do not patch dense non-gated q/k-norm attention in install_decode_attention (#9163) (#9165) ### Summary Fixes #9163. Dense models such as Qwen3-0.6B have `q_proj.out_features == 16 * 128 = 2048`, which is divisible by `2 * head_dim` (256). As a result, `install_decode_attention` misclassified dense attention as the 2x-wide gated `[q|gate]` layout (patching it as 8 gated heads instead of 16 dense heads), causing runtime crashes such as `AttributeError: 'Qwen3RMSNorm' object has no attribute 'eps'` or `TypeError: Qwen3Attention.forward() got multiple values for argument 'cache'`. This PR: 1. Verifies that `q_proj.out_features == 2 * o_proj.in_features` in `deepspeed/module_inject/segment_ki.py`, ensuring that the layer actually uses the 2x-wide gated query layout where `o_proj` consumes only the attention half. Dense layers where `q_out == o_in` are cleanly bypassed. 2. Adds a unit test in `tests/unit/module_inject/test_segment_ki_kernels.py` confirming that dense attention is rejected and gated attention is accepted by `install_decode_attention`. ### Test Plan ```bash pytest tests/unit/module_inject/test_segment_ki_kernels.py -k "test_glu_only_model_refresh_clears_backend_cat_cache or test_install_decode_attention" # 2 passed in 4.54s ``` --------- Signed-off-by: shotsan <shotsan@users.noreply.github.com> Co-authored-by: shotsan <shotsan@users.noreply.github.com> Co-authored-by: Zhipeng Wang <zhipeng.rainbowserie@gmail.com>
Author
Parents
Loading