[Paper Review] Use and implementation of autodifferentiation in tensor network methods with complex scalars
This paper presents a practical implementation of reverse-mode automatic differentiation (AD) in tensor network toolkits using complex scalars, demonstrating that less than 1,000 lines of code extend native C++ tensor libraries to support AD. It establishes the mathematical foundations for differentiating key tensor operations—QR and SVD—under complex scalars, with a key contribution being the derivation of the adjoint for the complex SVD, enabling end-to-end backpropagation in quantum many-body simulations.
Following the recent preprints arXiv:1903.09650 and arXiv:1906.04654 we comment on the feasibility of implementation of autodifferentiation in standard tensor network toolkits by briefly walking through the steps to do so. The total implementation effort comes down to fewer than 1000 lines of additional code. We furthermore summarise the current status when the method is applied to cases where the underlying scalars are complex, not real and the final result is a real-valued scalar. It is straightforward to generalise most operations (addition, tensor products and also the QR decomposition) to this case and after the initial submission of these notes, also the adjoint of the complex SVD has been found.
Motivation & Objective
- To enable reverse-mode automatic differentiation in native tensor network toolkits without relying on external frameworks like PyTorch or TensorFlow.
- To extend standard tensor operations—addition, tensor products, QR decomposition, and SVD—to complex scalar arithmetic while preserving differentiability.
- To derive and validate the adjoint of the complex singular value decomposition (SVD), a critical missing component for gradient-based optimization in quantum many-body systems.
- To ensure gauge invariance in the SVD adjoint computation, particularly under phase transformations of U and V matrices.
- To provide a testable, efficient, and modular AD framework compatible with symmetries and asynchronous tensor caching in condensed matter simulations.
Proposed method
- Augmented the STensor class with autodifferentiation IDs and shared pointers to ComputeNode objects to track computational graphs.
- Constructed a directed acyclic graph (DAG) of compute nodes, each storing input/output dependencies, adjoint evaluation functions, and cached tensor data for backpropagation.
- Implemented reverse-mode AD by traversing the DAG backward, computing adjoints using pre-defined adjoint evaluator functions for each operation.
- Derived the adjoint of the complex QR decomposition by expressing the differential of Q and R in terms of the output adjoint and input perturbations, incorporating complex conjugation and Hermitian structure.
- Extended the real SVD adjoint derivation to the complex case, resolving the issue of phase ambiguity by enforcing gauge conditions (e.g., first column of V real and positive) and ensuring gauge-invariant cost functions.
- Validated the implementation using finite-difference comparisons with perturbed inputs, testing gradients of real-valued cost functions derived from complex tensors (e.g., norms, traces, or selected elements).
Experimental results
Research questions
- RQ1Can reverse-mode automatic differentiation be efficiently and natively implemented in a C++ tensor network toolkit without external AD libraries?
- RQ2How can the adjoint of the complex QR decomposition be derived and implemented, particularly accounting for complex conjugation and Hermitian structure?
- RQ3What are the mathematical and computational challenges in differentiating the complex singular value decomposition (SVD), and how can gauge freedom be exploited to ensure differentiability?
- RQ4How can the resulting AD framework be tested robustly when the final output is a real scalar, even though intermediate scalars are complex?
- RQ5Is the adjoint of the complex SVD computable in a way that preserves gauge invariance of the cost function under U and V phase transformations?
Key findings
- The implementation of reverse-mode AD in a native tensor network toolkit requires less than 1,000 lines of additional C++ code, with the core framework (compute node graph and adjoint propagation) implemented in about 350 lines.
- The adjoint of the complex QR decomposition was successfully derived, with the differential of Q and R expressed in terms of the output adjoint and input perturbations, including proper handling of complex conjugation.
- The differential of the complex SVD was found to be non-trivial due to phase ambiguity, but a solution was achieved by enforcing a gauge condition (e.g., first column of V real and positive), enabling differentiable SVD in optimization workflows.
- The derived adjoint for the complex SVD ensures that the gradient is invariant under unitary transformations of U and V, provided the cost function is gauge-invariant, which is essential for physical consistency.
- The framework supports efficient gradient computation for real-valued cost functions derived from complex tensors, such as norms, traces, or selected tensor elements, enabling use in energy minimization and variational algorithms.
- Testing via finite-difference comparison confirmed the correctness of the AD implementation, with agreement up to numerical precision for small perturbations in complex tensor inputs.
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.