<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Numerical Computing on Matt Suiche</title><link>https://www.msuiche.com/categories/numerical-computing/</link><description>Recent content in Numerical Computing on Matt Suiche</description><generator>Hugo</generator><language>en-us</language><lastBuildDate>Fri, 17 Oct 2025 00:00:00 +0000</lastBuildDate><atom:link href="https://www.msuiche.com/categories/numerical-computing/index.xml" rel="self" type="application/rss+xml"/><item><title>Porting CUDA FFT to Mojo: Achieving Bit-Exact Precision</title><link>https://www.msuiche.com/posts/porting-cuda-fft-to-mojo-achieving-bit-exact-precision/</link><pubDate>Fri, 17 Oct 2025 00:00:00 +0000</pubDate><guid>https://www.msuiche.com/posts/porting-cuda-fft-to-mojo-achieving-bit-exact-precision/</guid><description>&lt;p&gt;Porting a CUDA Fast Fourier Transform (FFT) implementation to Mojo for the &lt;a href="https://leetgpu.com/challenges/fast-fourier-transform" target="_blank" rel="noopener"&gt;LeetGPU Fast Fourier Transform challenge&lt;/a&gt; presented an unexpected challenge: achieving bit-exact precision matching between CUDA&amp;rsquo;s &lt;code&gt;sinf()&lt;/code&gt;/&lt;code&gt;cosf()&lt;/code&gt; functions and their Mojo equivalents. This required PTX assembly analysis, cross-platform testing, and ultimately upgrading to Float64 precision for deterministic results.&lt;/p&gt;
&lt;h2 id="challenge-constraints"&gt;Challenge Constraints &lt;a href="#challenge-constraints" class="anchor"&gt;🔗&lt;/a&gt;&lt;/h2&gt;&lt;ul&gt;
&lt;li&gt;N range: $1 \leq N \leq 262,144$ (power-of-2 FFT sizes)&lt;/li&gt;
&lt;li&gt;Data type: All values are 32-bit floating point numbers&lt;/li&gt;
&lt;li&gt;Accuracy requirements: Absolute error $\leq 10^{-3}$, Relative error $\leq 10^{-3}$&lt;/li&gt;
&lt;li&gt;Array format: Input and output arrays have length $2N$ (interleaved real/imaginary)&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id="initial-problem-accuracy-mismatch"&gt;Initial Problem: Accuracy Mismatch &lt;a href="#initial-problem-accuracy-mismatch" class="anchor"&gt;🔗&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;The initial Mojo FFT implementation failed correctness tests with a maximum absolute difference of 0.023 compared to the reference CUDA implementation. For a coding challenge requiring exact equality, this was unacceptable.&lt;/p&gt;</description></item></channel></rss>