CUDA Tiling API and optimal tile shapes

Already mentioned (but buried) in Real doc for CUDA Tile C++ API, with basic tasks
Related to determining the most effective size of tile (e.g. matrix multiplication) algebra dense matrices

I want to perform high-efficient tile matrix multiplication with ct::matmul (with 3D KxMxN matrices)
My problem is to shape the problem in the most effective way.

I can’t find any doc similar to Functionality — NVIDIA CUTLASS Documentation that would help finding the optimal ct::shape<>

I understand that the tile API is an abstraction that will automatically route the operation to the best dedicated hardwared (CUDA, TensorOp, Wmma…), but I need to know how to make the best choices.

Not to mention that I cannot understand if converting to tf32 at tile loading will change anything.

Is there a CUDA Tile documentation dedicated to this topic ?

The Cuda Tile C++ API is quite new, so I don’t have insight or know, how it converts.

But I can answer in general for TF32. TF32 is a 19-bit format combining the 8 bits for the exponent like FP32 and the 10 bits for the mantissa (+ the implicit 1 at the MSB) from FP16. It uses 19 bits, but is stored in 32 bits.

So for all purposes of data transfer and loading and conventional (non-Tensor Core) GPU operations it behaves like a FP32 value. For the Tensor Core computations it behaves like a FP16 with extended range.

If you want to optimize memory bandwidth further, you have to do your own compression; a straight-forward way could be to store and transfer as FP16, scale by a common scale factor for several numbers.

Probably you know all that and you want to exactly know, how it is handled for the Cuda Tile API.


In practice I would a) hope for better answers here; b) try a direct implementation and measure the performance with Nsight Compute compared to the theoretically optimum performance (computation and memory performance). And c) if it is not good enough, I would fall back to a conventional kernel.


Perhaps you could clarify the math operation you want to do. 3D KxMxN matrix multiplication.

Is it 2D x 2D → 2D matrix multiplication or is it a tensor multiplication with 3D matrices?

From

I would guess you mean a batched (over a third dimension) 2D x 2D → 2D?

Could you say the approximate dimensions?

You’re right on every guess about my current knowledge (at least the knowledge I think I have)

About the matrix multiplication :

(disclaimer : the word “tile” below does not refer to ct::tile)

I have 2D arrays (let’s say from ~1000x1000 to 5000x5000), and I have some 2D kernel (let’s say from 3x3 to 64x64) that must be matmuled with each tile of a partition of the array (so that each tile has a compatible size against the kernel)
So basically, I want to perform 2D matmul.

The 3rd dim is indeed to batch them since I have a lot of tiles.

So it is up to me to be clever and size the ct::shape for the best performance… if I knew what to expect.

For instance, there is some padding to get power-of-two shapes, but considering Functionality — NVIDIA CUTLASS Documentation , it might be a good strategy to use artificially larger sizes than necessary to target some hardware operators (like, 32 instead of 8 even if 8 is enough)

Also, the “batch” dimension (K) could be adapted depending on the actual values of MxN, but I lack a guideline about relevant choices.