[Paper Review] ModelingToolkit: A Composable Graph Transformation System For Equation-Based Modeling
ModelingToolkit (MTK) is a composable, Julia-based symbolic modeling system that applies graph-based transformations—such as index reduction, parallelization, and machine learning-driven model order reduction—directly to users' numerical code, automatically improving stability, performance, and efficiency. It accelerates an HVAC model by 590× with 3% error compared to Dymola, demonstrating end-to-end automation of model optimization within a high-level, extensible framework.
Getting good performance out of numerical equation solvers requires that the user has provided stable and efficient functions representing their model. However, users should not be trusted to write good code. In this manuscript we describe ModelingToolkit (MTK), a symbolic equation-based modeling system which allows for composable transformations to generate stable, efficient, and parallelized model implementations. MTK blurs the lines of traditional symbolic computing by acting directly on a user's numerical code. We show the ability to apply graph algorithms for automatically parallelizing and performing index reduction on code written for differential-algebraic equation (DAE) solvers, "fixing" the performance and stability of the model without requiring any changes to on the user's part. We demonstrate how composable model transformations can be combined with automated data-driven surrogate generation techniques, allowing machine learning methods to generate accelerated approximate models within an acausal modeling framework. These reduced models are shown to outperform the Dymola Modelica compiler on an HVAC model by 590x at 3\% error. Together, this demonstrates MTK as a system for bringing the latest research in graph transformations directly to modeling applications.
Motivation & Objective
- To address the performance and stability issues in equation-based modeling caused by suboptimal user-written code for DAE solvers.
- To eliminate the need for users to manually write efficient, stable, or parallel code by automating code transformations.
- To integrate symbolic computation directly into a high-performance programming language (Julia) for seamless, composable model transformations.
- To enable automated, data-driven surrogate modeling within an acausal modeling framework for accelerated simulation.
- To create an open, extensible system that allows researchers to plug in new symbolic and graph-based optimization passes.
Proposed method
- MTK uses Symbolics.jl, a Julia-based Computer Algebra System (CAS), to represent models as symbolic expressions that preserve Julia semantics.
- It applies graph algorithms—such as strongly connected component (SCC) analysis—to detect parallelizable equation groups and enable automatic parallelism.
- Index reduction is performed symbolically on DAEs using Pantelides-like algorithms, transforming high-index DAEs into index-1 form without user intervention.
- Nonlinear tearing and singularity elimination are applied to decouple systems and improve solver convergence.
- Machine learning-based surrogate models are generated automatically via the `surrogatize` function, replacing complex submodels with fast, approximate equivalents.
- Transformations are composable: multiple passes (e.g., index reduction, parallelization, surrogate generation) can be applied in sequence to the same model.
Experimental results
Research questions
- RQ1Can symbolic graph transformations be applied directly to user-written numerical code to improve solver performance and stability without code changes?
- RQ2How effective is automated index reduction via graph algorithms in stabilizing and accelerating DAE solvers?
- RQ3To what extent can automatic parallelization of equations be achieved using SCC decomposition in equation-based models?
- RQ4Can data-driven surrogate models be automatically generated and integrated into acausal modeling frameworks to accelerate simulation?
- RQ5How does the composable transformation pipeline in MTK compare to commercial tools like Dymola in real-world performance benchmarks?
Key findings
- MTK reduced simulation time for an HVAC model by 590× compared to Dymola, achieving a 3% error rate using machine learning-generated surrogates.
- The system achieved a 5.8-second simulation time for the same HVAC model, outperforming Dymola’s 35.3-second runtime.
- Index reduction was automatically applied to user-written code, transforming high-index DAEs into index-1 form without requiring manual reformulation.
- Automatic parallelization was enabled through SCC detection, allowing independent equation groups to be solved in parallel.
- The `surrogatize` function successfully replaced high-fidelity submodels with fast, approximate surrogates, preserving model structure and enabling reuse in larger systems.
- MTK enables end-to-end automation of model optimization, including symbolic analysis, structural simplification, and surrogate generation, all within a single, composable framework.
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.