Abstract
The rapid diversification of AI hardware has created a significant maintenance burden for framework developers and hardware vendors. Integrating new accelerators into popular frameworks like PyTorch or TensorFlow typically requires extensive source code modifications and ongoing synchronization with upstream updates. This paper presents SOL, an optimization middleware designed to decouple AI frameworks from hardware backends. By utilizing a hardware abstraction layer and innovative "hijacking" techniques, SOL enables seamless support for new devices—such as CPUs, GPUs, and vector processors—without altering the framework's core. SOL achieves up to a 25x speedup over reference implementations while reducing the engineering effort for new device support from tens of thousands of lines of code to just a few thousand.
Introduction: The Hardware-Software Gap
The AI hardware landscape is expanding at an unprecedented rate. However, the software ecosystem struggles to keep pace, leading to a "maintenance nightmare." Currently, hardware vendors must often fork major frameworks to add support for their specific chips. This results in fragmented versions of PyTorch or TensorFlow that are difficult to maintain and prevent users from easily mixing hardware from different vendors within a single environment. SOL addresses this by creating a middleware that sits between the high-level AI framework and the low-level hardware, providing a "write once, run anywhere" abstraction.
The SOL Architecture
SOL introduces a simplified stack that replaces the need for multiple device-specific backends within the framework core with a single, unified middleware layer.
1. The SOL Compiler
The SOL compiler extracts the computation graph from the framework and converts it into a specialized Intermediate Representation (IR). It applies high-level mathematical optimizations, such as fusing ReLU and MaxPooling layers. A key innovation is Depth First Parallelism (DFP): instead of processing a model layer-by-layer, which frequently flushes data to main memory, DFP processes the graph in a depth-first manner to keep data in the processor's registers and caches as long as possible. It also automatically selects the best memory layout (e.g., NCHW vs. NHWC) for the specific hardware.
2. The SOL Runtime
The runtime manages memory and connects optimized kernels to the framework’s memory allocation system. This allows SOL to read and write framework tensors directly without expensive data copies.
Integration and "Hijacking" Strategies
SOL offers two primary ways to integrate with existing frameworks:
- Transparent Offloading: A "Keras-like" approach where the user adds a few lines of Python code. SOL intercepts the model and handles the execution.
- Native Offloading: A clever "hijacking" technique. For example, in PyTorch, the authors repurpose existing, unused device slots (like "HIP") to register SOL’s callbacks for new hardware like the NEC SX-Aurora vector processor. This tricks the framework into supporting new hardware without changing a single line of its C++ core.
Key Results and Performance
The performance of SOL was evaluated using standard deep learning architectures, including various CNNs (ResNet, VGG, DenseNet) and MLPs.
- Speedups: SOL demonstrated substantial gains over native PyTorch (CPU/GPU) and TensorFlow-VE (NEC SX-Aurora). It was up to 7.79x faster on CPUs and 4.37x faster on GPUs for inference. On the NEC SX-Aurora, it achieved a massive 25.41x speedup for inference and 4.18x for training compared to the reference implementation.
- Engineering Efficiency: The abstraction provided by SOL drastically reduces development time. Implementing support for the SX-Aurora required only ~3,000 lines of code and two weeks of engineering effort, compared to the 47,000+ lines required for native NVIDIA GPU support in PyTorch.
Conclusion
SOL demonstrates that middleware can provide both high performance and ease of integration for diverse AI hardware. By decoupling frameworks from hardware backends, SOL allows vendors to support new devices with minimal effort while providing users with significant performance improvements. Future work will focus on expanding support to more complex structures like Transformers and Recurrent Neural Networks (RNNs).
Summary updated