The emergence of variational quantum applications has led to the development of automatic differentiation techniques in quantum computing. Existing work has formulated differentiable quantum programming with bounded loops, providing a framework for scalable gradient calculation by quantum means for training quantum variational applications. However, promising parameterized quantum applications, e.g., quantum walk and unitary implementation, cannot be trained in the existing framework due to the natural involvement of unbounded loops. To fill in the gap, we provide the first differentiable quantum programming framework with unbounded loops, including a newly designed differentiation rule, code transformation, and their correctness proof. Technically, we introduce a randomized estimator for derivatives to deal with the infinite sum in the differentiation of unbounded loops, whose applicability in classical and probabilistic programming is also discussed. We implement our framework with Python and Q# and demonstrate a reasonable sample efficiency. Through extensive case studies, we showcase an exciting application of our framework in automatically identifying close-to-optimal parameters for several parameterized quantum applications.
more »
« less
This content will become publicly available on April 1, 2026
Optimization using pathwise algorithmic derivatives of electromagnetic shower simulations
Among the well-known methods to approximate derivatives of expectancies computed by Monte-Carlo simulations, averages of pathwise derivatives are often the easiest one to apply. Computing them via algorithmic differentiation typically does not require major manual analysis and rewriting of the code, even for very complex programs like simulations of particle-detector interactions in high-energy physics. However, the pathwise derivative estimator can be biased if there are discontinuities in the program, which may diminish its value for applications. This work integrates algorithmic differentiation into the electromagnetic shower simulation code HepEmShow based on G4HepEm, allowing us to study how well pathwise derivatives approximate derivatives of energy depositions in a sampling calorimeter with respect to parameters of the beam and geometry. We found that when multiple scattering is disabled in the simulation, means of pathwise derivatives converge quickly to their expected values, and these are close to the actual derivatives of the energy deposition. Additionally, we demonstrate the applicability of this novel gradient estimator for stochastic gradient-based optimization in a model example.
more »
« less
- Award ID(s):
- 2311471
- PAR ID:
- 10639330
- Publisher / Repository:
- Elsevier B.V.
- Date Published:
- Journal Name:
- Computer physics communications
- Volume:
- 309
- ISSN:
- 0010-4655
- Page Range / eLocation ID:
- 109491
- Subject(s) / Keyword(s):
- Automatic differentiation Differentiable programming Gradient estimation Monte-Carlo algorithm High-energy physics Sampling calorimeter
- Format(s):
- Medium: X
- Sponsoring Org:
- National Science Foundation
More Like this
-
-
ABSTRACT A long-standing problem in galactic simulations is to resolve the dynamical friction (DF) force acting on massive black hole particles when their masses are comparable to or less than the background simulation particles. Many sub-grid models based on the traditional Chandrasekhar DF formula have been proposed, yet they suffer from fundamental ambiguities in the definition of some terms in Chandrasekhar’s formula when applied to real galaxies, as well as difficulty in evaluating continuous quantities from (spatially) discrete simulation data. In this work, we present a new sub-grid DF estimator based on the discrete nature of N-body simulations, which also avoids the ambiguously defined quantities in Chandrasekhar’s formula. We test our estimator in the gizmo code and find that it agrees well with high-resolution simulations where DF is fully captured, with negligible additional computational cost. We also compare it with a Chandrasekhar estimator and discuss its applications in real galactic simulations.more » « less
-
Abstract A preceding 2023 study argued that the resistance of a heterogeneous material to the curvature of the displacement field is the most physically realistic localization limiter for softening damage. The curvature was characterized by the second gradient of the displacement vector field, which includes the material rotation gradient, and was named the “sprain” tensor, while the term “spress” is here proposed as the force variable work-conjugate to “sprain.” The partial derivatives of the associated sprain energy density yielded in the preceeding study, sets of curvature resisting self-equilibrated nodal sprain forces. However, the fact that the sprain forces had to be applied on the adjacent nodes of a finite element greatly complicated the programming and extended the simulation time in a commercial code such as abaqus by almost two orders of magnitude. In the present model, Smooth Lagrangian Crack Band Model (slCBM), these computational obstacles are here overcome by using finite elements with linear shape functions for both the displacement vector and for an approximate displacement gradient tensor. A crucial feature is that the nodal values of the approximate gradient tensor are shared by adjacent finite elements. The actual displacement gradient tensor calculated from the nodal displacement vectors is constrained to the approximate displacement gradient tensor by means of a Lagrange multiplier tensor, either one for each element or one for each node. The gradient tensor of the approximate gradient tensor then represents the approximate third-order displacement curvature tensor, or Hessian of the displacement field. Importantly, the Lagrange multiplier behaves as an externally applied generalized moment density that, similar to gravity, does not affect the total strain-plus-sprain energy density of material. The Helmholtz free energy of the finite element and its associated stiffness matrix are formulated and implemented in a user’s element of abaqus. The conditions of stationary values of the total free energy of the structure with respect to the nodal degrees-of-freedom yield the set of equilibrium equations of the structure for each loading step. One- and two-dimensional examples of crack growth in fracture specimens are given. It is demonstrated that the simulation results of the three-point bend test are independent of the orientation of a regular square mesh, capture the width variation of the crack band, the damage strain profile across the band, and converge as the finite element mesh is refined.more » « less
-
Feng, B.; Pedrielli, G; Peng, Y.; Shashaani, S.; Song, E.; Corlu, C. G.; Lee, L.H.; Chew, E. P.; Roeder, T.; Lendermann, P. (Ed.)Automatic differentiation (AD) can provide infinitesimal perturbation analysis (IPA) derivative estimates directly from simulation code. These gradient estimators are simple to obtain analytically, at least in principle, but may be tedious to derive and implement in code. AD software tools aim to ease this workload by requiring little more than writing the simulation code. We review considerations when choosing an AD tool for simulation, demonstrate how to apply some specific AD tools to simulation, and provide insightful experiments highlighting the effects of different choices to be made when applying AD in simulation.more » « less
-
We present auto_diff, a package that performs automatic differentiation of numerical Python code. auto_diff overrides Python's NumPy package's functions, augmenting them with seamless automatic differentiation capabilities. Notably, auto_diff is non-intrusive, i.e., the code to be differentiated does not require auto_diff-specific alterations. We illustrate auto_diff on electronic devices, a circuit simulation, and a mechanical system simulation. In our evaluations so far, we found that running simulations with auto_diff takes less than 4 times as long as simulations with hand-written differentiation code. We believe that auto_diff, which was written after attempts to use existing automatic differentiation packages on our applications ran into difficulties, caters to an important need within the numerical Python community. We have attempted to write this paper in a tutorial style to make it accessible to those without prior background in automatic differentiation techniques and packages. We have released auto_diff as open source on GitHub.more » « less
An official website of the United States government
