cuda : add conv3d with implicit GEMM - #29137
Conversation
|
Hi @leejet, thanks for your contribution! Per our contribution guidelines, the automated PR checker found the following issue(s) that need your attention:
Please note that maintainers reserve the right to make final decisions on PRs. If you believe there is a mistake, please comment below. |
|
@ggerganov @am17an This is the Conv3D version, following a similar path to the Conv2D implicit GEMM implementation #29135. Could you take a look at this one as well? |
ggerganov
left a comment
There was a problem hiding this comment.
I can't make a detailed review, but I think it is OK to merge as the chances to impact llama.cpp functionality is zero and it would be useful for downstream projects to get the extra performance.
|
/bot review |
Automated code reviewStatic review of Will slow the review (point 1) AMD/HIP path is untested — the PR only reports an RTX 4090 run, but the AMD-specific code is exactly what cannot be validated there: the (point 2) (point 3) (point 4) Process note for maintainers: there are competing conv3d implementations in flight (#16948, #17255, #24569, all referenced in the description). Someone should decide which approach is preferred before this gets a deep review, so the review effort is not spent on the wrong one. Nits (point 5) (point 6) (point 7) A one-line comment in The new test cases are well chosen (OC=65 crossing the 64-tile boundary, stride/dilation/padding combos, shapes small enough to trigger split_k > 1, both kernel dtypes), and reuse the existing This review was generated automatically by pi coding agent using |
|
@JohannesGaessler About your earlier concern in #24569 (comment) - I think this is a great opportunity to get some progress on the convolution kernels. With this work, the kernels will get heavily exercised in @leejet's https://github.com/leejet/stable-diffusion.cpp project and chances are that any issues with correctness and performance will be quickly resolved over there. |
|
an issue i have had trying to optimize the kernels mostly used by sdcpp (im2col) in the past is that sdcpp lacks an easy way to do end to end benchmarks sweeps, ie a llama-bench equivalent. |
JohannesGaessler
left a comment
There was a problem hiding this comment.
Thank you for sorting this out on your end. The only thing that I think needs to be addressed prior to a merge is the misaligned pointer, the rest I'll leave at your discretion.
|
Thanks everyone for the reviews! I’ve updated the code based on the feedback, including some of the helpful suggestions from the bot review. When you have a chance, please take another look. Thanks! |
|
@leejet Could you take a look at this error: https://github.com/ggml-org/llama.cpp/actions/runs/35969488472/job/107535592917#step:3:9865 |
We need to handle misaligned offsets in the vulkan backend. @0cc4m can you do this? |
|
I'll look into it. |
Thanks for the heads-up! Looks like this has already been picked up and there's a fix PR open now. |
Overview
Add CUDA support for
GGML_OP_CONV_3D, used byggml_conv_3d_direct, with an F16 implicit-GEMM kernel and a direct fallback for F32 weights and shapes outside the fast path. Inputs and outputs are contiguous F32 tensors; weights can be F16 or F32.There are already CUDA conv3d proposals, including #16948, #17255, and #24569. This PR offers a compact implementation intended to make the indexing, bounds checks, and performance tradeoffs easier to review and maintain. It reuses
mma.cuh, uses one fixed 64x64x64 tile shape, and keeps the convolution indexing and dispatch in one source file. The goal is to lower the review burden around this operation.Additional information
Tested on Windows with an RTX 4090, CUDA 12.4, driver 596.36, and a Release build:
Requirements