Details
vulkan: improve CONV_2D/3D performance (#32629)
- tests: add conv2d/conv3d cases from diffusion models
I asked Claude to add more representative perf tests, to optimize against
Assisted-by: Claude Opus 5.5
- vulkan: Avoid private variables in coopmat2 callbacks
There's a compiler bug where these can spill to local memory, making the
coopmat2 shader slower than coopmat1.
Assisted-by: Claude Opus 5.5
- vulkan: split_k for conv_2d
#29929 added split_k for conv_3d, at the time I didn't see much benefit to
doing the same for conv_2d, but with additional test cases this helps, and
it also interacts well with the upcoming halo optimization
Assisted-by: Claude Opus 5.5
- vulkan: Add conv_2d/3d "halo" shader
This shader copies the input region corresponding to the output region (plus
the "halo") once into shared memory, rather than for each filter tap.
Assisted-by: Claude Opus 5.5
- vulkan: don't waste accumulator space on discarded halo elements
All elements of the result accumulator now correspond to real work in
the output tile, where in the previous commit the accumulator had "halo"
elements that did wasted work and were discarded during store.
Claude's description:
Each accumulator fragment covers 16 (or 8) pixels of one tile row, and its
B matrix is that box row shifted by the tap. Box rows no longer need padding
and no multiplies are spent on the border columns. Tiles are 256 pixels
where the output allows, otherwise the shape with the least padded area
weighted by its cost per output. 8-pixel fragments use 16x8x16 cooperative
matrices when the device has them. The header comment describes the new
layout.
RTX 5090: SD1.5 64x64 320->320 1.81x, 3D Wan 130x130x3 384 1.41x,
3D 106x154x6 96->96 1.34x; CONV_2D +6%, CONV_3D +11%.
Assisted-by: Claude Opus 5.5
- vulkan: Enable split_k for the conv_halo shader
The reduction logic is still shared with conv2d_mm and mul_mat
(mul_mat_split_k_reduce).
RTX 5090: SD1.5 8x8 1280->1280 2.71x, 16x16 1280->1280 1.63x, 32x32
640->640 1.61x, SDXL 32x32 2560->1280 1.61x; CONV_2D +13%, CONV_3D +3%.
Assisted-by: Claude Opus 5.5
- vulkan: Tweak the conv shader selection heuristic to use halo more often
Claude's summary:
- Small 2D layers that read the filter in place, and have enough passes to
split, use 32 output channels per workgroup before splitting the passes:
twice the workgroups, without split-K's partial outputs and reduce. (With
the filter copy, and for 1x1 filters, this was slower.) - 3D layers with fewer than 4K outputs use the halo shader instead of
conv3d_mm, despite the filter copy. - Layers with 16 to 48 input channels use it instead of conv2d_mm; the
limit of 64 predates split-K and the row-aligned tiles.
RTX 5090: SD1.5 8x8 1280->1280 1.35x, VAE 128x128 16->512 1.47x,
1536x1536 32->64 1.28x, 3D 28x40x3 384->384 1.64x, 1024->1024 1.37x;
CONV_2D +6%, CONV_3D +4%.
Assisted-by: Claude Opus 5.5
- vulkan: Tweak tile selection and workgroup traversal order
Claude's summary:
- 56x4 tiles (8-pixel fragments) for outputs 49 to 56 wide, so 52-wide
layers pad to 56 instead of 64; tiles of 192 pixels or more now cost the
same as 256. Skipped on layers with too few workgroups to fill half the
GPU. - All output channels in one workgroup when 64 < Cout <= 128 and Cout is
not a multiple of 64 (96 no longer pads to 128), on tiles of up to 128
pixels. The tile choice now counts output channel padding. - 3D tiles numbered with the output depth slices fastest, so workgroups of
neighboring output slices run together and share their input slices in
L2.
Adds CONV_2D/CONV_3D tests for 56x4 tiles and Cout 80, 96 and 112.
RTX 5090: 3D Wan 480p 96->96 482x834x6 1.18x, 96->96 154x106x6 1.15x,
1280->1280 76x52x8 1.13x, 320->1280 76x52x8 1.12x, Wan 480p 192
242x418x6 1.05x; geomean +2% over all the CONV perf cases (RTX 4070 +3%).
Assisted-by: Claude Opus 5.5
- trim comments
Website:
Attestations:
macOS/iOS:
- macOS Apple Silicon (arm64)
- macOS Apple Silicon (arm64, KleidiAI enabled) DISABLED
- macOS Intel (x64)
- iOS XCFramework
Linux:
- Ubuntu x64 (CPU)
- Ubuntu arm64 (CPU)
- Ubuntu 24.04 s390x (CPU)
- Ubuntu 26.04 s390x (CPU)
- Ubuntu 26.04 s390x (zDNN)
- Ubuntu x64 (Vulkan)
- Ubuntu arm64 (Vulkan)
- Ubuntu x64 (CUDA 12) - CUDA 12.8 libraries
- Ubuntu x64 (CUDA 13) - CUDA 13.5 libraries
- Ubuntu arm64 (CUDA 13) - CUDA 13.5 libraries
- Ubuntu x64 (ROCm 10.0)
- Ubuntu x64 (OpenVINO)
- Ubuntu x64 (SYCL FP32)
- Ubuntu x64 (SYCL FP16)
- Linux arm64 (Snapdragon: CPU, Adreno GPU, Hexagon NPU) - setup guide
Android:
Windows:
- Windows x64 (CPU)
- Windows arm64 (CPU)
- Windows arm64 (OpenCL Adreno)
- Windows x64 (CUDA 12) - CUDA 12.4 DLLs
- Windows x64 (CUDA 13) - CUDA 13.5 DLLs
- Windows arm64 (CUDA 13) - CUDA 13.5 DLLs
- Windows x64 (Vulkan)
- Windows arm64 (Vulkan)
- Windows x64 (OpenVINO)
- Windows x64 (SYCL)
- Windows x64 (ROCm 10.0)
openEuler:
- DISABLED
- openEuler x86 (310p)
- openEuler x86 (910b, ACL Graph)
- openEuler aarch64 (310p)
- openEuler aarch64 (910b, ACL Graph)
UI: