I have recently started working on optimizing tensor core–related algorithms on the H100, but I keep encountering various performance issues. Here I summarize my current understanding of the H100 architecture (mainly the Tensor Core–related aspects).
-
Each SM is capable of sustaining up to 128 register reads and 128 register writes per cycle.
-
For the instruction
wgmma.mma_async.sync.aligned.shape{.satfinite}.s32.s8.s8, the theoretical peak throughput on Tensor Cores is 4096 MAC operations per cycle per SM. -
The WGMMA instruction does not necessarily write the updated C values back to registers after every execution, as this would impose a significant bandwidth pressure on the register file. For example, for the
ssmode instructionm64n128k32.s32.s8.s8, if each execution required reading from and writing back the C matrix in the register file, it would on average require 128 register accesses per cycle (since the C matrix contains 64×128 elements; the average throughput is 64×128×32 / 4 / 1024 = 64 cycles). -
In some special cases, redundant reads and writes of the C registers can be avoided. For example, when two consecutive WGMMA instructions use the same C input and output, the first WGMMA does not need to write back the C matrix, and the second WGMMA does not need to read it again.
As for the timing of writing the C matrix back to registers, I believe there are at least two cases:
-
When a
wait_groupinstruction is explicitly executed, the C data must be written back to ensure visibility to subsequent instructions. -
When subsequent WGMMA operations work on different matrices, and the register cache cannot hold multiple matrices simultaneously, the old matrix must be evicted (written back).
-
The submitted WGMMA instructions are reordered within the group by the async proxy or other mechanisms, while still ensuring correctness, so that the output of a previous WGMMA can be used as the input to the next one as much as possible, thereby reducing register file accesses.
Additional question: is reordering allowed across groups
-
-
Tensor Cores execute the matrix multiplication described by WGMMA at a finer granularity. It takes some time for the internal Tensor Core pipeline to reach full utilization (based on discussions with engineers working on other AI accelerator designs). Pipeline disruptions can significantly impact performance. For instance, issuing a WGMMA followed immediately by a
wait_group 0, and repeating this pattern, is highly inefficient. Therefore, WGMMA instructions should be batched, and synchronization should also be performed in batches.
Final question: are there any best practices for developing Tensor Core programs on the H100? So far, I have only found PTX documentation, but I have not come across any materials similar to best-practice guides. If such resources exist, could you please share them with me?