TL;DR
Signatory is a new, highly optimized library for computing signature and logsignature transforms, designed specifically for deep learning. It provides the first GPU-capable implementation and introduces novel algorithmic improvements that deliver order-of-magnitude speedups, making these powerful tools from rough path theory practical for modern neural network training.
What Problem Does This Paper Address?
The signature transform is a mathematical tool from rough path theory that summarizes sequential data (like time series) by capturing the order and area of its path. While it’s "universally nonlinear" and highly effective for tasks ranging from handwriting recognition to sepsis prediction, its adoption in deep learning has been hampered by computational bottlenecks.
Existing libraries were primarily CPU-only, single-threaded, and lacked efficient support for backpropagation. As researchers began embedding these transforms inside neural networks, the time spent calculating signatures and their gradients became the primary source of slowdown, often making training prohibitively slow. Signatory aims to eliminate this bottleneck by providing a fast, differentiable, and GPU-accelerated implementation.
Methods
Signatory introduces several key technical innovations to speed up computations:
- Fused Multiply-Exponentiate: The standard way to update a signature is to take the exponential of a new data increment and then combine it with the existing signature using a "tensor product-like" operation. Signatory fuses these into a single operation. By applying a Horner-style scheme to the tensor expansion, they reduce the asymptotic complexity from $O(N d^N)$ to an optimal $O(d^N)$, where $d$ is the number of channels and $N$ is the transform depth.
- Efficient Logsignature Basis: The logsignature is a more compact version of the signature. Traditionally, converting to a standard "Lyndon basis" required solving an overdetermined linear system. Signatory identifies a new, mathematically unusual basis that exploits a triangularity property, allowing coefficients to be extracted directly and cheaply from the tensor representation.
- Improved Precomputation: For querying signatures over arbitrary intervals of a long sequence, Signatory achieves $O(1)$ inference time with $O(L)$ precomputation (where $L$ is sequence length), improving upon previous $O(\log L)$ methods.
- Handwritten Backpropagation: Instead of relying on PyTorch's automatic differentiation, the authors wrote custom C++ kernels for the backward pass. These kernels exploit a reversibility property of the signature, allowing them to recover intermediate states during backpropagation rather than storing them, which significantly reduces memory usage.
Datasets
The authors evaluated Signatory using:
- Synthetic Benchmarks: A series of tests varying the number of channels (2–7) and transform depth (2–9) to compare performance against existing libraries
esigandiisignature. - Deep Learning Toy Task: A binary classification problem using a dataset of geometric Brownian motion samples with different volatilities. This was used to demonstrate the real-world impact on training time for a "deep signature model."
Key Insights and Ideas
- Complexity Matters: The jump from $O(N d^N)$ to $O(d^N)$ isn't just a constant factor improvement; it changes how the transform scales with depth, which is critical as $d^N$ grows very quickly.
- GPU Obviates Data Transfer: Beyond raw compute speed, having a GPU-native implementation prevents the costly overhead of moving data between the GPU (where the rest of the neural network lives) and the CPU (where previous signature libraries were stuck).
- Reversibility as a Feature: By treating the signature as a solution to a differential equation, the authors could use the "adjoint method" for backpropagation. This allows for exact gradient calculations without the numerical approximation errors typically seen in Neural ODEs.
Key Results
The performance gains are dramatic, especially as problem size increases:
- Forward Pass Speedup: On a GPU, Signatory is up to 132x faster than the best previous alternative (
iisignatureon CPU) for large computations. Even on a single-threaded CPU, Signatory's algorithmic improvements yield a 5.5x speedup. - Backward Pass Speedup: For backpropagation, Signatory on GPU is 166x faster than
iisignatureon CPU. - Training Efficiency: In the deep learning example, a model using Signatory trained 210 times faster than one using
iisignature. This highlights that the signature transform was previously the single largest bottleneck in these architectures.
Limitations and Future Work
- Numerical Stability: The $O(1)$ precomputation strategy can suffer from numerical instability when dealing with very long intervals, requiring caution in specific applications.
- Parallel Backpropagation: Currently, Signatory does not parallelize the gradient computation for a single sequence because the reversibility property (which saves memory) makes the necessary intermediate values unavailable for parallel reduction. The authors suggest this as an area for future optimization, though they note that batch-level parallelism often saturates hardware anyway.
- Memory-Speed Trade-offs: The choice to use reversibility saves memory but costs extra computation time. Providing an option to toggle between these two modes could be beneficial for users with varying hardware constraints.
Summary updated