Introduction
In the pursuit of peak performance, the machine learning industry has increasingly embraced specialized hardware, such as Google’s Tensor Processing Units (TPUs), alongside highly optimized software kernels. While this specialization accelerates standard model training, it creates a significant "lock-in" effect. Researchers often operate under the assumption that high-level frameworks like PyTorch, TensorFlow, and JAX are hardware-agnostic—believing that code written for a GPU will seamlessly transition to a TPU.
This paper argues that this assumption is a "Grand Illusion." When software and hardware co-evolve too closely, researchers become trapped in a narrow tooling stack. This dynamic, often referred to as the "Hardware Lottery," discourages the exploration of novel ideas that fall outside dominant hardware-software combinations. Until now, the actual cost of straying from these established stacks has remained largely unquantified.
Quantifying the "Innovation Tax"
To measure this lack of portability, researchers conducted a large-scale, systematic audit of three major ML libraries: TensorFlow, PyTorch, and JAX.
The methodology involved:
- Function Sampling: Enumerating thousands of functions and sampling the "Top 20" most frequently used (based on the CodeParrot-clean dataset of ~22 million Python files), alongside random functions from every usage decile.
- Human Curation: Manually matching functions to official library test suites and modifying them to consistently measure core functionality and latency.
- Cross-Hardware Benchmarking: Running tests across NVIDIA GPUs (T4 and A100) and Google TPUs (v2-8 and v3-8).
- Failure Categorization: Tracking partial failures, complete failures, timeouts, and precision errors.
The "First-Class Citizen" Effect
The results reveal that portability is rarely a two-way street. Frameworks tend to heavily favor the hardware they were co-designed with. JAX, designed with TPUs in mind, acts as a "first-class citizen" on that hardware, boasting a 97% success rate. Conversely, PyTorch’s TPU support appears less integrated, leading to massive failure rates.
Surprisingly, a function's popularity offers no shield against these issues. The data indicates that the "Top 20" most-used functions fail just as often—if not more—than obscure ones when ported to different hardware. Furthermore, upgrading to newer hardware (e.g., from a T4 to an A100 GPU) improves speed but does almost nothing to resolve software portability gaps; the missing links are in the code, not the silicon.
The Latency Wall and Extreme Outliers
Even when a function successfully runs across different hardware, it may hit a "Latency Wall" that renders it practically useless. If a function runs orders of magnitude slower on a TPU, a researcher will likely abandon the experiment, effectively locking them back into the GPU ecosystem.
The performance hits observed in the study are severe:
- Functional Failures: On TPUs, a staggering 44% of PyTorch functions failed partially or completely. TensorFlow fared somewhat better but still exhibited a 21.5% failure rate on GPUs. The primary failure mode was "Not Implemented" (over 60% of TF and JAX failures), proving that many "portable" claims simply lack the underlying kernels.
- Performance Hits: 81.4% of PyTorch functions experienced more than a 10x slowdown when moved from GPU to TPU.
- Extreme Outliers: Certain functions, such as
torch.argsort, demonstrated a latency gap of 6039x between devices. - JAX Dominance on TPU: Reflecting its design origins, 91.8% of JAX functions were faster on the TPU than the GPU.
Limitations and Future Directions
While this study provides a crucial first look at the portability crisis, it has limitations. The scope was restricted to NVIDIA GPUs and Google TPUs, excluding AMD GPUs, Apple Silicon, and other emerging accelerators. Additionally, the closed-source nature of NVIDIA's CUDA makes it difficult to pinpoint exactly why certain kernels are missing or slow. Finally, the study evaluated individual, atomic functions rather than end-to-end model pipelines (like a full Transformer), though a single function failure is often enough to break an entire training run.
Future work must expand these benchmarks to more device types and investigate the root causes of kernel-level implementation gaps. Addressing these issues is vital for developers aiming to build truly portable frameworks that foster, rather than restrict, machine learning innovation.
Summary updated