Abstract
Optimizing TensorFlow's performance on CPU backends is a complex task typically handled through manual trial-and-error or static defaults. We present TensorTuner, an automated framework that treats threading configuration as a black-box optimization problem. By utilizing the Nelder-Mead Simplex algorithm, TensorTuner identifies optimal configurations for inter-op and intra-op parallelism, delivering performance gains of up to 123% over default settings while searching less than 10% of the potential parameter space.
Introduction
While deep learning often focuses on GPU acceleration, CPUs remain a cornerstone for many production inference and training workloads. TensorFlow utilizes two primary CPU backends: the default Eigen library and the Intel Math Kernel Library (MKL). Achieving peak performance on these backends requires precise tuning of threading parameters, including inter_op_parallelism_threads, intra_op_parallelism_threads, and OMP_NUM_THREADS.
Current "best-known" defaults are often neural-network agnostic, failing to account for specific model architectures. This leads to significant performance bottlenecks, such as thread over-subscription, where the overhead of managing excessive threads outweighs the computational benefits.
Methodology: The TensorTuner Framework
TensorTuner formulates threading configuration as a black-box function optimization problem. Because the relationship between thread counts and hardware performance is non-differentiable and noisy, the framework employs the Nelder-Mead Simplex algorithm.
Key features of the methodology include:
- Gradient-Free Optimization: Direct search via Nelder-Mead avoids the need for differentiable performance functions.
- Active Harmony Integration: Built upon the Active Harmony framework for automated performance tuning in high-performance computing (HPC).
- Constrained Search: Search is bounded by physical core counts to accelerate convergence and prevent unrealistic configurations.
Experimental Evaluation
The framework was evaluated using the standard TensorFlow Benchmarking Suite (tf_cnn_benchmarks) across five CNN architectures: ResNet-50, InceptionV3, VGG11, VGG16, and GoogLeNet. Testing was conducted on an Intel Xeon Platinum 8180 processor featuring 56 physical cores.
Key Results
TensorTuner demonstrated significant improvements across both CPU backends. For the Eigen backend, performance gains ranged from 2% to 123% over default settings. The most dramatic improvement (123% for VGG11) was achieved by identifying and fixing severe thread over-subscription issues inherent in default configurations.
For the MKL backend, the tool outperformed expert-tuned "best-known" settings by 1.5% to 28%. Beyond raw performance, TensorTuner proved highly efficient, converging to optimal settings roughly 10x faster than exhaustive search methods by exploring only 9% to 24% of the parameter space. Analysis via Intel VTune confirmed that these optimized settings significantly reduced "thread spin time," ensuring CPU cores spent more time on active computation.
Conclusion and Future Work
TensorTuner provides a robust, automated alternative to manual threading optimization. While highly effective for CNNs, future work will explore its generalizability to other architectures like Transformers and RNNs. Additionally, scaling the search to include data pre-processing threads and further tuning the Nelder-Mead algorithm parameters could yield even greater efficiency in diverse hardware environments.
Summary updated