[gemma] Allow packed QKV MatMul with QK-Norm via post-projection Split - #366
Conversation
Agent-Logs-Url: https://github.com/xadupre/mbext/sessions/e059dee5-ed76-46b6-ba16-99c97d5fe075 Co-authored-by: xadupre <22452781+xadupre@users.noreply.github.com>
📂 Impacted Files2 file(s) changed in this pull request: 🔵 |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #366 +/- ##
==========================================
+ Coverage 78.39% 78.44% +0.05%
==========================================
Files 26 26
Lines 7984 8003 +19
==========================================
+ Hits 6259 6278 +19
Misses 1725 1725
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
@copilot one test on phi3 is failing with transformers 5.6 |
I'm unable to reproduce a phi3 failure locally with the exact CI dependency versions (transformers 5.6.0, onnxruntime 1.26.0, onnxruntime-genai 0.13.2, torch 2.11). All 26 The MCP log endpoint returns 404 for that job, and the workflow-run logs zip on this PR snapshots the steps before "Run fast tests" finishes, so I cannot see which specific phi3 test failed or its traceback. Could you paste the failing test name + stack trace (or the relevant pytest output)? With that I can target the fix. Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
|
@copilot can you try again? |
Tried again. Reinstalled the exact CI dep set (transformers==5.6.0, onnxruntime==1.26.0, onnxruntime-genai==0.13.2, onnx==1.21.0, peft==0.19.1) and ran the full Inspecting the failing CI run (26374761498, job 77633104896, transformers-5.6) more carefully: the workflow-run log archive contains files Could you re-run that job? If it fails again with the same pattern (no step-8 log), it's a runner issue; if a real test failure surfaces with a traceback, I can target the fix. Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
|
@copilot the test |
Just re-ran If you can share the exact pytest output / traceback from your local 5.6 run (or an exact |
…import-changes-from-onnxruntime-genai
Ports microsoft/onnxruntime-genai#2137: previously
use_packed_matmulwas disabled wheneverq_norm/k_normwas set, emitting 3 separateq_proj/k_proj/v_projMatMulNBitsper layer for Qwen3-class (QK-Norm) architectures. We now keep the single packedqkv_proj/MatMuland recover Q/K/V via oneSplitnode so the per-headSimplifiedLayerNormalizationpath is unchanged.Changes
base.py—make_attention_init: cacheself.q_size/self.kv_size; dropq_norm/k_normfrom theuse_packed_matmulexclusion list.base.py—make_splithelper: new thin wrapper around ONNXSplit.base.py—make_attention_input_proj: when packed QKV is active and both Q/K norms are present, insertSplit(widths[q_size, kv_size, kv_size]) after the optional packed biasAdd(so packed-bias fusion is preserved) and rebindq_path/k_path/v_pathto its 3 outputs. Diagram comments added.base.py: replace inlinenum_attn_heads*head_size/num_kv_heads*head_sizewith cachedq_size/kv_sizeinmake_qk_norm,make_repeat_kv,make_attention_unpacked_lora,make_attention_unpacked_regular.gemma.py—Gemma4Model.make_attention: also swap (and restore)q_size/kv_sizealongside the existing per-layerhead_size/num_kv_headsswap, so full-attention layers get correctSplitwidths and SLN reshape dims.Resulting subgraph (QK-Norm + packed)
A single
Splitis preferred over 3Slicenodes: the packed output is read once and written to 3 outputs in one dispatch, avoiding 3× re-reads per decode step.