Table of Contents
Fetching ...

Lattice Gauge Theory via LLVM-Level Automatic Differentiation

Yuki Nagai, Akio Tomiya, Hiroshi Ohno

TL;DR

This work enables the automatic construction of Hybrid Monte Carlo (HMC) forces in lattice gauge theory by performing reverse-mode automatic differentiation at the level of optimized LLVM intermediate representation, making the approach applicable to any language that lowers lattice action code to LLVM.

Abstract

We enable the automatic construction of Hybrid Monte Carlo (HMC) forces in lattice gauge theory by performing reverse-mode automatic differentiation at the level of optimized LLVM intermediate representation, making the approach applicable to any language that lowers lattice action code to LLVM. In practice, this means that once the action evaluation routine is implemented, the corresponding HMC force can be generated automatically from the same code path, without deriving or maintaining a separate force routine. The method preserves conventional imperative, in-place implementations and enables a single-source workflow in which forces are generated directly from the action code while inheriting compiler optimizations. We perform end-to-end reverse-mode differentiation of both gauge and Wilson fermion actions. For the Wilson fermion case, we find that the force generated by automatic differentiation achieves performance comparable to a conventional hand-written fermion force implementation. The same differentiation pipeline targets both CPU and GPU backends, providing a practical route to performance-portable force construction for compositional lattice actions.

Lattice Gauge Theory via LLVM-Level Automatic Differentiation

TL;DR

This work enables the automatic construction of Hybrid Monte Carlo (HMC) forces in lattice gauge theory by performing reverse-mode automatic differentiation at the level of optimized LLVM intermediate representation, making the approach applicable to any language that lowers lattice action code to LLVM.

Abstract

We enable the automatic construction of Hybrid Monte Carlo (HMC) forces in lattice gauge theory by performing reverse-mode automatic differentiation at the level of optimized LLVM intermediate representation, making the approach applicable to any language that lowers lattice action code to LLVM. In practice, this means that once the action evaluation routine is implemented, the corresponding HMC force can be generated automatically from the same code path, without deriving or maintaining a separate force routine. The method preserves conventional imperative, in-place implementations and enables a single-source workflow in which forces are generated directly from the action code while inheriting compiler optimizations. We perform end-to-end reverse-mode differentiation of both gauge and Wilson fermion actions. For the Wilson fermion case, we find that the force generated by automatic differentiation achieves performance comparable to a conventional hand-written fermion force implementation. The same differentiation pipeline targets both CPU and GPU backends, providing a practical route to performance-portable force construction for compositional lattice actions.
Paper Structure (14 sections, 50 equations, 3 figures, 1 table)

This paper contains 14 sections, 50 equations, 3 figures, 1 table.

Figures (3)

  • Figure 1: Compiler-level view of HMC force construction as the adjoint of an in-place action evaluation. In LLVM SSA form, apparent in-place updates correspond to a sequence of distinct values %Ui. Enzyme generates the reverse pass by traversing the optimized instruction sequence backward and propagating adjoints %$\bar{U}$i. The force is obtained from the adjoint associated with the initial SSA value (followed by Lie-algebra projection).
  • Figure 2: Cumulative distribution of the relative Frobenius-norm error between the molecular-dynamics force for the Wilson fermion action generated by LLVM-level automatic differentiation, $F_{\rm AD}$, and the corresponding force computed by a conventional hand-written implementation, $F_{\rm ana}$, on an $\mathop{\rm SU}(3)$$16^4$ lattice. The error is evaluated link by link over the lattice. Agreement is observed at the $10^{-9}$ level, consistent with double-precision roundoff.
  • Figure 3: Step-size dependence of HMC diagnostics using automatically generated forces for Wilson fermion simulations. The data exhibit the expected $\Delta H \propto \Delta t^2$ scaling characteristic of a second-order symplectic integrator, together with stable acceptance behavior. Blue circles denote standard Wilson fermion HMC on an $8^4$ lattice without stout smearing. Red squares correspond to simulations on a $6^4$ lattice with stout smearing ($\rho=0.3$), combined with a Sexton–Weingarten multiple time-scale integrator with 10 sub-steps.