<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title>CUDA on AIBussin — AI applications, systems and books</title>
		<link>https://aibussin.com/tags/cuda/</link>
		<description>Recent content in CUDA on AIBussin — AI applications, systems and books</description>
		<generator>Hugo</generator>
		<language>en-US</language>
		
		
		
		
			<lastBuildDate>Thu, 26 Nov 2026 23:58:38 +0000</lastBuildDate>
		
			<atom:link href="https://aibussin.com/tags/cuda/index.xml" rel="self" type="application/rss+xml" />
			<item>
				<title>Matrix Multiplication and GPU Execution</title>
				<link>https://aibussin.com/books/inference/07-chapter/</link>
				<pubDate>Tue, 20 Oct 2026 00:00:00 +0100</pubDate>
				<guid>https://aibussin.com/books/inference/07-chapter/</guid>
				<description>&lt;p&gt;Moving the &lt;a href=&#34;https://aibussin.com/books/inference/06-chapter/&#34;&gt;Building Our First Inference Engine&lt;/a&gt; engine from one CPU thread to a GPU made it &lt;strong&gt;14.2 times faster&lt;/strong&gt;. Thirty-two greedy GPT-2 tokens took a median of 6.41 seconds on the CPU and 0.453 seconds on the GPU, over five runs each, and the generated token ids agreed.&lt;/p&gt;&#xA;&lt;p&gt;That sounds like a lot until you compare the hardware. On this machine, a large fp32 matrix product reached about 7.4 TFLOP/s on the GPU in the best observed runs, while one CPU thread reached about 53 GFLOP/s: a ratio of roughly 140. So why did the engine only get 14 times faster?&lt;/p&gt;</description>
			</item>
			<item>
				<title>The Memory and Compute Budget</title>
				<link>https://aibussin.com/books/fine-tuning/11-chapter/</link>
				<pubDate>Wed, 18 Nov 2026 00:00:00 +0000</pubDate>
				<guid>https://aibussin.com/books/fine-tuning/11-chapter/</guid>
				<description>&lt;p&gt;A model&amp;rsquo;s parameter arrays occupy less than a megabyte, yet a CUDA measurement reports tens of megabytes allocated. The discrepancy need not indicate a leak. A training step contains gradients, moment estimates, saved forward values and temporary workspace, and the runtime may retain storage for later reuse. To understand a measurement, we must specify both what it counts and where its interval begins.&lt;/p&gt;&#xA;&lt;p&gt;Chapter 04 estimated resource requirements before execution. Here we reuse its arithmetic where the assumptions match and compare it with actual tensors from our shared Transformer. We are measuring runtime mechanisms, not revisiting the financial case for adaptation or certifying that a future language model fits on the same GPU.&lt;/p&gt;</description>
			</item>
			<item>
				<title>Performance: What Is the Machine Waiting For?</title>
				<link>https://aibussin.com/books/pytorch-from-first-principles/12-chapter/</link>
				<pubDate>Sat, 29 Aug 2026 16:00:00 +0100</pubDate>
				<guid>https://aibussin.com/books/pytorch-from-first-principles/12-chapter/</guid>
				<description>&lt;p&gt;Here is a benchmark. A model, a batch, a loop, a timer. Nothing exotic.&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-python&#34; data-lang=&#34;python&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;model&lt;span style=&#34;color:#f92672&#34;&gt;.&lt;/span&gt;train()&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;t0 &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; time&lt;span style=&#34;color:#f92672&#34;&gt;.&lt;/span&gt;perf_counter()&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;for&lt;/span&gt; _ &lt;span style=&#34;color:#f92672&#34;&gt;in&lt;/span&gt; range(&lt;span style=&#34;color:#ae81ff&#34;&gt;20&lt;/span&gt;):&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    optimizer&lt;span style=&#34;color:#f92672&#34;&gt;.&lt;/span&gt;zero_grad(set_to_none&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;True&lt;/span&gt;)&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    loss &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; F&lt;span style=&#34;color:#f92672&#34;&gt;.&lt;/span&gt;cross_entropy(model(x), y)          &lt;span style=&#34;color:#75715e&#34;&gt;# MLP, batch 256&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    loss&lt;span style=&#34;color:#f92672&#34;&gt;.&lt;/span&gt;backward()&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    optimizer&lt;span style=&#34;color:#f92672&#34;&gt;.&lt;/span&gt;step()&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;ms_per_step &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; (time&lt;span style=&#34;color:#f92672&#34;&gt;.&lt;/span&gt;perf_counter() &lt;span style=&#34;color:#f92672&#34;&gt;-&lt;/span&gt; t0) &lt;span style=&#34;color:#f92672&#34;&gt;/&lt;/span&gt; &lt;span style=&#34;color:#ae81ff&#34;&gt;20&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;*&lt;/span&gt; &lt;span style=&#34;color:#ae81ff&#34;&gt;1000&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-text&#34; data-lang=&#34;text&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;naive loop of   20:   9.491 ms/step reported   + 132.0 ms still queued at the final sync   -&amp;gt; really 16.093 ms/step&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;naive loop of  100:  14.692 ms/step reported   + 138.8 ms still queued at the final sync   -&amp;gt; really 16.080 ms/step&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;naive loop of  400:  15.741 ms/step reported   + 132.1 ms still queued at the final sync   -&amp;gt; really 16.071 ms/step&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;synchronized + warmed, median of 400 :  16.430 ms/step   &amp;lt;- the real number&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;one step, host-visible return only   :   4.866 ms/step&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;first training step ever             :  20.890 ms&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Read the first line again. The loop ran twenty iterations and reported &lt;code&gt;9.491&lt;/code&gt; ms per step. Then a single &lt;code&gt;torch.cuda.synchronize()&lt;/code&gt; immediately afterward blocked for &lt;code&gt;132&lt;/code&gt; more milliseconds — roughly eight more steps&amp;rsquo; worth of work that the GPU had not finished when the timer stopped. Loop over a hundred iterations instead and the same code reports &lt;code&gt;14.7&lt;/code&gt;. Over four hundred, &lt;code&gt;15.7&lt;/code&gt;. Time one step in isolation and it looks like &lt;code&gt;4.9&lt;/code&gt;.&lt;/p&gt;</description>
			</item>
			<item>
				<title>Set Up a Reproducible Local Training Environment</title>
				<link>https://aibussin.com/books/fine-tuning/19-chapter/</link>
				<pubDate>Thu, 19 Nov 2026 00:00:00 +0000</pubDate>
				<guid>https://aibussin.com/books/fine-tuning/19-chapter/</guid>
				<description>&lt;p&gt;A CUDA matrix multiplication succeeds, the GPU has several gigabytes free, and the&#xA;package installer reports no broken requirements. We still do not know whether a&#xA;particular language model can be loaded safely, whether its tokenizer matches its&#xA;embeddings, or whether adapting it is an authorised experiment. Each observation&#xA;answers a narrower question than the proposed run.&lt;/p&gt;&#xA;&lt;p&gt;Part II made a small Transformer inspectable. This chapter prepares a different&#xA;boundary: a reproducible environment in which a pinned pretrained checkpoint could&#xA;eventually be investigated. The distinction matters because a model introduces&#xA;external weights, architecture-specific kernels, tokenizer assets and additional&#xA;rights and resource requirements. A working educational loop cannot certify those&#xA;dependencies by inheritance.&lt;/p&gt;</description>
			</item>
			<item>
				<title>Run Cellular Automata on the GPU</title>
				<link>https://aibussin.com/books/cellular-automata-from-first-principles/52-chapter/</link>
				<pubDate>Mon, 10 Aug 2026 20:54:00 +0100</pubDate>
				<guid>https://aibussin.com/books/cellular-automata-from-first-principles/52-chapter/</guid>
				<description>&lt;p&gt;Once the update is expressed as tensor operations, moving to a GPU becomes straightforward.&lt;/p&gt;&#xA;&lt;p&gt;But a GPU is not automatically faster.&lt;/p&gt;&#xA;&lt;p&gt;It wins when there is enough parallel work to amortize transfer and launch overhead.&lt;/p&gt;&#xA;&lt;hr&gt;&#xA;&lt;h2 id=&#34;a-tensor-implementation-of-life&#34;&gt;A tensor implementation of Life&lt;/h2&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-python&#34; data-lang=&#34;python&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;import&lt;/span&gt; torch&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;import&lt;/span&gt; torch.nn.functional &lt;span style=&#34;color:#66d9ef&#34;&gt;as&lt;/span&gt; F&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;LIFE_KERNEL &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; torch&lt;span style=&#34;color:#f92672&#34;&gt;.&lt;/span&gt;tensor(&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    [[&lt;span style=&#34;color:#ae81ff&#34;&gt;1.0&lt;/span&gt;, &lt;span style=&#34;color:#ae81ff&#34;&gt;1.0&lt;/span&gt;, &lt;span style=&#34;color:#ae81ff&#34;&gt;1.0&lt;/span&gt;],&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;     [&lt;span style=&#34;color:#ae81ff&#34;&gt;1.0&lt;/span&gt;, &lt;span style=&#34;color:#ae81ff&#34;&gt;0.0&lt;/span&gt;, &lt;span style=&#34;color:#ae81ff&#34;&gt;1.0&lt;/span&gt;],&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;     [&lt;span style=&#34;color:#ae81ff&#34;&gt;1.0&lt;/span&gt;, &lt;span style=&#34;color:#ae81ff&#34;&gt;1.0&lt;/span&gt;, &lt;span style=&#34;color:#ae81ff&#34;&gt;1.0&lt;/span&gt;]]&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;)&lt;span style=&#34;color:#f92672&#34;&gt;.&lt;/span&gt;view(&lt;span style=&#34;color:#ae81ff&#34;&gt;1&lt;/span&gt;, &lt;span style=&#34;color:#ae81ff&#34;&gt;1&lt;/span&gt;, &lt;span style=&#34;color:#ae81ff&#34;&gt;3&lt;/span&gt;, &lt;span style=&#34;color:#ae81ff&#34;&gt;3&lt;/span&gt;)&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;def&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;life_step&lt;/span&gt;(x):&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    padded &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; F&lt;span style=&#34;color:#f92672&#34;&gt;.&lt;/span&gt;pad(x, (&lt;span style=&#34;color:#ae81ff&#34;&gt;1&lt;/span&gt;, &lt;span style=&#34;color:#ae81ff&#34;&gt;1&lt;/span&gt;, &lt;span style=&#34;color:#ae81ff&#34;&gt;1&lt;/span&gt;, &lt;span style=&#34;color:#ae81ff&#34;&gt;1&lt;/span&gt;), mode&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;circular&amp;#34;&lt;/span&gt;)&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    neighbors &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; F&lt;span style=&#34;color:#f92672&#34;&gt;.&lt;/span&gt;conv2d(padded, LIFE_KERNEL&lt;span style=&#34;color:#f92672&#34;&gt;.&lt;/span&gt;to(x&lt;span style=&#34;color:#f92672&#34;&gt;.&lt;/span&gt;device))&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    alive &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; x &lt;span style=&#34;color:#f92672&#34;&gt;&amp;gt;&lt;/span&gt; &lt;span style=&#34;color:#ae81ff&#34;&gt;0.5&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    born &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; neighbors &lt;span style=&#34;color:#f92672&#34;&gt;==&lt;/span&gt; &lt;span style=&#34;color:#ae81ff&#34;&gt;3&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    survive &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; alive &lt;span style=&#34;color:#f92672&#34;&gt;&amp;amp;&lt;/span&gt; (neighbors &lt;span style=&#34;color:#f92672&#34;&gt;==&lt;/span&gt; &lt;span style=&#34;color:#ae81ff&#34;&gt;2&lt;/span&gt;)&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#66d9ef&#34;&gt;return&lt;/span&gt; (born &lt;span style=&#34;color:#f92672&#34;&gt;|&lt;/span&gt; survive)&lt;span style=&#34;color:#f92672&#34;&gt;.&lt;/span&gt;float()&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Two things matter here beyond the convolution. First, this is the third &lt;code&gt;life_step&lt;/code&gt; in the book (after Chapters 6 and 51) — same B3/S23 rule, new backend, bridged explicitly rather than silently redefined. Second, the padding mode is load-bearing: plain &lt;code&gt;padding=1&lt;/code&gt; zero-pads, which silently changes periodic boundaries into dead ones. Circular padding preserves the torus semantics every roll-based helper in this book assumes — verified bit-identical against the NumPy version on 20 random grids, where the zero-padded variant mismatched all 20 at the edges.&lt;/p&gt;</description>
			</item>
			<item>
				<title>Inkling 2 Mini: From Local Inference to Working AI Agents</title>
				<link>https://aibussin.com/post/inkling/</link>
				<pubDate>Thu, 26 Nov 2026 23:58:38 +0000</pubDate>
				<guid>https://aibussin.com/post/inkling/</guid>
				<description>&lt;p&gt;On November 20, 2026, Thinking Machines Lab released Inkling 2 Mini. Six days later, I had it running on my Windows desktop with an NVIDIA RTX 2060 and 12 GB of video memory.&lt;/p&gt;&#xA;&lt;p&gt;After resolving a CUDA installation problem and experimenting with different context configurations, I arrived at a setup that generates 37.2 tokens per second with a 16,384-token context window.&lt;/p&gt;&#xA;&lt;p&gt;I connected the model to Pi and asked it to read existing software, create a Python module with eight unit tests, and repair an implementation containing two known defects. All three experiments passed independent verification.&lt;/p&gt;</description>
			</item>
	</channel>
</rss>
