# A Neural Network-Inspired Matrix Formulation of Chemical Kinetics for Acceleration on GPUs
## Appendix A Substitution with Approximate Artificial Neural Networks  
In Section 2.1, the matrix based formulations of the kinetics routines are exact and perform at high efficiency on GPUs as they stand. The ANN interpretations of these exact formulations, however, illuminate pathways where additional computational efficiency can be extracted by utilizing so-called \"approximate ANNs\" as drop-in replacements for the \"exact ANN\" architectures described in Figure 1. At the cost of perfect accuracy, such replacements allow for direct control over computational cost through a customized ANN architecture whose parameters are trained with data. The end goal is that the execution time of the approximate ANN should be faster than the exact ANN counterparts (to clarify, \"exact ANN\" here refers to the exact matrix-based formulations of Section 2.1). Many pathways to this end are available. For the sake of demonstrating how this technique can be applied, the replacement of the exact ANN for the logarithm of the equilibrium rate constant (Figure 1c) with an approximate ANN counterpart is explored. In other words, in this demonstration, the modeling goal of the approximate ANN is to recover accurate representations of \(\log(\mathbf{K}_{c})\) and not the species production rates \(\mathbf{\Omega}\) directly. Narrowing the approximate ANN scope to \(\log(\mathbf{K}_{c})\) brings forward two key advantages. The first is that the equilibrium rate constants do not depend on the species concentrations, but rather only on nonlinear functions of temperature. This means that the sampling of an \(N_{\text{S}}\)-dimensional phase space to develop a training dataset--a huge bottleneck in many existing ANN-based source term modeling techniques that becomes prohibitive for large mechanisms--is not required in the training phase. The second advantage is that known physical constraints to recover the source terms, such as the relationship between concentrations and net reaction rate (Equation (4)), as well as Arrhenius forms for the forward rate (Equation (6)), are preserved in the overall computation, ensuring high accuracy and physical consistency. Additionally, the exact ANN architecture for \(\log(\mathbf{K}_{c})\) (shown in Figure 1c) is complex enough to warrant a reduction based on an approximate ANN--there is more than one layer in the exact form, which is not the case for the forward rate constant architecture. This is crucial because the design of the approximate ANN must be driven by reducing computational effort. In other words, the exact ANN form should serve as an upper bound for the computational complexity (in terms of a cost metric such as FLOPs, for example) of the approximate ANN. In general, an ANN layer takes the following form:  
\[\mathbf{X}_{l+1}=\sigma_{l}(\mathbf{X}_{l}\mathbf{W}_{l}+B_{l}),\quad l=0, \ldots,N_{L}, \tag{1}\]  
where \(\mathbf{X}_{l}\) is the layer input, \(\mathbf{X}_{l+1}\) is the layer output, \(\mathbf{W}_{l}\) is the weight matrix, \(B_{l}\) is the bias vector, \(\sigma\) is an activation function, and \(N_{L}\) is the total number of hidden layers. Note that, unlike in Section 2.1, the parameters (weights/biases) are assumed unknown in this setting and are found through a training procedure. As with the exact formulations, the leading dimension (batch size) for these input and output matrices is \(N_{C}\). For a given \(N_{L}\), the hidden layer dimension \(N_{H}\) (or number of neurons per hidden layer) is assumed to be fixed for the sake of this walk-through, but this does not have to be the case in general. The ANN input is \(\mathbf{X}_{0}\in\mathbb{R}^{N_{C}\times N_{in}}\) and the output is \(\mathbf{X}_{N_{L}+1}\in\mathbb{R}^{N_{C}\times N_{R}}=\log(\widetilde{\mathbf{ K}}_{c})\). The main task is to train the ANN such that \(\log(\widetilde{\mathbf{K}}_{c})\approx\log(\mathbf{K}_{c})\).