Skip to content

implement vulkan gemm packed#6573

Merged
nihui merged 29 commits intoTencent:masterfrom
nihui:vulkan-gemm-packed
Mar 6, 2026
Merged

implement vulkan gemm packed#6573
nihui merged 29 commits intoTencent:masterfrom
nihui:vulkan-gemm-packed

Conversation

@nihui
Copy link
Member

@nihui nihui commented Mar 3, 2026

z-image-turbo 1024 end2end (s)

7900xtx 9060xt rtx3060
baseline 32.003 65.640 155.383
pr6573 29.583 62.148 134.004

@github-actions github-actions bot added the vulkan label Mar 3, 2026
@tencent-adm
Copy link
Member

CLA assistant check
Thank you for your submission, we really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@codecov-commenter
Copy link

codecov-commenter commented Mar 3, 2026

Codecov Report

❌ Patch coverage is 91.95980% with 16 lines in your changes missing coverage. Please review.
✅ Project coverage is 93.17%. Comparing base (081f2b8) to head (a4c181d).
⚠️ Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
src/layer/vulkan/gemm_vulkan.cpp 91.95% 16 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #6573      +/-   ##
==========================================
- Coverage   93.18%   93.17%   -0.02%     
==========================================
  Files         832      829       -3     
  Lines      266714   265989     -725     
==========================================
- Hits       248545   247839     -706     
+ Misses      18169    18150      -19     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR extends the Vulkan GEMM implementation to support runtime packing (elempack 1/4) and to optionally write packed outputs directly from the shaders, reducing the need for explicit pre/post packing conversions in gemm_vulkan.cpp.

Changes:

  • Add out_elempack, A_elempack, and B_elempack push constants and introduce pack-aware load/store paths in GEMM shaders.
  • Update gemm_vulkan.cpp to stop forcing A/B to pack1, compute logical M/N/K using elempack, and allocate top_blob with the chosen out_elempack.
  • Add additional descriptor bindings to provide alternate scalar/vec4 views for packed I/O.

Reviewed changes

Copilot reviewed 3 out of 4 changed files in this pull request and generated 3 comments.

File Description
src/layer/vulkan/shader/gemm_sg.comp Adds elempack-aware loads and pack4 output stores for the subgroup GEMM shader.
src/layer/vulkan/shader/gemm_cm.comp Adds elempack-aware load paths and pack4 output stores for the cooperative-matrix GEMM shader.
src/layer/vulkan/shader/gemm.comp Adds new bindings/constants and implements pack4 output write paths for the non-subgroup GEMM shader.
src/layer/vulkan/gemm_vulkan.cpp Removes forced input packing, computes M/N/K with elempack, allocates packed output, and updates bindings/constants passed to shaders.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@nihui
Copy link
Member Author

nihui commented Mar 4, 2026

我不满意!

@nihui nihui force-pushed the vulkan-gemm-packed branch from 900aa37 to dd45db7 Compare March 4, 2026 09:37
@nihui nihui force-pushed the vulkan-gemm-packed branch from 511dea3 to e68d933 Compare March 4, 2026 12:20
@nihui nihui closed this Mar 4, 2026
@nihui nihui reopened this Mar 4, 2026
@nihui
Copy link
Member Author

nihui commented Mar 5, 2026

TODO: pre-transform constant A and constant B to optimal layout
TODO: is uvec4 beneficial ?
TODO: vkmat heap index for auto host-device transfer

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 4 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@nihui nihui merged commit c286083 into Tencent:master Mar 6, 2026
54 of 66 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants