<?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"><channel><title><![CDATA[samuphys lab]]></title><description><![CDATA[samuphys lab]]></description><link>https://samuphys-lab.hashnode.dev</link><image><url>https://cdn.hashnode.com/uploads/logos/6aa9365b77f820e1cd9d2e8c/2f5ca618-909a-4bd1-bd6f-b48a881a8e59.jpg</url><title>samuphys lab</title><link>https://samuphys-lab.hashnode.dev</link></image><generator>RSS for Node</generator><lastBuildDate>Sat, 05 Dec 2026 01:11:49 GMT</lastBuildDate><atom:link href="https://samuphys-lab.hashnode.dev/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[Benchmarking a 63.7M-Triangle Procedural City in Godot 4.4 and UE 5.8 — and Why I Stayed on Godot]]></title><description><![CDATA[Fixed cost vs. variable cost when rendering 49 procedurally assembled city blocks]]></description><link>https://samuphys-lab.hashnode.dev/godot-4-4-vs-ue-5-8-63m-triangle-procedural-city</link><guid isPermaLink="true">https://samuphys-lab.hashnode.dev/godot-4-4-vs-ue-5-8-63m-triangle-procedural-city</guid><category><![CDATA[Godot]]></category><category><![CDATA[unreal-engine]]></category><category><![CDATA[Game Development]]></category><category><![CDATA[3d]]></category><category><![CDATA[Benchmark]]></category><dc:creator><![CDATA[Samu (samuphys)]]></dc:creator><pubDate>Mon, 23 Nov 2026 09:03:39 GMT</pubDate><enclosure url="https://cdn.hashnode.com/uploads/covers/6aa9365b77f820e1cd9d2e8c/7fff4f4c-c794-4bac-8e67-727603153c8e.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p><em>Hakoniwa (箱庭, 'box garden') is what Japanese game criticism calls a small, self-contained world you tend and meddle with from above.</em></p>
<h2>Background: Why I Tested Both, and What I Decided</h2>
<p>AI coding agents have gotten capable enough lately that I decided to build a hakoniwa naval combat game. I want an isometric (angled orthographic) view that keeps a grid feel while using procedural generation to give city blocks real variety without building everything by hand.</p>
<p>Here is the short version: <strong>I rendered and measured my procedural city (63.7 million triangles) in both Godot 4.4 and Unreal Engine 5.8, and decided to stay on Godot for this project.</strong></p>
<p>The test started when Godot's auto-LOD failed to reduce frame time and raised an obvious question: "Should I move to UE5 for Nanite instead?" My buildings are not imported as single per-building 3D models; I assemble them from wall cells and other modular parts.</p>
<p>What I found: under my requirement of assembling buildings at runtime, UE tied with Godot at Far zoom, and Godot was 2–3x lighter at Mid and Close. This post records the test setup, the raw numbers, and why I made the call. It is not a general claim that Godot is faster than UE5 — I state the exact scope at the end.</p>
<img src="https://cdn.hashnode.com/uploads/covers/6aa9365b77f820e1cd9d2e8c/6f2ac0c8-6fbe-4e53-a15d-39a14972186d.png" alt="godot_vs_UE5" style="display:block;margin:0 auto" />

<p><em>Left: Godot (with dirt shader) / Right: UE Parts-ISM (flat shading)</em></p>
<h2>Test Setup: 49 City Blocks from the Same Layout Spec</h2>
<p>For a shared test scene, I took 8 block designs from my layout layer and tiled them into a 7×7 = 49 block grid at 48 m spacing. Including 4 cm bevels and detail stamps, the scene totaled <strong>63,696,890 triangles</strong>. I verified that summing the exported GLBs for UE across all 49 blocks produced the exact same triangle count. Neither engine had water, trees, or terrain in the scene.</p>
<table>
<thead>
<tr>
<th>Item</th>
<th>Details</th>
</tr>
</thead>
<tbody><tr>
<td>Hardware</td>
<td>Laptop with a desktop-class Core i7-9700 / RTX 2070 / 64 GB RAM / Windows 11</td>
</tr>
<tr>
<td>Godot</td>
<td>4.4.1 stable, Vulkan, Forward+. Ran as a standalone process without the editor</td>
</tr>
<tr>
<td>UE</td>
<td>5.8, Development configuration, D3D12 SM6. <strong>Play In Editor (PIE)</strong>. Packaged build was not measured</td>
</tr>
<tr>
<td>Camera</td>
<td>Both orthographic, 30° elevation, same heading. Three zoom levels — Far (~190 m view height), Mid, and Close — matched to show the exact same area</td>
</tr>
<tr>
<td>Lighting</td>
<td>(1) <strong>Matched lighting</strong>: Lumen GI and reflections off, FXAA (Virtual Shadow Maps left at project default). (2) <strong>Default UE lighting</strong>: Lumen + TSR + volumetric clouds</td>
</tr>
<tr>
<td>Timing</td>
<td>Godot: mean frame interval over 160 frames after a 40-frame warmup. UE: <code>StartFPSChart</code> Average GPU frametime</td>
</tr>
</tbody></table>
<img src="https://cdn.hashnode.com/uploads/covers/6aa9365b77f820e1cd9d2e8c/00c3db6c-6afc-402e-ad95-99e89f4ad9cb.png" alt="godot_3phase" style="display:block;margin:0 auto" />

<p><em>Three zoom levels in Godot</em></p>
<h2>Walls I Hit in Both Engines</h2>
<p><strong>Godot's wall: auto-LOD appeared broken — the input mesh was at fault.</strong> At first, even with <code>generate_lods</code> enabled, Far zoom took 43–46 ms. That was what prompted me to evaluate UE5. The engine was not the problem; triangle winding order on my beveled edges was inconsistent. The moment I fixed the winding order, Far frame time dropped from 43–46 ms to <strong>9.91 ms</strong> (48.79 ms with LOD disabled; breaking down the geometry cost, plain boxes took 6.25 ms, adding stamps took 8.15 ms, and adding bevels reached 9.91 ms). Auto-LOD quality is governed by input mesh regularity — the most expensive lesson of this benchmark.</p>
<p><strong>UE's wall: Nanite does not run on runtime-generated meshes out of the box.</strong> My requirements (runtime generation and per-piece destruction) conflicted with Nanite's assumption (pre-built static meshes), so I built two setups in UE:</p>
<ul>
<li><strong>Whole-block</strong>: GLB converted to FBX via Blender, imported as 8 block-sized Nanite <code>StaticMesh</code> assets placed as 49 actors. This lets Nanite perform at full strength, but does not work for runtime changes or individual piece destruction. Vertex colors also got stripped going through FBX, leaving every block solid white.</li>
<li><strong>Parts-ISM</strong>: 51 pre-made Nanite part meshes (unit box, cylinder, and 49 stamps) placed via <code>InstancedStaticMesh</code> (ISM). Across 49 blocks, this came to <strong>1,257,329 instances</strong>. This is the realistic setup that satisfies my runtime requirements.</li>
</ul>
<h2>Results: Fixed Cost in UE, Variable Cost in Godot</h2>
<p>Summary under <strong>Matched lighting</strong>, in ms (Godot is full frame time; UE is GPU time — I cover this metric mismatch in the limitations section):</p>
<table>
<thead>
<tr>
<th>Setup (Metric)</th>
<th>Far</th>
<th>Mid</th>
<th>Close</th>
</tr>
</thead>
<tbody><tr>
<td><strong>Godot: 1 mesh/building + auto-LOD + dirt shader</strong> (full frame)</td>
<td><strong>10.11</strong></td>
<td><strong>3.36</strong></td>
<td><strong>1.88</strong></td>
</tr>
<tr>
<td><strong>UE Parts-ISM: 51 Nanite parts × 1.25M ISM</strong> (GPU time)</td>
<td>9.53</td>
<td>8.58</td>
<td>6.85</td>
</tr>
<tr>
<td>(Reference) UE Whole-block: 1 mesh/block × 49 actors (GPU time)</td>
<td>6.19</td>
<td>5.12</td>
<td>5.71</td>
</tr>
</tbody></table>
<p>Three takeaways:</p>
<ol>
<li><strong>Whole-block UE stayed flat across every zoom level.</strong> Far or Close, it sat at 5–6 ms — a fixed-cost regime independent of triangle count, which is Nanite doing what it was built for.</li>
<li><strong>With Parts-ISM — the setup that meets runtime requirements — UE tied at Far, and Godot was 2–3x lighter at Mid and Close.</strong> Godot acts as a variable cost that scales down with what is on screen, dropping to 1.88 ms at Close.</li>
<li><strong>The lighting cost in UE was ~6–7 ms</strong> (estimated by subtraction). Switching to Default UE lighting (Lumen + TSR + volumetric clouds) pushed GPU time into the 12–14 ms range.</li>
</ol>
<blockquote>
<p>Note: UE's frame rate capped around 115 fps at every distance because PIE's game thread (~7–8 ms of editor work) was the limiter. That is why I compared GPU time for UE.</p>
</blockquote>
<p>Side note on generation time: assembling 8 blocks in Godot took 54 s in naive GDScript, dropped to 16.6 s with <code>numpy</code> across 8 threads, and took <strong>0.54 s</strong> loading from disk cache. Placing parts in UE via Python took 0.6–0.9 s per block.</p>
<h2>Detailed Benchmark Tables</h2>
<h3>Godot 4.4.1 Details (49 Blocks, Full Frame Time)</h3>
<table>
<thead>
<tr>
<th>Condition</th>
<th>Far</th>
<th>Mid</th>
<th>Close</th>
</tr>
</thead>
<tbody><tr>
<td>With LOD (color only)</td>
<td>9.91 ms (100.9 fps)</td>
<td>3.23 ms (310.0 fps)</td>
<td>1.75 ms (572.5 fps)</td>
</tr>
<tr>
<td><strong>+ Dirt shader (representative)</strong></td>
<td><strong>10.11 ms (98.9 fps)</strong></td>
<td><strong>3.36 ms (297.8 fps)</strong></td>
<td><strong>1.88 ms (530.9 fps)</strong></td>
</tr>
<tr>
<td>Arrays loaded from file and cache</td>
<td>9.38 ms (106.7 fps)</td>
<td>3.41 ms (293.2 fps)</td>
<td>1.80 ms (557.1 fps)</td>
</tr>
<tr>
<td>Without LOD</td>
<td>48.79 ms (20.5 fps)</td>
<td>—</td>
<td>—</td>
</tr>
</tbody></table>
<h3>UE 5.8 Whole-Block (GPU Time and Thread Breakdown)</h3>
<table>
<thead>
<tr>
<th>Lighting</th>
<th>Zoom</th>
<th>fps</th>
<th>GPU</th>
<th>Render Thread</th>
<th>Game Thread</th>
</tr>
</thead>
<tbody><tr>
<td>Matched lighting</td>
<td>Far</td>
<td>116.6</td>
<td><strong>6.19 ms</strong></td>
<td>6.63</td>
<td>7.23</td>
</tr>
<tr>
<td>Matched lighting</td>
<td>Mid</td>
<td>114.8</td>
<td><strong>5.12 ms</strong></td>
<td>6.83</td>
<td>7.72</td>
</tr>
<tr>
<td>Matched lighting</td>
<td>Close</td>
<td>117.4</td>
<td><strong>5.71 ms</strong></td>
<td>6.56</td>
<td>7.16</td>
</tr>
<tr>
<td>Default UE lighting</td>
<td>Far</td>
<td>75.6</td>
<td><strong>12.12 ms</strong></td>
<td>13.07</td>
<td>7.47</td>
</tr>
<tr>
<td>Default UE lighting</td>
<td>Close</td>
<td>72.2</td>
<td><strong>12.80 ms</strong></td>
<td>13.73</td>
<td>7.21</td>
</tr>
</tbody></table>
<h3>UE 5.8 Parts-ISM — 1.25M Instances (GPU Time and Thread Breakdown)</h3>
<table>
<thead>
<tr>
<th>Lighting</th>
<th>Zoom</th>
<th>fps</th>
<th>GPU</th>
<th>Render Thread</th>
<th>Game Thread</th>
</tr>
</thead>
<tbody><tr>
<td>Matched lighting</td>
<td>Far</td>
<td>95.6</td>
<td><strong>9.53 ms</strong></td>
<td>10.43</td>
<td>6.93</td>
</tr>
<tr>
<td>Matched lighting</td>
<td>Mid</td>
<td>107.2</td>
<td><strong>8.58 ms</strong></td>
<td>9.32</td>
<td>7.10</td>
</tr>
<tr>
<td>Matched lighting</td>
<td>Close</td>
<td>115.9</td>
<td><strong>6.85 ms</strong></td>
<td>6.73</td>
<td>7.87</td>
</tr>
<tr>
<td>Default UE lighting</td>
<td>Far</td>
<td>66.8</td>
<td><strong>14.15 ms</strong></td>
<td>14.97</td>
<td>7.50</td>
</tr>
<tr>
<td>Default UE lighting</td>
<td>Close</td>
<td>73.1</td>
<td><strong>12.78 ms</strong></td>
<td>13.67</td>
<td>7.08</td>
</tr>
</tbody></table>
<h2>Caveats and Limitations</h2>
<ol>
<li><strong>Metric and execution mode mismatch.</strong> Godot's numbers are full frame time (including CPU), while UE's are GPU time only — the metric disadvantages Godot. Conversely, Godot ran as a standalone process while UE ran in Play In Editor (PIE) without measuring a packaged build — the execution mode disadvantages UE (a packaged build could run lighter). Bias remains in both directions.</li>
<li><strong>Virtual Shadow Maps (VSM) stayed enabled in UE's Matched lighting.</strong> I turned off Lumen and volumetric clouds, but left project-default VSM enabled. Because 1.25M ISM instances paired with VSM is a demanding combination, I have not measured the limits of switching VSM to traditional shadow maps or using non-Nanite LODs with HISM/ISM.</li>
<li><strong>Differences in what was drawn.</strong> Godot included a procedural dirt shader; UE used flat shading and color only (and Whole-block lost vertex colors to white). Resolution also differed: compared to Godot's 1600×900, UE's actual PIE viewport measured ≈1378×775 (≈26% fewer pixels). In Parts-ISM, non-uniform scaling on the unit box stretched the 4 cm bevel up to 40 cm on large walls — valid as an instance and triangle load test, but unusable visually as-is.</li>
<li><strong>N=1.</strong> Each condition was measured once. Whole-block runs were triggered manually, so recording lengths varied from 8.6 to 19.1 s, and I have no log confirming whether VSync-disable commands were re-entered for the Parts-ISM session.</li>
<li><strong>Hybrid GPU routing.</strong> Post-test log checks confirmed that <strong>both engines rendered on the RTX 2070</strong> (UE log <code>Chosen D3D12 Adapter</code> = RTX 2070, driver 552.44; Godot startup log <code>Vulkan Device #0</code> = RTX 2070). Because this is a laptop, display output passed through the integrated GPU (Intel UHD 630), adding the same present overhead to both engines. That does not skew the relative comparison, though absolute frame times include that shared cost. A discrepancy between the DXGI output count and the Windows display mode readout remains unresolved (likely how the hybrid display path reports outputs).</li>
<li><strong>Estimates vs. direct measurements.</strong> The "5–6 ms fixed cost" and "~6–7 ms lighting cost" figures are read by subtracting between test conditions, not summed from profiler pass breakdowns. UE VRAM and RAM usage were not measured (Godot used 400 MB VRAM).</li>
</ol>
<h2>Why I Chose Godot</h2>
<p>Before testing, I assumed drawing a city of tens of millions of triangles might force me onto UE5. After measuring, <strong>performance gave me no reason to pick UE</strong>.</p>
<ul>
<li>Once I switched UE to Parts-ISM to meet my runtime requirements, the toughest Far view was a tie (~10 ms). At Mid and Close, where actual gameplay happens, Godot was 2–3x lighter.</li>
<li>Parts-ISM also introduced stretched bevels, which would take extra work to fix visually.</li>
</ul>
<p>Where UE clearly pulls ahead is lighting. Replicating Lumen's indirect bounce — say, fire on a night sea lighting up smoke and waves — would be a struggle in my Godot setup. If realistic night lighting were the main selling point, paying ~6–7 ms for UE5 would be worth it.</p>
<p>For the game I am actually making, my design rules are set:</p>
<ul>
<li>Weapons and units use symbolic, stylized representations</li>
<li>Building destruction is deterministic</li>
<li>Effects are stylized rather than photorealistic</li>
</ul>
<p>Against those rules and practical workflow factors (text-friendly assets, lightweight editor, MIT license), Godot was the rational choice. <strong>If I ever decide to make photorealistic night visuals a selling point, I plan to re-measure then.</strong> Until then, I plan to keep building in Godot.</p>
<h2>Scope of This Conclusion</h2>
<p>This post is not a general claim that Godot is lighter than UE5. It is an engineering decision log for one specific set of constraints: <strong>an orthographic camera, stylized visuals, tens of millions of triangles in procedural city blocks, runtime assembly, and deterministic destruction.</strong> Change even one constraint — a free-roaming perspective camera, pre-baked static meshes, or photorealistic lighting — and the break-even point likely shifts.</p>
<img src="https://cdn.hashnode.com/uploads/covers/6aa9365b77f820e1cd9d2e8c/00c6b75e-5a24-4d29-9f2b-5d8901cda5ac.png" alt="current" style="display:block;margin:0 auto" />

<p><em>Development view in Godot</em></p>
<hr />
<p><em>Measured on November 10, 2026, with Godot 4.4.1 and UE 5.8. I ran this benchmark as part of an AI-agent-driven solo game project (covered in a separate post).</em></p>
]]></content:encoded></item><item><title><![CDATA[Implementing Kolmogorov-Arnold Networks as Dense GEMMs in JAX: A Neural QMC Experiment]]></title><description><![CDATA[A deep dive into optimizing Neural QMC. Learn how we built FermiKAN in JAX, demonstrating a 330x parameter compression over FermiNet for the H2.]]></description><link>https://samuphys-lab.hashnode.dev/implementing-kolmogorov-arnold-networks-as-dense-gemms-in-jax-a-neural-qmc-experiment</link><guid isPermaLink="true">https://samuphys-lab.hashnode.dev/implementing-kolmogorov-arnold-networks-as-dense-gemms-in-jax-a-neural-qmc-experiment</guid><category><![CDATA[jax]]></category><category><![CDATA[ai for science]]></category><category><![CDATA[scientific-computing]]></category><category><![CDATA[Deep Learning]]></category><category><![CDATA[Python]]></category><dc:creator><![CDATA[Samu (samuphys)]]></dc:creator><pubDate>Wed, 16 Sep 2026 15:03:53 GMT</pubDate><enclosure url="https://cdn.hashnode.com/uploads/covers/6aa9365b77f820e1cd9d2e8c/f053f4ce-afc2-417c-b63e-c02903cbfff6.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<blockquote>
<p><strong>Update (Sep 2026)</strong>: After publishing, I found problems in the design described here, and I have revised this post.</p>
<p>The ε-manifold mapping (originally Sections 1–2) was unnecessary. Real solid harmonics are polynomials in x, y, z with no singularity at the origin, and the exponential envelope keeps the orbitals bounded at large r. In practice, training without ε did not diverge either. The electron-nucleus cusp is not exactly satisfied for molecular orbitals, because contributions from other atoms shift the slope at each nucleus. All runs were on GPU. Statements about TPUs describe expected behavior based on the dense-GEMM formulation, not measurements.</p>
<p>I am revising the code and will report updated results in a follow-up post.</p>
</blockquote>
<p><strong>[TL;DR] Can Kolmogorov-Arnold Network layers be written as dense matrix multiplications instead of branching spline evaluations?</strong></p>
<p><em>Note for ML Engineers: While this project tackles Quantum Chemistry, you don't need a PhD in physics to read this. The core of this article is a deep dive into JAX software architecture—specifically, how to refactor branching algorithms into GEMMs, and how to inject physical constraints (Inductive Biases) into neural networks.</em></p>
<p>In this project, I built Physics-Designed KAN (PD-KAN), a compact wavefunction for Neural Quantum Monte Carlo (Neural QMC) written in JAX. The main points are:</p>
<ul>
<li>GEMM KAN layers: Replacing B-splines with orthogonal polynomials lets the KAN layers be written with jnp.einsum as dense matrix multiplications, which should suit accelerators built for GEMMs such as TPUs (tested on GPU only).</li>
<li>Compact ansatz: For H2, the model uses 1,328 parameters, compared with 437,200 in the default FermiNet configuration. Its energy is currently ~0.01 Hartree above FermiNet's.</li>
<li>AI-assisted development: I built this as a solo project with Gemini as a coding partner.</li>
</ul>
<blockquote>
<p>💻 <strong>Code Availability</strong>: The complete JAX implementation, including <code>environment.yml</code> and <code>Apptainer.def</code> for easy replication, is open-sourced on GitHub: <a href="https://github.com/Samu-Physicist/FermiKAN"><strong>Samu-Physicist/FermiKAN</strong></a></p>
</blockquote>
<img src="https://cdn.hashnode.com/uploads/covers/6aa9365b77f820e1cd9d2e8c/afd5c2b9-4ad0-424a-abc0-cd0679678c1c.png" alt="" style="display:block;margin:0 auto" />

<p>How does it work? Section 1 notes a design choice I have since withdrawn. Section 2 describes the dense-GEMM formulation, and Sections 3–4 show how it fits into a Neural QMC wavefunction and what the results were.</p>
<hr />
<h2>1. Earlier Design Note (Withdrawn)</h2>
<p>An earlier version of this post proposed mapping coordinates to a 4D unit vector, q = (x, y, z, ε)/√(r² + ε²), to avoid a singularity at the origin and to keep polynomial features bounded. This turned out to be unnecessary. Real solid harmonics r^l Y_lm are polynomials in x, y, z, so they have no singularity at the origin, and the exponential envelope of each orbital keeps them bounded at large r. The mapping also mixed radial dependence into the angular features, and the Cartesian monomials let s-type components leak into the d shells. The revised code uses real solid harmonics instead.</p>
<hr />
<h2>2. KAN Layers with Orthogonal Polynomials</h2>
<p>The Kolmogorov-Arnold Network (KAN) learns adaptive non-linear functions on its edges. However, the original KAN relies on B-splines.</p>
<p>From a hardware perspective, B-splines are less suited to Tensor Processing Units (TPUs). TPUs are built around systolic arrays designed for massive, dense matrix multiplications (GEMMs). B-splines require conditional branching and localized basis evaluations, which fragment memory access and can reduce hardware utilization.</p>
<p>To unlock hardware acceleration, I replace B-splines with <strong>Orthogonal Polynomials</strong> (such as Chebyshev or Legendre polynomials). Because orthogonal polynomials can be generated using simple recurrence relations, I can implement the entire KAN forward pass as a sequence of dense tensor contractions. By leveraging JAX's <code>jnp.einsum</code> for batched matrix multiplications, I transform the KAN from a branching-heavy algorithm into a GEMM operation.</p>
<pre><code class="language-python">        # m_q is (..., N_atoms, N_mono), W is (N_atoms, N_MOs, N_mono)
        # Contract over N_mono to get (..., N_atoms, N_MOs)
        val = jnp.einsum('...am, aom -&gt; ...ao', m_q, W)
        shell_angular_vals.append(val)
</code></pre>
<h2>3. The Stress Test: Standing on the Shoulders of FermiNet</h2>
<p>To test this formulation on a demanding problem, I applied it to solving the Schrödinger equation with Neural QMC.</p>
<p>I did not build this from scratch. I integrated my architecture as an extension module into <strong>FermiNet</strong>, DeepMind's pioneering Neural QMC framework. FermiNet's infrastructure let me focus on the orbital architecture instead of the full VMC pipeline.</p>
<h3>The Physics-Designed KAN (PD-KAN)</h3>
<p>The core strength of the Kolmogorov-Arnold Network (KAN) lies in its ability to learn non-linear functions on edges via a <em>Basis Expansion</em>. Typically, generic B-splines are used for this expansion. However, I injected a physical <strong>Inductive Bias</strong> into this mechanism.</p>
<p>Instead of generic splines, I adopted a Learnable Physical Basis (Adaptive LCAO) for the KAN edges. Unlike classical static orbitals, these basis functions are parameterized; both the LCAO coefficients and the underlying orbital shapes are dynamically optimized end-to-end via JAX's Autograd. Mathematically, it takes this form:</p>
<img src="https://cdn.hashnode.com/uploads/covers/6aa9365b77f820e1cd9d2e8c/b96a33a1-8372-4f36-b9c7-81fb27aec457.png" alt="Orbital expansion: sum over atoms and shells of LCAO coefficients times radial, angular, and envelope terms" style="display:block;margin:0 auto" />

<p>In the realm of quantum chemistry, this is known as Linear Combination of Atomic Orbitals (LCAO)—a classical and incredibly powerful technique. But translated into the context of modern Machine Learning, it is exactly this: <strong>a KAN equipped with a Physics-Informed custom basis.</strong></p>
<p>My core contribution to this ecosystem is the <strong>Physics-Designed KAN (PD-KAN)</strong>. Neural QMC models often start with a pretraining stage, such as fitting Hartree-Fock orbitals. PD-KAN instead starts from a physics-based initialization:</p>
<ol>
<li><strong>Physics-Informed Parametric Residuals (Radial):</strong> To preserve the electron-nucleus cusp condition and numerical stability, the radial component is initialized with analytical solutions (Laguerre polynomials). The KAN is tasked with learning only the <em>parameter residual</em>—the dynamic shift in the effective nuclear charge.</li>
<li><strong>Unconstrained Hybridization (Angular):</strong> While the radial component uses physical priors, the angular component starts from a neutral state (\(W=0\)). I do <em>not</em> hardcode spherical harmonics. Instead, the network is given raw Cartesian monomials and must learn to assemble the optimal polarized orbitals (e.g., \(p_z\)) and chemical hybridization through gradient descent. (In the revised code, the Cartesian monomials are replaced by real solid harmonics. Hybridization is still learned, through the mixing coefficients across shells.)</li>
</ol>
<p>Within the FermiNet infrastructure, PD-KAN uses a physics-based initialization based on Slater's rules instead of pretraining. The network starts with a physically safe state (isolated atom) at Step 0, while retaining the architectural flexibility to learn optimal spatial symmetries dynamically.</p>
<p><strong>Putting It All Together: The PD-KAN Forward Pass</strong> To visualize how these hybrid mechanics operate in practice, here is the step-by-step data flow of the architecture:</p>
<p><strong>Dynamic Coordinate Shift (Vector Backflow)</strong></p>
<ul>
<li>Raw electron/nuclei coordinates are fed into a Backflow-KAN to learn electron correlations, generating a dynamic shift \(\eta_i\).</li>
</ul>
<img src="https://cdn.hashnode.com/uploads/covers/6aa9365b77f820e1cd9d2e8c/33473f68-669b-447d-9e2b-522a4f921f8a.png" alt="" style="display:block;margin:0 auto" />

<ol>
<li><p><strong>Physical Basis Evaluation (PD-KAN)</strong></p>
<ul>
<li><strong>Radial</strong>: The scalar distance feeds into a Chebyshev KAN (handling static morphing and dynamic breathing), which outputs a dynamic parameter \(\xi\). This parameter controls the exponential decay of Analytical Laguerre Polynomials, designed to satisfy the electron-nucleus cusp for each atom (see the update note for molecules).</li>
<li><strong>Angular</strong>: The shifted electron-nucleus vectors feed into an Angular KAN.</li>
</ul>
<img src="https://cdn.hashnode.com/uploads/covers/6aa9365b77f820e1cd9d2e8c/e2b4adaf-b9ea-43e9-be17-7970a646d1cc.png" alt="" style="display:block;margin:0 auto" /></li>
<li><p><strong>LCAO Orbital Construction</strong></p>
<ul>
<li>Radial and Angular outputs are combined and multiplied by LCAO coefficients.</li>
<li>Summing over all atoms and physical shells yields the generalized 1-Electron Orbital.</li>
</ul>
<img src="https://cdn.hashnode.com/uploads/covers/6aa9365b77f820e1cd9d2e8c/929fc7fb-71fc-4b52-87b1-d50551542ca2.png" alt="" style="display:block;margin:0 auto" /></li>
<li><p><strong>Slater-Jastrow Wavefunction</strong></p>
<ul>
<li>The orbitals are passed through a Slater Determinant (guaranteeing physical antisymmetry).</li>
<li>Following the PauliNet architecture, the determinant is explicitly multiplied by a Jastrow factor (enforcing electron-electron cusps separately for parallel and anti-parallel spins) to produce the final continuous wavefunction.</li>
</ul>
<img src="https://cdn.hashnode.com/uploads/covers/6aa9365b77f820e1cd9d2e8c/0be31271-4ce9-4fab-b61c-685d8b71f948.png" alt="" style="display:block;margin:0 auto" /></li>
</ol>
<hr />
<h2>4. Results</h2>
<p>A note on the optimizer: I originally intended to run this on top of FermiNet using its well-known K-FAC optimizer. However, I encountered a severe "dependency hell" between the older JAX/XLA versions required by the official FermiNet repository and the cutting-edge JAX ecosystem utilized in this project. Due to these version incompatibilities, maintaining the intricate K-FAC hooks became insurmountable for a solo researcher, and I was forced to fall back to the standard, much lighter Adam optimizer.</p>
<p><strong>1. The Scale: 330x Parameter Compression</strong></p>
<p>The default FermiNet configuration uses 437,200 parameters for H2, while PD-KAN uses 1,328 (about 330x fewer). Note that the default FermiNet configuration is much larger than H2 requires.</p>
<p><strong>2. The Speed: Per-Iteration Wall-Time</strong></p>
<img src="https://cdn.hashnode.com/uploads/covers/6aa9365b77f820e1cd9d2e8c/6648d97e-8327-457a-a01b-f9bf6e978b30.png" alt="" style="display:block;margin:0 auto" />

<p>Both models were run for 2,000 iterations on the same GPU with a batch of 16,384 walkers. The total wall-time was 687.07 seconds for FermiNet and 115.87 seconds for PD-KAN, about 6x faster per iteration. However, FermiNet converged in about 500 iterations, while PD-KAN needed about 2,000. Measured as time to convergence, PD-KAN was about 1.5x faster (roughly 116 seconds versus 172 seconds).</p>
<p><strong>3. Convergence and Accuracy</strong></p>
<img src="https://cdn.hashnode.com/uploads/covers/6aa9365b77f820e1cd9d2e8c/218a76bf-cb5c-4ae3-891c-1d4d7c593d29.png" alt="" style="display:block;margin:0 auto" />

<p>PD-KAN's energy is about 0.01 Hartree above FermiNet's. The cause of this gap is under investigation, including the cusp issue noted in the update. With Adam used for both models, PD-KAN also needed about 4x more iterations to converge.</p>
<hr />
<h2>5. Honest Scaling Limit &amp; Call for Collaborators</h2>
<p>I would like to be transparent about the current engineering limits of this proof-of-concept.</p>
<p>As an R&amp;D researcher at a traditional chemical manufacturer (where compute budgets are far from infinite), I have made heavy use of the standard capabilities of JAX (<code>vmap</code>, <code>lax.scan</code>). However, scaling this architecture to larger molecules (e.g., benzene) or to excited states will require more compute. Most notably, a second-order optimizer such as K-FAC or Stochastic Reconfiguration is likely needed.</p>
<p>Beyond purely computational limits, PD-KAN also presents a fundamental theoretical limitation. As an explicitly constructed "Glass Box," it cannot magically learn physical constraints that I haven't built into its structure. For example, the current FermiKAN architecture assumes only standard electron-electron and electron-nucleus cusp conditions. If one were to introduce exotic particles like positrons, my analytical compoents would fail. Therefore, expanding this framework (e.g., to handle strong external magnetic fields or non-adiabatic nuclear dynamics) requires rigorous theoretical review and collaboration with domain experts in physics.</p>
<p>If you are passionate about crossing disciplinary boundaries to push the limits of AI and physics, I am actively looking for collaborators.</p>
<hr />
<h2>Code Availability</h2>
<p>The complete codebase for PD-KAN (FermiKAN), including the JAX optimization loops, LCAO basis implementations, and full reproducibility environments (<code>environment.yml</code>, <code>Apptainer.def</code>), is available on GitHub: 🔗 <a href="https://github.com/Samu-Physicist/FermiKAN"><strong>https://github.com/Samu-Physicist/FermiKAN</strong></a></p>
<h2>6. Acknowledgements / Prior Work</h2>
<p>This project is heavily inspired by and builds upon the foundational Neural QMC architectures: FermiNet by Google DeepMind (Pfau et al., 2020) and PauliNet (Hermann et al., 2020). While FermiNet beautifully demonstrated the power of deep learning in ab-initio quantum chemistry, PD-KAN introduces another approach by incorporating LCAO into the base functions of Kolmogorov-Arnold Networks (KANs), combined with PauliNet's explicit Jastrow formulation. I deeply respect the original FermiNet and PauliNet teams, as well as the KAN authors (Ziming Liu et al., 2024), for their groundbreaking contributions and for paving the way in AI for Science.</p>
<h2>Citing this work</h2>
<p>If you found this architecture or the provided codebase useful for your own research, please consider citing the project via its DOI:</p>
<blockquote>
<p>Takamatsu, T. (2026). <em>FermiKAN: Physics-Designed Kolmogorov-Arnold Networks for Neural QMC</em> [Software]. Zenodo. <a href="https://doi.org/10.5281/zenodo.21849868">https://doi.org/10.5281/zenodo.21849868</a></p>
</blockquote>
<h2>References</h2>
<ol>
<li>Pfau, D., Spencer, J. S., Matthews, A. G. D. G., &amp; Foulkes, W. M. C. (2020). Ab initio solution of the many-electron Schrödinger equation with deep neural networks. <em>Physical Review Research</em>, 2(3), 033429.</li>
<li>Liu, Z., Wang, Y., Vaidya, S., Ruehle, F., Halverson, J., Soljačić, M., ... &amp; Tegmark, M. (2024). KAN: Kolmogorov-Arnold Networks. <em>arXiv preprint arXiv:2404.19756</em>.</li>
<li>Kato, T. (1957). On the eigenfunctions of many-particle systems in quantum mechanics. <em>Communications on Pure and Applied Mathematics</em>, 10(2), 151-177.</li>
<li>Hermann, J., Schätzle, Z., &amp; Noé, F. (2020). Deep-neural-network solution of the electronic Schrödinger equation. <em>Nature Chemistry</em>, 12(10), 891-897.</li>
</ol>
]]></content:encoded></item></channel></rss>