Skip to main content
QUICK REVIEW

[Paper Review] Operator Fusion in XLA: Analysis and Evaluation

Daniel Snider, Ruofan Liang|arXiv (Cornell University)|Jan 30, 2023
Parallel Computing and Optimization TechniquesComputer Science3 citations
TL;DR

This paper reverse-engineers XLA’s operator fusion mechanism, revealing how conservative rule-based fusion and frontend code quality limit performance. By optimizing code structure, loop unrolling, and custom fusion strategies, the authors achieve up to 10.56x speedup over baseline JAX-XLA, exposing key bottlenecks like kernel launch overhead and reliance on cuDNN primitives.

ABSTRACT

Machine learning (ML) compilers are an active area of research because they offer the potential to automatically speedup tensor programs. Kernel fusion is often cited as an important optimization performed by ML compilers. However, there exists a knowledge gap about how XLA, the most common ML compiler, applies this nuanced optimization, what kind of speedup it can afford, and what low-level effects it has on hardware. Our paper aims to bridge this knowledge gap by studying key compiler passes of XLA's source code. Our evaluation on a reinforcement learning environment Cartpole shows how different fusion decisions in XLA are made in practice. Furthermore, we implement several XLA kernel fusion strategies that can achieve up to 10.56x speedup compared to our baseline implementation.

Motivation & Objective

  • To reverse-engineer and document XLA’s operator fusion mechanism, which remains poorly documented in public literature.
  • To evaluate XLA’s performance on a real-world JAX-based reinforcement learning task (Cartpole) and identify limitations in its fusion strategy.
  • To explore and implement alternative fusion strategies that improve performance beyond XLA’s default behavior.
  • To quantify the impact of frontend code quality, kernel launch overhead, and third-party library dependencies (e.g., cuDNN) on XLA-generated code efficiency.

Proposed method

  • Reverse-engineered XLA’s source code to analyze its rule-based fusion passes and understand fusion decision criteria.
  • Implemented a microbenchmark using the Cartpole reinforcement learning environment to evaluate XLA’s fusion behavior under real workloads.
  • Applied code transformations such as loop unrolling and structural refactoring to reduce kernel launch count and improve fusion opportunities.
  • Developed custom fusion strategies by modifying XLA’s HLO (High-Level Optimizer) graph to merge operations that were previously kept separate.
  • Conducted low-level profiling to measure kernel launch overhead, memory transfers, and execution time differences between baseline and optimized implementations.
  • Compared performance against a hand-written CUDA kernel to isolate the impact of XLA’s framework-level abstractions and compilation choices.

Experimental results

Research questions

  • RQ1How does XLA’s rule-based fusion strategy determine which operations to fuse, and what constraints limit its effectiveness?
  • RQ2To what extent does the quality of the frontend Python code (e.g., use of concatenate operations) affect the performance of XLA-compiled kernels?
  • RQ3What performance gains can be achieved through manual code refactoring and loop unrolling in XLA-compiled ML workloads?
  • RQ4Why does XLA still underperform compared to hand-optimized CUDA kernels, and what are the key system-level bottlenecks?
  • RQ5How do third-party libraries like cuDNN and cuBLAS impact fusion opportunities and overall execution efficiency in XLA-GPU?

Key findings

  • XLA’s fusion strategy is conservative and rule-based, often failing to fuse operations like concatenation even when semantically safe, due to heuristics designed to avoid performance regression.
  • The baseline JAX-XLA implementation launched 3,000 kernels over 10,000 steps in the Cartpole environment, contributing to a 2.7x longer runtime than a hand-optimized CUDA kernel.
  • Loop unrolling by a factor of 10 reduced kernel launch overhead and contributed significantly to performance gains, demonstrating the value of auto-tuning loop structure.
  • Custom fusion strategies that merged operations across multiple HLO instructions achieved up to 10.56x speedup over the baseline JAX-XLA implementation.
  • The use of third-party cuDNN/cuBLAS primitives in XLA-GPU introduces layout conversion overhead and limits fusion opportunities, unlike XLA-TPU which has first-party optimized kernels.
  • Frontend code quality has a major impact on performance—inefficient patterns like repeated concatenation can severely degrade XLA’s ability to generate optimal kernels.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.