NaN-Propagation: A Novel Method for Sparsity Detection in Black-Box Computational Functions

  • 2025-08-01 03:11:12
  • Peter Sharpe
  • 0

Abstract

When numerically evaluating a function's gradient, sparsity detection canenable substantial computational speedups through Jacobian coloring andcompression. However, sparsity detection techniques for black-box functions arelimited, and existing finite-difference-based methods suffer from falsenegatives due to coincidental zero gradients. These false negatives cansilently corrupt gradient calculations, leading to difficult-to-diagnoseerrors. We introduce NaN-propagation, which exploits the universalcontamination property of IEEE 754 Not-a-Number values to trace input-outputdependencies through floating-point numerical computations. By systematicallycontaminating inputs with NaN and observing which outputs become NaN, themethod reconstructs conservative sparsity patterns that eliminate a majorsource of false negatives. We demonstrate this approach on an aerospace wingweight model, achieving a 1.52x speedup while uncovering dozens of dependenciesmissed by conventional methods -- a significant practical improvement sincegradient computation is often the bottleneck in optimization workflows. Thetechnique leverages IEEE 754 compliance to work across programming languagesand math libraries without requiring modifications to existing black-box codes.Furthermore, advanced strategies such as NaN payload encoding via direct bitmanipulation enable faster-than-linear time complexity, yielding speedimprovements over existing black-box sparsity detection methods. Practicalalgorithms are also proposed to mitigate challenges from branching codeexecution common in engineering applications.

 

Quick Read (beta)

loading the full paper ...