CAFIN: CUDA-accelerated Adaptive Fisher Information Matrix Network Optimization via GPU-Native Kernel Fusion
CAFIN fuses CUDA kernels to speed up the AdaFisher secondâorder optimizer, cutting latency and memory use while keeping training accuracy.

Introduction
Training deep neural networks with secondâorder optimizers can yield faster convergence because they exploit curvature information, but the practical gains are often erased by heavy GPU overhead. AdaFisher addresses this by approximating the Fisher Information Matrix (FIM) with diagonal Kronecker structures and exponential moving averages, yet its reference PyTorch implementation still suffers from a cascade of separate CUDA kernel launches, temporary tensor allocations, and repeated memory traffic. CAFIN (CUDAâaccelerated Adaptive Fisher Information Matrix Network Optimization) tackles the performance bottleneck at the kernel level. By progressively fusing the distinct steps of AdaFisherâFIM construction, EMA updates, gradient preconditioning, momentum handling, weight decay, and parameter updatesâinto a small set of native CUDA kernels, CAFIN reduces both latency and memory footprint without altering the underlying optimization mathematics.
---
Kernel Fusion Strategy
From Sequential Calls to InâPlace Pipelines
Traditional AdaFisher executes each subâoperation in its own kernel, forcing the GPU to launch, synchronize, and move intermediate results between global memory and registers. CAFIN rewrites the workflow so that a single kernel can:
- Load the current gradient and model parameters into registers.
- Update the EMA of the FIM diagonal blocks directly in shared memory.
- Apply the preconditioner to the gradient onâtheâfly.
- Incorporate momentum and weightâdecay terms.
- Write the final updated parameters back to global memory.
By keeping data resident in registers or shared memory throughout the step, CAFIN eliminates the need for separate allocation buffers and reduces globalâmemory traffic.
MemoryâEfficient Design
- Sharedâmemory reuse: The same sharedâmemory buffers store both the EMA of the FIM and the intermediate preconditioned gradients, avoiding duplicate allocations.
- Registerâresident computation: Critical scalar operations (e.g., EMA decay, momentum scaling) are performed in registers, which are the fastest onâchip storage.
- Inâplace updates: Parameter tensors are overwritten directly, cutting the perâstep allocation overhead by roughly 19âŻMB on the tested GPUs.
---
Empirical Highlights
Experiments were conducted on ResNetâ18 across three image classification benchmarks (CIFARâ10, CIFARâ100, Tiny ImageNet) using two consumerâgrade GPUs (GTXâŻ1660âŻTi and RTXâŻ3060âŻLaptop). The key observations include:
- FIM construction latency dropped by up to 78âŻ% compared with the baseline AdaFisher implementation.
- Overall optimizerâstep latency improved between 2âŻ% and 27âŻ%, depending on dataset size and GPU.
- Training accuracy remained statistically indistinguishable from the original method across multiple random seeds, confirming numerical fidelity within standard FP32 tolerances.
These results demonstrate that kernelâlevel fusion can deliver substantial speedups for secondâorder methods without sacrificing the theoretical benefits they provide.
---
Practical Takeaways
- Performanceâfirst refactoring: When a highâlevel optimizer incurs many small kernels, consider merging them into a single, wellâstructured CUDA kernel to minimize launch overhead.
- Leverage onâchip memory: Shared memory and registers are underutilized in many deepâlearning pipelines; reâarchitecting data flow to keep intermediate values onâchip can yield both speed and memory savings.
- Maintain numerical equivalence: CAFIN validates that aggressive fusion does not have to compromise precision; careful ordering of operations and adherence to FP32 rounding behavior preserve the original optimizerâs convergence properties.
- Portability: Although CAFIN is built for CUDA, the same principlesâkernel fusion, inâplace updates, and onâchip memory reuseâcan be adapted to other GPU programming models (e.g., ROCm, SYCL) for broader hardware support.
---
Conclusion
CAFIN showcases how a disciplined, kernelâfusion approach can revitalize secondâorder optimization in deep learning. By collapsing the multiple stages of AdaFisher into a handful of GPUânative kernels, it slashes both execution time and memory consumption while delivering identical training outcomes. For practitioners seeking to harness curvatureâbased methods on commodity hardware, CAFIN provides a concrete blueprint: prioritize kernel consolidation, exploit fast onâchip storage, and verify numerical consistency throughout the transformation.
Source
Read original sourceWhy we picked this
Introduces a CUDA kernel fusion framework to accelerate second-order optimizers, important AI training tech.