<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: martial wato</title>
    <description>The latest articles on DEV Community by martial wato (@rustspeak).</description>
    <link>https://dev.to/rustspeak</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4278603%2F2ff786b8-2c8f-4c80-b754-e13d4f4349dd.jpg</url>
      <title>DEV Community: martial wato</title>
      <link>https://dev.to/rustspeak</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/rustspeak"/>
    <language>en</language>
    <item>
      <title>Why I Replaced PyTorch with Burn in NEURAX.</title>
      <dc:creator>martial wato</dc:creator>
      <pubDate>Wed, 02 Dec 2026 14:45:05 +0000</pubDate>
      <link>https://dev.to/rustspeak/why-i-replaced-pytorch-with-burn-in-neurax-3abh</link>
      <guid>https://dev.to/rustspeak/why-i-replaced-pytorch-with-burn-in-neurax-3abh</guid>
      <description>&lt;p&gt;When building a deep learning application, choosing a framework is not only about training performance. It is also about software architecture, distribution, memory management, hardware compatibility, and the ability to control and optimize the execution infrastructure.&lt;/p&gt;

&lt;p&gt;During the early development of NEURAX, I used Python and PyTorch as the foundation of its training engine.&lt;/p&gt;

&lt;p&gt;However, as the Studio evolved, several limitations became apparent: heavy dependencies, complex integration with Rust, additional installation requirements, and difficulties implementing fine-grained optimizations.&lt;/p&gt;

&lt;p&gt;These challenges led me to replace PyTorch with Burn.&lt;/p&gt;

&lt;p&gt;This article explains the technical reasoning behind that decision.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Understanding How a Deep Learning Framework Works
&lt;/h2&gt;

&lt;p&gt;A neural network is fundamentally a composition of mathematical operations and trainable parameters.&lt;/p&gt;

&lt;p&gt;A deep learning framework provides the infrastructure that transforms these mathematical operations into computations executable on physical hardware.&lt;/p&gt;

&lt;p&gt;Consider a simple operation:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;y&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;torch&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;relu&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;x&lt;/span&gt; @ &lt;span class="n"&gt;w&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Behind this expression lies an entire computational infrastructure.&lt;br&gt;
&lt;/p&gt;

&lt;pre data-lang="mermaid"&gt;&lt;code&gt;flowchart TD
    A["Neural Architecture"] --&amp;gt; B["Tensor Engine"]
    B --&amp;gt; C["Backend and Optimization"]
    C --&amp;gt; D["Compute Kernels"]
    D --&amp;gt; E["CPU / GPU"]

    B -.-&amp;gt; F["Automatic Differentiation"]
    F --&amp;gt; G["Gradients"]
    G --&amp;gt; H["Optimizer"]
    H --&amp;gt; I["Updated Parameters"]
    I --&amp;gt; B

    classDef core fill:#F8FAFC,stroke:#64748B,color:#0F172A
    classDef compute fill:#FFF7ED,stroke:#EA580C,color:#7C2D12
    classDef train fill:#ECFDF5,stroke:#059669,color:#064E3B

    class A,B,C core
    class D,E compute
    class F,G,H,I train&lt;/code&gt;&lt;/pre&gt;



&lt;p&gt;&lt;em&gt;Figure 1 — Conceptual responsibilities of a deep learning framework.&lt;/em&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Tensor representation
&lt;/h3&gt;

&lt;p&gt;Tensors are the fundamental computational units of deep learning. Inputs, weights, activations, and gradients are represented through tensor abstractions.&lt;/p&gt;

&lt;p&gt;A tensor generally associates numerical data with several properties:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Property&lt;/th&gt;
&lt;th&gt;Responsibility&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Shape&lt;/td&gt;
&lt;td&gt;Tensor dimensions&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Dtype&lt;/td&gt;
&lt;td&gt;Numerical representation&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Layout&lt;/td&gt;
&lt;td&gt;Memory organization&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Strides&lt;/td&gt;
&lt;td&gt;Memory offsets&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Storage&lt;/td&gt;
&lt;td&gt;Underlying data allocation&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Device&lt;/td&gt;
&lt;td&gt;Hardware where the data resides&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;These properties influence computational efficiency. Two tensors containing identical values can exhibit different performance characteristics depending on their memory organization and access patterns.&lt;/p&gt;

&lt;h3&gt;
  
  
  Automatic differentiation
&lt;/h3&gt;

&lt;p&gt;Training a neural network requires determining how its parameters influence a loss function.&lt;/p&gt;

&lt;p&gt;Consider:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;y = wx + b
L = (y - target)²
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The gradient with respect to the weight is:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;∂L/∂w = 2(y - target)x
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Rather than calculating every derivative manually, deep learning frameworks use automatic differentiation.&lt;/p&gt;

&lt;p&gt;During the forward pass, the framework records the information required for differentiation. During the backward pass, it propagates gradients through computational dependencies using the chain rule.&lt;/p&gt;

&lt;p&gt;An optimizer subsequently uses these gradients to update the parameters.&lt;/p&gt;

&lt;h3&gt;
  
  
  Backends and computational kernels
&lt;/h3&gt;

&lt;p&gt;The same mathematical operation can have different implementations depending on the target hardware.&lt;/p&gt;

&lt;p&gt;CPUs exploit vectorized instructions, caches, and multithreading. GPUs exploit large-scale parallelism, specialized memory hierarchies, and computational units.&lt;/p&gt;

&lt;p&gt;Backends abstract these implementation differences, while computational kernels perform the numerical operations.&lt;/p&gt;

&lt;p&gt;A deep learning framework therefore combines numerical mathematics, automatic differentiation, memory management, compiler engineering, and high-performance computing.&lt;/p&gt;

&lt;h2&gt;
  
  
  2. The Vision Behind NEURAX
&lt;/h2&gt;

&lt;p&gt;NEURAX is a local-first neural engineering studio designed primarily for companies and universities.&lt;/p&gt;

&lt;p&gt;My objective is to enable organizations to design their own neural architectures, train models using their own datasets and hardware, retain ownership of their weights, and progressively improve their models using errors collected in production.&lt;/p&gt;

&lt;p&gt;Not every problem requires a general-purpose model containing billions of parameters.&lt;/p&gt;

&lt;p&gt;For example, a company developing a classifier for its internal operational data may be better served by a small, specialized neural network.&lt;/p&gt;

&lt;p&gt;The model should be proportional to the problem. The execution infrastructure should also be proportional to the model.&lt;/p&gt;

&lt;p&gt;This philosophy imposes several engineering requirements on NEURAX:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Flexible construction of custom neural architectures.&lt;/li&gt;
&lt;li&gt;Lightweight local software distribution.&lt;/li&gt;
&lt;li&gt;Efficient execution on resource-constrained hardware.&lt;/li&gt;
&lt;li&gt;Strong software contracts and memory safety.&lt;/li&gt;
&lt;li&gt;Fine-grained computational optimization.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The deep learning framework must serve these requirements.&lt;/p&gt;

&lt;h2&gt;
  
  
  3. From Heavy Dependencies to Native Distribution
&lt;/h2&gt;

&lt;p&gt;PyTorch was initially a natural choice because of its mature ecosystem, extensive operator coverage, and powerful computational infrastructure.&lt;/p&gt;

&lt;p&gt;However, using a framework in a research environment and integrating it into a standalone desktop application are different engineering problems.&lt;/p&gt;

&lt;p&gt;In the early versions of NEURAX, the user had to install the Studio and then click an additional installation button to download more than 500 MB of dependencies associated with our Python and PyTorch environment.&lt;/p&gt;

&lt;p&gt;For a local-first application, this introduced unnecessary friction.&lt;/p&gt;

&lt;p&gt;I wanted users to install a complete neural engineering studio, rather than configure a separate deep learning environment.&lt;br&gt;
&lt;/p&gt;

&lt;pre data-lang="mermaid"&gt;&lt;code&gt;flowchart TB
    subgraph OLD["Before: Python and PyTorch"]
        A["Install NEURAX"] --&amp;gt; B["Install Framework Dependencies"]
        B --&amp;gt; C["500+ MB Additional Download"]
        C --&amp;gt; D["Training Engine Available"]
    end

    subgraph NEW["After: Burn"]
        E["Install NEURAX"] --&amp;gt; F["Integrated Burn Engine"]
        F --&amp;gt; G["Training Engine Available"]
    end

    classDef old fill:#FFF1ED,stroke:#EE4C2C,color:#7C2D12
    classDef native fill:#ECFDF5,stroke:#059669,color:#064E3B

    class B,C old
    class F,G native&lt;/code&gt;&lt;/pre&gt;



&lt;p&gt;&lt;em&gt;Figure 2 — The evolution of NEURAX's installation process.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;With Burn, the framework is sufficiently lightweight in our selected configuration to be distributed directly with the Studio.&lt;/p&gt;

&lt;p&gt;Users no longer need to install separate Python and PyTorch packages after installing NEURAX.&lt;/p&gt;

&lt;p&gt;Rust's compilation and dependency management infrastructure also allows us to select the framework features and backends required by the application.&lt;/p&gt;

&lt;p&gt;Hardware drivers and backend-specific system requirements still apply.&lt;/p&gt;

&lt;p&gt;The important difference is that the deep learning engine becomes an integrated component of the product.&lt;/p&gt;

&lt;h2&gt;
  
  
  4. PyTorch vs. Burn: Architectural Integration
&lt;/h2&gt;

&lt;p&gt;It would be incorrect to describe PyTorch as slow simply because its primary programming interface uses Python.&lt;/p&gt;

&lt;p&gt;PyTorch relies extensively on native C++ implementations and optimized computational kernels. Its ATen library provides tensor operations, while its dispatcher selects appropriate implementations.&lt;/p&gt;

&lt;p&gt;PyTorch also provides advanced compilation capabilities through technologies such as TorchDynamo, AOTAutograd, and TorchInductor.&lt;/p&gt;

&lt;p&gt;Burn approaches deep learning from a Rust-native perspective.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Responsibility&lt;/th&gt;
&lt;th&gt;PyTorch&lt;/th&gt;
&lt;th&gt;Burn&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Primary API&lt;/td&gt;
&lt;td&gt;Python / C++&lt;/td&gt;
&lt;td&gt;Rust&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Tensor infrastructure&lt;/td&gt;
&lt;td&gt;ATen&lt;/td&gt;
&lt;td&gt;Burn Tensor&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Operation selection&lt;/td&gt;
&lt;td&gt;Dispatcher&lt;/td&gt;
&lt;td&gt;Backend abstractions&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Differentiation&lt;/td&gt;
&lt;td&gt;Autograd&lt;/td&gt;
&lt;td&gt;Autodiff&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Computational optimization&lt;/td&gt;
&lt;td&gt;TorchInductor, among others&lt;/td&gt;
&lt;td&gt;Fusion and backend optimizations&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Custom kernels&lt;/td&gt;
&lt;td&gt;C++, CUDA, Triton&lt;/td&gt;
&lt;td&gt;CubeCL and other implementations&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;These components are not necessarily direct equivalents. They represent different approaches to similar computational responsibilities.&lt;/p&gt;

&lt;p&gt;The main advantage of Burn for NEURAX is architectural coherence.&lt;/p&gt;

&lt;p&gt;The Studio, scientific compiler, data services, and agentic system are developed around Rust. Maintaining a separate Python training environment introduced additional integration complexity.&lt;br&gt;
&lt;/p&gt;

&lt;pre data-lang="mermaid"&gt;&lt;code&gt;flowchart TD
    A["NEURAX Studio"] --&amp;gt; B["Custom Neural Graph"]
    B --&amp;gt; C["Scientific Compiler"]
    C --&amp;gt; D["Executable Model"]
    D --&amp;gt; E["Burn Training Engine"]
    E --&amp;gt; F["Compatible Compute Backend"]
    F --&amp;gt; G["CPU"]
    F --&amp;gt; H["GPU"]

    classDef studio fill:#F8FAFC,stroke:#64748B,color:#0F172A
    classDef engine fill:#FFF7ED,stroke:#EA580C,color:#7C2D12
    classDef hardware fill:#ECFDF5,stroke:#059669,color:#064E3B

    class A,B,C,D studio
    class E,F engine
    class G,H hardware&lt;/code&gt;&lt;/pre&gt;



&lt;p&gt;&lt;em&gt;Figure 3 — Simplified execution architecture of NEURAX.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Burn allows the training engine to evolve within the same technological ecosystem as the rest of the Studio.&lt;/p&gt;

&lt;p&gt;This simplifies shared software contracts, dependency management, error handling, and the integration of computational optimizations.&lt;/p&gt;

&lt;p&gt;PyTorch also provides a native C++ frontend that does not require Python. However, Burn aligns more directly with the existing Rust architecture of NEURAX.&lt;/p&gt;

&lt;h2&gt;
  
  
  5. Strong Typing and Safety for Custom Models
&lt;/h2&gt;

&lt;p&gt;NEURAX introduces a particular engineering challenge: users can construct architectures that were not predefined by the developers of the Studio.&lt;/p&gt;

&lt;p&gt;This flexibility requires rigorous validation of computational graphs, tensor dimensions, and operator compatibility.&lt;/p&gt;

&lt;p&gt;Consider a typical PyTorch function:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="n"&gt;torch&lt;/span&gt;

&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;add&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;torch&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Tensor&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;torch&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Tensor&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;torch&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Tensor&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This signature does not statically constrain the rank of the input tensors.&lt;/p&gt;

&lt;p&gt;Using the Burn 0.19.x API, a similar function can be expressed as:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight rust"&gt;&lt;code&gt;&lt;span class="k"&gt;use&lt;/span&gt; &lt;span class="n"&gt;burn&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;tensor&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;backend&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nc"&gt;Backend&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;Tensor&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;fn&lt;/span&gt; &lt;span class="nf"&gt;add&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="no"&gt;B&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;Backend&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;Tensor&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="no"&gt;B&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;Tensor&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="no"&gt;B&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="nc"&gt;Tensor&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="no"&gt;B&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;a&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The tensor rank and backend are represented directly within the type.&lt;/p&gt;

&lt;p&gt;Passing a rank-three tensor would violate the static contract.&lt;/p&gt;

&lt;p&gt;However, static typing does not guarantee dimensional compatibility.&lt;/p&gt;

&lt;p&gt;For example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Tensor A: [32, 128]
Tensor B: [32, 256]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Both tensors have rank two, but their shapes are incompatible for direct element-wise addition.&lt;/p&gt;

&lt;p&gt;The scientific compiler of NEURAX must therefore validate the dynamic architecture before execution.&lt;/p&gt;

&lt;p&gt;Rust's ownership and borrowing mechanisms also prevent several categories of memory-related errors and data races in sound Safe Rust code.&lt;/p&gt;

&lt;p&gt;These mechanisms provide complementary guarantees:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Layer&lt;/th&gt;
&lt;th&gt;Responsibility&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;NEURAX compiler&lt;/td&gt;
&lt;td&gt;Mathematical and architectural validation&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Rust type system&lt;/td&gt;
&lt;td&gt;Static software contracts&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Burn runtime&lt;/td&gt;
&lt;td&gt;Numerical execution&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Hardware backend&lt;/td&gt;
&lt;td&gt;Device-specific execution&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;This approach is particularly relevant for custom neural architectures.&lt;/p&gt;

&lt;p&gt;It strengthens software reliability without imposing unnecessary restrictions on architectural flexibility.&lt;/p&gt;

&lt;p&gt;It does not, however, eliminate numerical instability, unsupported operations, or defects in native libraries and GPU kernels.&lt;/p&gt;

&lt;h2&gt;
  
  
  6. Fine-Grained Optimization with Burn
&lt;/h2&gt;

&lt;p&gt;Another major reason for replacing PyTorch was the difficulty of integrating fine-grained optimizations into our previous architecture.&lt;/p&gt;

&lt;p&gt;I needed greater control over tensor allocations, intermediate buffers, memory reuse, CPU-GPU transfers, and hardware-specific computations.&lt;/p&gt;

&lt;p&gt;PyTorch provides powerful tools for these optimizations. However, integrating them into a Rust-based application through our previous Python environment introduced additional engineering complexity.&lt;/p&gt;

&lt;p&gt;Burn provides a more coherent environment for exploring these mechanisms within Rust.&lt;/p&gt;

&lt;h3&gt;
  
  
  Kernel fusion
&lt;/h3&gt;

&lt;p&gt;Consider the expression:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Y = ReLU(A + B)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Without fusion, the addition can produce an intermediate tensor that must be written to memory and subsequently read by another kernel.&lt;/p&gt;

&lt;p&gt;With fusion, both operations can potentially execute within a single kernel.&lt;br&gt;
&lt;/p&gt;

&lt;pre data-lang="mermaid"&gt;&lt;code&gt;flowchart TB
    subgraph U["Unfused Execution"]
        A["Read A and B"] --&amp;gt; B["Addition Kernel"]
        B --&amp;gt; C["Write Intermediate Tensor"]
        C --&amp;gt; D["Read Intermediate Tensor"]
        D --&amp;gt; E["ReLU Kernel"]
        E --&amp;gt; F["Write Output"]
    end

    subgraph V["Fused Execution"]
        G["Read A and B"] --&amp;gt; H["Fused Addition + ReLU"]
        H --&amp;gt; I["Write Output"]
    end

    classDef intermediate fill:#FFF1ED,stroke:#EE4C2C,color:#7C2D12
    classDef optimized fill:#ECFDF5,stroke:#059669,color:#064E3B

    class C,D intermediate
    class H optimized&lt;/code&gt;&lt;/pre&gt;



&lt;p&gt;&lt;em&gt;Figure 4 — Eliminating intermediate memory operations.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;For N FP32 elements:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Memory operation&lt;/th&gt;
&lt;th&gt;Unfused&lt;/th&gt;
&lt;th&gt;Fused&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Read inputs&lt;/td&gt;
&lt;td&gt;8N bytes&lt;/td&gt;
&lt;td&gt;8N bytes&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Write intermediate&lt;/td&gt;
&lt;td&gt;4N bytes&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Read intermediate&lt;/td&gt;
&lt;td&gt;4N bytes&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Write output&lt;/td&gt;
&lt;td&gt;4N bytes&lt;/td&gt;
&lt;td&gt;4N bytes&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Total&lt;/td&gt;
&lt;td&gt;20N bytes&lt;/td&gt;
&lt;td&gt;12N bytes&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;For ten million elements, this represents 200 MB versus 120 MB of logical memory traffic, a theoretical reduction of 40%.&lt;/p&gt;

&lt;p&gt;This is an illustration of memory traffic reduction, not a measured execution speedup.&lt;/p&gt;

&lt;p&gt;Both PyTorch and Burn support computational fusion. The advantage for NEURAX is the ability to integrate and investigate such optimizations more directly within its native infrastructure.&lt;/p&gt;

&lt;h3&gt;
  
  
  CubeCL and hardware specialization
&lt;/h3&gt;

&lt;p&gt;CubeCL is an important component of the Burn ecosystem.&lt;/p&gt;

&lt;p&gt;It provides a Rust-based infrastructure for developing and compiling computational kernels across supported hardware platforms.&lt;/p&gt;

&lt;p&gt;Its capabilities include kernel specialization, execution runtimes, and autotuning.&lt;/p&gt;

&lt;p&gt;Autotuning evaluates alternative kernel configurations to select an efficient implementation for a particular device and workload.&lt;/p&gt;

&lt;p&gt;This matters because a configuration optimized for one GPU may not perform equally well on another.&lt;/p&gt;

&lt;p&gt;For NEURAX, the objective is not to rewrite every computational kernel. It is to retain the ability to identify actual bottlenecks and optimize the operations that matter to our users.&lt;/p&gt;

&lt;h2&gt;
  
  
  7. Native Execution on Resource-Constrained Hardware
&lt;/h2&gt;

&lt;p&gt;NEURAX is designed for organizations that may not possess large computational infrastructures.&lt;/p&gt;

&lt;p&gt;A relatively small neural model should not require a disproportionately heavy execution environment.&lt;/p&gt;

&lt;p&gt;Consider training a model containing one million trainable parameters using FP32 and Adam.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Component&lt;/th&gt;
&lt;th&gt;Approximate memory&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Weights&lt;/td&gt;
&lt;td&gt;4 MB&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Gradients&lt;/td&gt;
&lt;td&gt;4 MB&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;First Adam moment&lt;/td&gt;
&lt;td&gt;4 MB&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Second Adam moment&lt;/td&gt;
&lt;td&gt;4 MB&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Partial total&lt;/td&gt;
&lt;td&gt;16 MB&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;This excludes activations, temporary buffers, and runtime allocations.&lt;/p&gt;

&lt;p&gt;Replacing PyTorch with Burn does not automatically reduce the mathematical memory requirements of the model.&lt;/p&gt;

&lt;p&gt;However, native integration, modular backends, memory reuse, and computational optimization provide opportunities to reduce avoidable software overhead.&lt;/p&gt;

&lt;p&gt;In my experience developing NEURAX, Burn has also delivered faster execution in certain situations than our previous PyTorch integration.&lt;/p&gt;

&lt;p&gt;Application performance depends on more than kernel speed. It includes data preparation, runtime orchestration, communication, numerical computation, and synchronization.&lt;/p&gt;

&lt;p&gt;Reducing integration overhead can improve overall execution without changing the mathematical complexity of the model.&lt;/p&gt;

&lt;p&gt;For smaller machines, the objective is to preserve as many resources as possible for useful computation.&lt;/p&gt;

&lt;h2&gt;
  
  
  8. Results and Engineering Trade-offs
&lt;/h2&gt;

&lt;p&gt;The following table summarizes this migration from the perspective of NEURAX.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Criterion&lt;/th&gt;
&lt;th&gt;Previous integration&lt;/th&gt;
&lt;th&gt;Burn integration&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Additional framework download&lt;/td&gt;
&lt;td&gt;500+ MB&lt;/td&gt;
&lt;td&gt;Eliminated&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Separate Python environment&lt;/td&gt;
&lt;td&gt;Required&lt;/td&gt;
&lt;td&gt;Not required&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Rust integration&lt;/td&gt;
&lt;td&gt;Cross-language&lt;/td&gt;
&lt;td&gt;Native&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Tensor rank contracts&lt;/td&gt;
&lt;td&gt;Dynamic API&lt;/td&gt;
&lt;td&gt;Static typing&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Fine-grained optimization&lt;/td&gt;
&lt;td&gt;More complex&lt;/td&gt;
&lt;td&gt;Easier to integrate&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Execution performance&lt;/td&gt;
&lt;td&gt;Previous baseline&lt;/td&gt;
&lt;td&gt;Improvements observed in some cases&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;RAM and VRAM efficiency&lt;/td&gt;
&lt;td&gt;Requires benchmarking&lt;/td&gt;
&lt;td&gt;Requires benchmarking&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Runtime stability&lt;/td&gt;
&lt;td&gt;Requires testing&lt;/td&gt;
&lt;td&gt;Requires testing&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;A reproducible comparison must evaluate identical models, datasets, numerical precision, hardware, and training configurations.&lt;/p&gt;

&lt;p&gt;It should measure startup latency, total distribution size, training throughput, peak RAM, peak VRAM, and numerical correctness.&lt;/p&gt;

&lt;p&gt;There are also important limitations.&lt;/p&gt;

&lt;p&gt;PyTorch benefits from a more mature ecosystem, extensive operator coverage, specialized libraries, and advanced tooling.&lt;/p&gt;

&lt;p&gt;Burn is younger, and some capabilities require additional integration and validation work.&lt;/p&gt;

&lt;p&gt;As of December 2026, the native training engine of NEURAX supports approximately 16.7 million trainable parameters in single precision on one device. Executing fine-tuning on published model weights is still being completed.&lt;/p&gt;

&lt;p&gt;These are current limitations of NEURAX, not inherent parameter limits of Burn.&lt;/p&gt;

&lt;p&gt;The migration is therefore an architectural trade-off rather than a claim of universal framework superiority.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;I did not replace PyTorch simply because Burn is written in Rust.&lt;/p&gt;

&lt;p&gt;I replaced it because NEURAX requires a lightweight, flexible, strongly typed, and optimizable deep learning infrastructure that can be distributed directly with a local Studio.&lt;/p&gt;

&lt;p&gt;Burn provides a foundation that aligns with these requirements while preserving the ability to investigate and improve the computational infrastructure.&lt;/p&gt;

&lt;p&gt;The most important lesson from this migration is that choosing a deep learning framework requires looking beyond popularity and individual kernel benchmarks.&lt;/p&gt;

&lt;p&gt;The framework must fit the architecture, constraints, and objectives of the product.&lt;/p&gt;

&lt;p&gt;For NEURAX, that means building specialized neural models adapted to the needs and computational resources of their users.&lt;/p&gt;

&lt;p&gt;Rather than requiring users to adapt their infrastructure to artificial intelligence, I want to explore how we can build artificial intelligence adapted to their infrastructure.&lt;/p&gt;

&lt;h2&gt;
  
  
  Technical References
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://burn.dev/books/burn/" rel="noopener noreferrer"&gt;The Burn Book&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.rs/crate/burn/0.19.1" rel="noopener noreferrer"&gt;Burn 0.19.1&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/tracel-ai/cubecl" rel="noopener noreferrer"&gt;CubeCL&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.pytorch.org/docs/stable/notes/autograd.html" rel="noopener noreferrer"&gt;PyTorch Autograd Mechanics&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.pytorch.org/tutorials/advanced/dispatcher.html" rel="noopener noreferrer"&gt;PyTorch Dispatcher&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.pytorch.org/docs/stable/torch.compiler.html" rel="noopener noreferrer"&gt;PyTorch Compiler&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.pytorch.org/cppdocs/frontend.html" rel="noopener noreferrer"&gt;PyTorch C++ Frontend&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://doc.rust-lang.org/book/ch04-01-what-is-ownership.html" rel="noopener noreferrer"&gt;Rust Ownership&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;If you are building native machine learning infrastructure, what engineering trade-offs have you encountered when integrating deep learning frameworks into standalone applications?&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Disclosure: AI assistance was used to structure, draft, and review this article based on my engineering experience developing NEURAX.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>ai</category>
      <category>rust</category>
      <category>machinelearning</category>
      <category>deeplearning</category>
    </item>
  </channel>
</rss>
