Scaling Symbolic-Numerics in ModelingToolkit.jl to PDE Auto-Discretization via Array-Based Symbolic Code Generation and Reactant.jl Integration
Please login to view abstract download link
ModelingToolkit.jl is an open-source symbolic-numeric modeling framework within Julia's SciML ecosystem that enables acausal equation-based model specification with automated code generation for high-performance simulation. A key feature is automatic structural analysis: the system performs tearing and strongly-connected component (SCC) identification to decompose nonlinear systems, reducing the size of implicit solves required at each timestep. This yields runtime performance that often exceeds hand-written Newton methods, since humans rarely perform such detailed structural analysis manually. While these symbolic transformations provide substantial runtime benefits for ODE and DAE systems, extending them to PDEs presents scaling challenges. Naive approaches generate one symbolic variable per discretization point, causing the structural analysis algorithms and code generation to grow prohibitively with mesh refinement. We address this through array-based symbolic code generation, where symbolic arrays represent entire spatial fields and operations propagate symbolically at the array level rather than element-wise. This preserves the benefits of automatic tearing and SCC decomposition while avoiding the compile-time explosion. Integration with Reactant.jl, Julia's interface to the XLA compiler infrastructure, enables these symbolically-generated kernels to target heterogeneous hardware including GPUs and TPUs. The symbolic layer performs algebraic simplifications and structural analysis before lowering to Reactant's intermediate representation, which applies hardware-specific optimizations. From a teaching perspective, this architecture demonstrates how symbolic computation lowers barriers to high-performance PDE simulation. Students specify equations in near-mathematical notation without managing discretization, structural decomposition, or hardware-specific code. The open-source stack provides transparency into each transformation, supporting pedagogy and reproducible research. All code is available under open-source licenses through the SciML organization.
