<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by IYKYK on Medium]]></title>
        <description><![CDATA[Stories by IYKYK on Medium]]></description>
        <link>https://medium.com/@iykyks33?source=rss-6c8385be62ee------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/proxy/1*TGH72Nnw24QL3iV9IOm4VA.png</url>
            <title>Stories by IYKYK on Medium</title>
            <link>https://medium.com/@iykyks33?source=rss-6c8385be62ee------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 01 Dec 2026 11:30:27 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@iykyks33/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[From 5 seconds to 20 ms: replicating a CPU matrix multiply on my laptop]]></title>
            <link>https://medium.com/@iykyks33/from-5-seconds-to-20-ms-replicating-a-cpu-matrix-multiply-on-my-laptop-feb4dd9044e5?source=rss-6c8385be62ee------2</link>
            <guid isPermaLink="false">https://medium.com/p/feb4dd9044e5</guid>
            <category><![CDATA[learning]]></category>
            <category><![CDATA[ai-hardware]]></category>
            <category><![CDATA[compilers]]></category>
            <category><![CDATA[ai]]></category>
            <dc:creator><![CDATA[IYKYK]]></dc:creator>
            <pubDate>Thu, 08 Oct 2026 07:23:20 GMT</pubDate>
            <atom:updated>2026-10-08T07:23:20.202Z</atom:updated>
            <content:encoded><![CDATA[<p>I rebuilt Simon Boehm’s “Fast Multidimensional Matrix Multiplication on CPU from Scratch” on my 2019 laptop. A naive 1024×1024 multiply took 5.3 seconds. Six changes later it ran in 19.5 ms, and numpy took 8.3 ms. At every step, my laptop stayed within 1.3× of the article’s desktop.</p><h3>Why I tried this</h3><p>Matrix multiplication is the operation underneath almost every neural network. Libraries like numpy hand it to a BLAS library tuned by experts, and it is fast. I wanted to see how much speed sits between a textbook triple loop and that library, and which changes actually buy it.</p><p>Simon Boehm’s 2022 article walks that path in six steps on a 4-core Intel desktop. I followed it line by line on my own laptop and measured every step.</p><h3>My setup</h3><p>My laptop turned out to be a close match for the article’s machine. It is four years newer and runs at a lower clock, but the core design, core count and caches are the same.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/793/1*agb_xryMansTWhQFmRgnxQ.png" /></figure><p>Every run multiplies two 1024×1024 float32 matrices, which is 2.15 billion floating-point operations. Each kernel runs once to warm up, then repeats for at least 2 seconds, and I report the median time. Every result is checked against a float64 reference, and the multithreaded output is also checked against numpy. With each run, a script records the CPU, compiler, flags and power state. The numbers below come from two runs on one afternoon, plugged in, with Windows set to Best performance.</p><h3>Results</h3><p>The two ladders have the same shape: a small gain from compiler flags, nothing from register accumulation, one huge drop from reordering the loops, then smaller gains from tiling and threads.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/778/1*KoeIToVJ3d-3VAiwRKgirQ.png" /><figcaption>Same ladder as the article: 5.3 s down to 19.5 ms on a 2019 laptop</figcaption></figure><h3>Step by step</h3><p>The speedups line up with the article everywhere except two steps: the loop reorder gained more on my laptop, and multithreading gained less.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/886/1*lGATZdwUD9ybNw5kaK_Lzg.png" /></figure><p>Step 4 is the whole story. The naive loop walks down a column of B, so every multiply lands on a new cache line. After the swap, the inner loop streams along rows. Each 64-byte cache line then feeds 16 floats, and the compiler can turn the loop into AVX2 fused multiply-adds on 8 floats at a time. Nothing else on the ladder comes close.</p><h3>What surprised me</h3><ul><li><strong>Register accumulation did nothing.</strong> Writing the running sum to a local variable gave 1.0×. clang 22 already keeps it in a register, which the article suspected a compiler could do.</li><li><strong>The single-threaded steps beat the article’s desktop.</strong> Steps 4 and 5 ran in 78.8 and 63.2 ms, against 89 and 70 ms in the article. It’s the same core design, but with a newer compiler, and one busy core can turbo to 4.1 GHz.</li><li><strong>Multithreading gained less on a laptop.</strong> I got 3.2× from four cores where the article got 4.4×. With all four cores loaded, my 45 W laptop drops its clock well below the single-core turbo.</li><li><strong>Hyperthreads helped.</strong> Eight threads ran in 19.5 ms and four threads in 27.0 ms, a 1.4× difference. This kernel mostly waits on loads and stores rather than on its FMA units, so a second thread per core fills those gaps.</li><li><strong>Free OpenBLAS matched Intel’s MKL.</strong> numpy took 8.3 ms on my laptop and 8 ms in the article. My best kernel is still 2.4× slower than that, almost the same 2× gap the article ended with.</li></ul><h3>What’s next</h3><ol><li><strong>Measure the real all-core clock</strong> and turn GFLOP/s into FLOPs per core per cycle. My CPU can do at most 32 per cycle. The article’s final kernel reached about 9 and MKL about 18. If my laptop holds about 3.5 GHz, I’m at roughly 8 and OpenBLAS at roughly 18.6, but I still have to measure the clock.</li><li><strong>Grid-search the tile size for my caches.</strong> Theory says a tile of about 3.5 rows fits a 32 KB L1, yet the article’s best was 16. Mine may differ again.</li><li><strong>Do three clean runs</strong> and report the median of the medians, instead of two runs on one afternoon.</li><li><strong>Close the 2.4× gap to BLAS.</strong> The article stops before register blocking and packing, which is where libraries like OpenBLAS get the rest of their speed.</li></ol><h3>Credits and sources</h3><ul><li>Simon Boehm, <a href="https://siboehm.com/articles/22/Fast-MMM-on-CPU">Fast Multidimensional Matrix Multiplication on CPU from Scratch</a> (August 2022). The kernels, the six-step ladder, and every “article” number in this post come from here.</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=feb4dd9044e5" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Kicking Off My Journey into AI Hardware]]></title>
            <link>https://medium.com/@iykyks33/kicking-off-my-journey-into-ai-hardware-89a0673a917a?source=rss-6c8385be62ee------2</link>
            <guid isPermaLink="false">https://medium.com/p/89a0673a917a</guid>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[compiler-design]]></category>
            <category><![CDATA[computer-hardware]]></category>
            <dc:creator><![CDATA[IYKYK]]></dc:creator>
            <pubDate>Mon, 05 Oct 2026 18:28:54 GMT</pubDate>
            <atom:updated>2026-10-05T18:28:54.479Z</atom:updated>
            <content:encoded><![CDATA[<p>It’s been more than a year since I last coded in C/C++, so I decided to start small by solving a few mathematical problems in C++. I’ve solved a couple so far.</p><p>Back in college, I was introduced to LLMs, and about a year later I came across Ollama. I was curious how long the GPU in my PC would take to process a request locally. So I went deeper and ran into GPUs, TPUs and NPUs. Then I noticed something unexpected: all of them are built to do one thing at massive scale, which is matrix multiplication.</p><p>That got me looking for ways to multiply matrices faster than the standard O(N³) approach. To my surprise, I found a 2022 paper from Google DeepMind called AlphaTensor, published before ChatGPT made AI a mainstream thing. The team used reinforcement learning to discover matrix multiplication algorithms that need fewer multiplications than the best ones humans had found. For example, it multiplied 4×4 matrices (in modular arithmetic) with 47 multiplications instead of Strassen’s 49. To be honest, I was amazed at first. Then it hit me: they used an ML algorithm to speed up the very thing ML algorithms spend all their time doing. You’ve got to be kidding me, right?</p><p>Today, I decided to dig into how Google TPUs, NPUs and the mighty Nvidia GPUs are built on the inside. That’s where I learned about GEMM, BLAS, systolic arrays, XLA, MXUs, neuromorphic chips, cuDNN and CUTLASS.</p><p>Starting today, I’m going to document everything I learn here, in public.</p><p>RIGHT TIME. RIGHT NOW.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=89a0673a917a" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>