<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Posts on gau-nernst's blog</title><link>https://gau-nernst.github.io/posts/</link><description>Recent content in Posts on gau-nernst's blog</description><generator>Hugo</generator><language>en-us</language><lastBuildDate>Sun, 27 Sep 2026 19:20:00 +0800</lastBuildDate><atom:link href="https://gau-nernst.github.io/posts/index.xml" rel="self" type="application/rss+xml"/><item><title>World's fastest (panel) QR factorization on B200</title><link>https://gau-nernst.github.io/b200-qr/</link><pubDate>Sun, 27 Sep 2026 19:20:00 +0800</pubDate><guid>https://gau-nernst.github.io/b200-qr/</guid><description>&lt;p>GPU MODE recently hosted a series of leaderboards for &lt;a href="https://www.gpumode.com/news/linear-algebra-kernels-age-of-research">linear algebra kernels&lt;/a>. I participated in the first one, QR decomposition, and claimed the 2nd place. I think it&amp;rsquo;s a breath of fresh air, a departure from the usual LLM-oriented kernels most people program for nowadays.&lt;/p>
&lt;p>As usual, my submission is open-sourced at &lt;a href="https://github.com/gau-nernst/gpu-mode-kernels/tree/fb291890/linalg/qr_v2">gau-nernst/gpu-mode-kernels&lt;/a>. The final submission is &lt;code>codex/submission.py&lt;/code>.&lt;/p>
&lt;aside class="toc">
 &lt;h2>Table of Contents&lt;/h2>
 &lt;nav id="TableOfContents">
 &lt;ol>
 &lt;li>&lt;a href="#introduction-to-qr-decomposition">Introduction to QR decomposition&lt;/a>&lt;/li>
 &lt;li>&lt;a href="#qr32-single-warp-register-resident-kernel">QR32: Single-warp, register-resident kernel&lt;/a>&lt;/li>
 &lt;li>&lt;a href="#qr176-single-cta-cooperative-warps">QR176: Single-CTA, cooperative warps&lt;/a>&lt;/li>
 &lt;li>&lt;a href="#qr352-qr512-and-qr1024-compact-wy-transform">QR352, QR512, and QR1024: compact WY transform&lt;/a>
 &lt;ol>
 &lt;li>&lt;a href="#panel-schedule">Panel schedule&lt;/a>&lt;/li>
 &lt;li>&lt;a href="#low-precision-matmul">Low precision matmul&lt;/a>&lt;/li>
 &lt;li>&lt;a href="#triangular-matrix-inversion">Triangular matrix inversion&lt;/a>&lt;/li>
 &lt;/ol>
 &lt;/li>
 &lt;li>&lt;a href="#qr1024-2-cta-threadblock-cluster-communication">QR1024: 2-CTA, threadblock cluster communication&lt;/a>&lt;/li>
 &lt;li>&lt;a href="#qr2048-and-qr4096-multi-cta-grid-wide-coordination">QR2048 and QR4096: Multi-CTA, grid-wide coordination&lt;/a>&lt;/li>
 &lt;li>&lt;a href="#final-remarks">Final remarks&lt;/a>&lt;/li>
 &lt;/ol>
&lt;/nav>
&lt;/aside>

&lt;h2 id="introduction-to-qr-decomposition">Introduction to QR decomposition&lt;/h2>
&lt;p>I don&amp;rsquo;t want to touch too much on this as I&amp;rsquo;m no expert on the topic (in fact, I only learned about QR decomposition, mostly from Codex, during the competition). There are excellent resources online explaining this, such as &lt;a href="https://ml-mike.com/writing/qr_v2/">the one from Michael&lt;/a>. Instead, I will focus on my thought process tackling the crux of the challenge: chained dependency.&lt;/p></description></item><item><title>Using TMA in CuteDSL</title><link>https://gau-nernst.github.io/cutedsl-tma/</link><pubDate>Mon, 25 May 2026 04:00:00 +0700</pubDate><guid>https://gau-nernst.github.io/cutedsl-tma/</guid><description>&lt;p>Some time ago, I explored using CuteDSL to write some kernels for vLLM to enjoy the JIT benefits (ability to specialize on more parameters, don&amp;rsquo;t need to recompile vLLM from source during development, etc&amp;hellip;). I have always known that we can write CUDA C++ way (SIMT style) in CuteDSL: there are &lt;code>cute.arch.thread_idx()&lt;/code>/&lt;code>cute.arch.block_idx()&lt;/code> (equivalent of &lt;code>threadIdx&lt;/code>/&lt;code>blockIdx&lt;/code> in CUDA C++), PTX (or its NVVM equivalent) can be used freely in device code. However, Tensor Memory Accelerator (TMA) is a special exception. Typically we need to encode tensor descriptors on the host side using CUDA driver API &lt;code>cuTensorMapEncodeTiled()&lt;/code>, but this is not exposed in CuteDSL!&lt;/p></description></item><item><title>tcgen05 for dummies</title><link>https://gau-nernst.github.io/tcgen05/</link><pubDate>Sun, 21 Dec 2025 22:26:00 +0800</pubDate><guid>https://gau-nernst.github.io/tcgen05/</guid><description>&lt;p>&lt;a href="https://docs.nvidia.com/cuda/parallel-thread-execution/#tensorcore-5th-generation-instructions">tcgen05&lt;/a> is the set of PTX instructions to program Tensor Cores on the latest NVIDIA Blackwell GPUs (&lt;code>sm100&lt;/code>, not to be confused with consumer Blackwell &lt;code>sm120&lt;/code>). At the time of writing, I couldn&amp;rsquo;t find a Blackwell tutorial in plain CUDA C++ with PTX, even though such exist for Ampere (&lt;a href="https://alexarmbr.github.io/2024/08/10/How-To-Write-A-Fast-Matrix-Multiplication-From-Scratch-With-Tensor-Cores.html">alexarmbr&amp;rsquo;s&lt;/a> and &lt;a href="https://www.spatters.ca/mma-matmul">spatters&amp;rsquo;&lt;/a>) and Hopper (&lt;a href="https://cudaforfun.substack.com/p/outperforming-cublas-on-h100-a-worklog">Pranjal&amp;rsquo;s&lt;/a>). So let&amp;rsquo;s write one, documenting my process of learning &lt;code>tcgen05&lt;/code> and reaching &lt;strong>98%&lt;/strong> of CuBLAS speed (on &lt;code>M=N=K=4096&lt;/code> problem shape)!&lt;/p></description></item><item><title>My first Multi-GPU kernel: Writing All-to-all for AMD MI300X</title><link>https://gau-nernst.github.io/amd-a2a/</link><pubDate>Sun, 02 Nov 2025 21:43:00 +0800</pubDate><guid>https://gau-nernst.github.io/amd-a2a/</guid><description>&lt;p>Last month, I participated in the AMD Distributed Challenge, hosted by &lt;a href="https://www.gpumode.com/v2/home">GPU MODE&lt;/a>. This was very exciting for me as it was the first time I learned how to write a multi-GPU kernel! Although I had a brief understanding of how DDP and FSDP worked under the hood via collective primitives like all-reduce and reduce-scatter, I didn&amp;rsquo;t know it was possible to perform remote memory access directly inside a kernel! It opens up a lot of opportunities for multi-GPU optimizations, especially overlapping compute with inter-GPU communications.&lt;/p></description></item><item><title>Use NVRTC to explore MMA instruction variants</title><link>https://gau-nernst.github.io/nvrtc-matmul/</link><pubDate>Mon, 08 Sep 2025 08:44:00 +0800</pubDate><guid>https://gau-nernst.github.io/nvrtc-matmul/</guid><description>&lt;p>Recently I tweeted about realistic Speed-of-Light (SOL) of 5090 and RTX PRO 6000 for some dtypes, and &lt;a href="https://x.com/mobicham/status/1963540008947617947">mobicham asked me about FP8 MMA with FP16 accumulation&lt;/a>. I of last year would turn to Triton for this - it&amp;rsquo;s trivial to change the accumulation dtype of &lt;a href="https://triton-lang.org/main/python-api/generated/triton.language.dot.html">tl.dot()&lt;/a>. However, I roughly know how to write a fast matmul kernel now, so why not do it myself! In addition, I have been tinkering around with &lt;a href="https://github.com/pytorch/pytorch/pull/151484">&lt;code>torch.cuda._compile_kernel()&lt;/code>&lt;/a>, which compiles CUDA kernels super fast via &lt;a href="https://docs.nvidia.com/cuda/nvrtc/index.html">NVRTC&lt;/a>. This seems ideal for JIT-compiled kernels and trying out all possible variants of the MMA instruction.&lt;/p></description></item><item><title>Writing Speed-of-Light Flash Attention for 5090 in CUDA C++</title><link>https://gau-nernst.github.io/fa-5090/</link><pubDate>Sat, 23 Aug 2025 15:25:20 +0800</pubDate><guid>https://gau-nernst.github.io/fa-5090/</guid><description>&lt;p>In this post, I will walk through how I learned to implement Flash Attention for 5090 in CUDA C++. The main objective is to learn writing attention in CUDA C++, since many features are not available in &lt;a href="https://triton-lang.org/main/index.html">Triton&lt;/a>, such as MXFP8 / NVFP4 MMA for sm120. I also feel this is a natural next step after learning about matmul kernels. Lastly, there are &lt;a href="https://alexarmbr.github.io/2024/08/10/How-To-Write-A-Fast-Matrix-Multiplication-From-Scratch-With-Tensor-Cores.html">many&lt;/a> &lt;a href="https://www.spatters.ca/mma-matmul">excellent&lt;/a> &lt;a href="https://cudaforfun.substack.com/p/outperforming-cublas-on-h100-a-worklog">blogposts&lt;/a> on writing fast matmul kernels, but there is none for attention. So I want to take this chance to write up something nicely.&lt;/p></description></item></channel></rss>