Advanced NVIDIA CUDA Kernel Optimization Techniques: Handwritten PTX

AI-generated summary of reporting by NVIDIA Developer Blog. Read the original for the full story.

Why it matters

Very little changes for most developers: NVIDIA's own guidance is that hand-written PTX is a last resort, and the 7-14% gains shown apply only to a specific fused GEMM kernel on Hopper GPUs.

Read this as

NVIDIA published a tutorial on PTX, which is the assembly language, the most low-level code, that runs on its GPUs. Using an example from its CUTLASS library that handles a common step in mixture-of-experts AI models, NVIDIA shows that writing PTX by hand instead of its usual C++ code speeds things up by 7-14% on a GH200 server GPU. The company stresses almost nobody should do this: the code is harder to write and debug, and may not work on other GPU models.

This is an advanced engineering tutorial, not a product launch, so there is nothing to buy or adopt. The message for decision-makers is that NVIDIA's optimised libraries (CUBLAS, CUTLASS) already contain hand-tuned GPU assembly where it pays off, and most teams gain nothing by going lower. The 7-14% throughput gain was measured only on the Hopper architecture (GH200), so hand-written low-level code risks not porting to future GPUs, an argument for building on NVIDIA's libraries rather than duplicating them.

NVIDIA benchmarks CUTLASS example 61 (fused GEMM with top_k=2 and softmax, the MoE routing pattern) on a GH200, toggling inline PTX in sm90_visitor_topk_softmax.hpp against CUDA C++ fallbacks. PTX versions of top_2/top_4 reduce and fast_masked_softmax deliver 7-14% higher GFlop/s across m=1,024 to 16,384 tokens (n=8, k=4096), with the PTX run reaching 5,704 GFlop/s at m=1024. Embedding options are inline PTX asm and the cuda::ptx namespace in libcu++; Hopper features require building with -DCUTLASS_NVCC_ARCHS=90a. Gains are kernel-specific and may not transfer across GPU architectures.

Read the original

This summary exists to save you time, not to replace the source.

Key terms

NVIDIA CUTLASS CUBLAS PTX GH200 Hopper libcu++

Was this summary useful?

One click, anonymous. It tells us which summaries to re-run.

Related reading