onnxruntime
2e912580 - Validate Attention projection and cache dimensions (#32946)

Commit
6 days ago
Validate Attention projection and cache dimensions (#32946) ### Description <!-- Describe your changes. --> Shares Q/K/V, weight-shape, projection-size, and cache-length checks between Attention prepacking and execution across CPU, CUDA, and native WebGPU. Uses checked packing/GEMM sizes, preserves pruned/unequal-V layouts and shared prepacking, and supports omitted CPU projection bias. Adds initializer-time, dynamic/unpacked, dimension-boundary, cache, and graph-independent validation coverage; updates the operator documentation. Refreshed on main `397657de778d05b17c0249ba37c0b4290e1ab3b5`: - Retains main's environment-based Android size allowance instead of reverting it to the stale branch constant. - Keeps both main's malformed-prepacking regressions and the new unequal-hidden-size sharing test. - Central validation preserves main's `"qkv_hidden_sizes values should be positive"` diagnostic. Shared malformed-case expectations were corrected after the first fresh native run exposed the mismatch. - Includes main's independent CUDA GQA build integration fix. ### Motivation and Context <!-- - Why is this change required? What problem does it solve? - If it fixes an open issue, please link to the issue here. --> Attention must enforce the same projection contract whether weights are packed at initialization or supplied during execution. Status-based validation rejects unsupported dimensions before unsafe packing/index arithmetic and keeps cache capacity checks consistent between implementations. ### Testing Fresh Windows Release CPU/DirectML build with MSVC and Ninja passed. MSBuild's CL task stalled without compiling; Ninja built the same configuration successfully. Tests ran from its fresh executable directory. ```powershell .\onnxruntime_provider_test.exe --gtest_filter=ContribOpAttentionTest.*:ContribOpAttentionValidationTest.* ``` **57 passed, 3 explicit unavailable WebGPU/cuDNN skips, zero failures; 1 existing disabled test.** Includes the main prepacking diagnostics and all three graph-independent helper cases. The initial run failed two malformed-projection tests solely because their expected diagnostics did not match the deliberately preserved main diagnostic; the corrected expectations were rebuilt and this entire selector passed. ```powershell .\onnxruntime_provider_test.exe --gtest_filter=QuantizeAttention*:*QAttention* ``` **20 passed, no skips**, verifying QAttention's shared validation. ```powershell .\onnxruntime_mlas_test.exe --gtest_filter=FGemmPackB.SizeBounds ``` **1 passed, no skips**, including exact accepted/rejected packing-size boundaries. Historical earlier-head evidence: 3 isolated no-exception/minimal validation cases and 601 packed-SGEMM cases passed. These configurations were not rebuilt for the main reconciliation above; they are not fresh-head minimal coverage. **Final-head GPU execution is now verified**, not inferred from green builds: - [Linux CUDA test job](https://github.com/microsoft/onnxruntime/actions/runs/37694054857/job/113070913707): `InvalidProjectionSizesCUDA`, `InvalidWeightsRankCUDA`, and `ProjectionSizeLimitCUDA` explicitly ran/passed; CTest **16/16 passed**. - [Native Metal WebGPU job](https://github.com/microsoft/onnxruntime/actions/runs/37694055050/job/113041537081): `InvalidProjectionSizesWebGPU` and `InvalidWeightsRankWebGPU` explicitly ran/passed; CTest **17/17 passed**. Remaining CI: three Linux minimal/no-optional build jobs and Suggest fixes are still genuinely queued without runners for more than eight hours. They have not run and are not passes; provisioning attention is requested without duplicating queued work. All other completed head checks passed. Independent approval remains required. --------- Co-authored-by: Gopalakrishnan Nallasamy <gopalakrishnan.nallasamy@microsoft.com> Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Parents
Loading