GEMM
General Matrix Multiplication, the fundamental and computationally intensive operation in deep learning. It is the core computation underlying fully connected layers, attention mechanism Q/K/V projections, and Transformer feed-forward networks, with its execution efficiency directly determining overall model training and inference throughput.
Core Facts
Timeline (last 90 days)
Common sources of computation graph differences include: operator fusion (such as merging LayerNorm with GEMM), reduction order changing due to different degrees of parallelism, inconsistent random number generator seeds and consumption order, and special optimizations of attention by inference frameworks (such as paged KV Cache changing the accumulation order).
On GPUs, FP64 theoretical throughput is typically only 1/2 to 1/32 that of FP32 (depending on architecture) and requires more registers and bandwidth, so optimizing FP64 GEMM is more challenging than lower precision.
GEMM (general matrix multiplication) is a core level-3 operation in BLAS libraries, computing C = α·A·B + β·C, where A, B and C are dense matrices.
The degree to which library-level optimization improves end-to-end metrics depends on the share of FP64 GEMM in the workload; if the share is low, the improvement is limited.
Modern GPUs implement GEMM using tiling, splitting large matrices into small blocks that fit in on-chip shared memory and reducing global memory accesses through data reuse.
For large-size input scenarios, boundary test cases for kernels involving 32-bit indexing should be established, rather than relying only on small- and medium-scale benchmarks.
As context windows and batch sizes continue to grow, scenarios where M*N crosses 2^31 will become more and more common, and the frequency of such boundary bugs may increase.
The default NCCL reduce-scatter can slow down a GEMM that originally completes in a single wave by 69%.
For dense GEMM and grouped GEMM, PyTorch's scheduling layer selects the appropriate backend based on tensor shapes and hardware type.
FlyDSL covers core operations such as dense and grouped GEMM, fused multi-head attention (FMHA/Attention), MXFP8/MXFP4 scaled GEMM, RMSNorm and TopK.
15 more timeline events
All Facts (20)
General Matrix Multiplication (GEMM) is the most fundamental and computationally intensive operation in deep learning inference, and NVIDIA Tensor Cores and Google TPU systolic arrays are both specialized optimizations targeting GEMM.
75%Unverified通过CUDA Tile,开发者可以更自然地表达矩阵分块乘法(Tiled GEMM),而不必深入处理wmma或mma.sync等底层PTX指令
85%UnverifiedCommon sources of computation graph differences include: operator fusion (such as merging LayerNorm with GEMM), reduction order changing due to different degrees of parallelism, inconsistent random number generator seeds and consumption order, and special optimizations of attention by inference frameworks (such as paged KV Cache changing the accumulation order).
50%UnverifiedModern GPUs implement GEMM using tiling, splitting large matrices into small blocks that fit in on-chip shared memory and reducing global memory accesses through data reuse.
50%UnverifiedThe degree to which library-level optimization improves end-to-end metrics depends on the share of FP64 GEMM in the workload; if the share is low, the improvement is limited.
50%UnverifiedOn GPUs, FP64 theoretical throughput is typically only 1/2 to 1/32 that of FP32 (depending on architecture) and requires more registers and bandwidth, so optimizing FP64 GEMM is more challenging than lower precision.
50%UnverifiedGEMM (general matrix multiplication) is a core level-3 operation in BLAS libraries, computing C = α·A·B + β·C, where A, B and C are dense matrices.
50%UnverifiedFor large-size input scenarios, boundary test cases for kernels involving 32-bit indexing should be established, rather than relying only on small- and medium-scale benchmarks.
50%UnverifiedThe default NCCL reduce-scatter can slow down a GEMM that originally completes in a single wave by 69%.
50%UnverifiedFor dense GEMM and grouped GEMM, PyTorch's scheduling layer selects the appropriate backend based on tensor shapes and hardware type.
50%UnverifiedFlyDSL covers core operations such as dense and grouped GEMM, fused multi-head attention (FMHA/Attention), MXFP8/MXFP4 scaled GEMM, RMSNorm and TopK.
50%UnverifiedMatrix multiplication satisfies (A×B)ᵀ = Bᵀ×Aᵀ; swapping the two operands and transposing the result does not change the computational semantics, only the way data is arranged in memory and registers.
50%UnverifiedBenchmarks show that when the number of concurrent requests reaches 5, the throughput ratio of row-by-row GEMV over GEMM drops below 100% (90.7%), and GEMM regains the advantage.
50%UnverifiedThe two prefill kernels, GEMM and row-by-row GEMV, produced output that was identical in the first 597 characters under the same prompt and greedy decoding, then began to diverge.
50%UnverifiedGEMV can complete dequantization while reading the weights, whereas GEMM's tiling logic makes the dequantization process more complex.
50%UnverifiedIn Candle's quantized Metal execution path, when the number of rows in the input matrix equals 1 it takes the GEMV path, and when the row count exceeds 1 it enters the GEMM path.
50%UnverifiedIn small-batch scenarios, the additional overhead of the GEMM implementation far outweighs the gains from reusing weights across rows.
50%UnverifiedFloating-point addition and multiplication are not associative under the IEEE 754 standard, and the different internal summation orders of GEMM and GEMV produce extremely small differences in activation values for the same input.
50%UnverifiedIn large models based on the Transformer architecture, the vast majority of floating-point operations are concentrated in matrix multiplication, and the efficiency of GEMM kernels directly determines training throughput and inference latency.
50%UnverifiedThe computational form of GEMM can be described as C = A × B + C, where A, B, and C are all two-dimensional matrices.
50%