Abstract
Modern deep learning workloads, particularly Large Language Models (LLMs) and Graph Neural Networks (GNNs), increasingly rely on dynamic input shapes. Traditional tensor compilers struggle with these workloads, either relying on opaque vendor libraries or slow, sample-based auto-tuning that fails when encountering unseen shapes. We present Vortex, a hardware-aware, sample-free compiler that optimizes tensor programs by aligning software abstractions with hardware hierarchies. By replacing empirical sampling with a bidirectional workflow guided by hardware specifications, Vortex achieves up to 3.01× faster execution and reduces compilation time by 176× compared to existing state-of-the-art compilers.
Introduction
The efficiency of Deep Neural Networks (DNNs) heavily depends on the optimization of underlying tensor operators like General Matrix Multiplication (GEMM) and Convolution. While static-shape optimization is well-understood, "dynamic-shape" scenarios—where sequence lengths or image dimensions vary at runtime—present a significant challenge for current infrastructure.
Current optimization strategies are bifurcated. Vendor-provided libraries (e.g., cuBLAS, oneDNN) offer high performance but act as "black boxes," requiring immense manual effort to support new operators. Conversely, sample-driven compilers like DietCode attempt to automate this process by auto-tuning micro-kernels for a subset of representative shapes. However, these compilers suffer from two major drawbacks: extreme compilation overhead (often taking hours or days) and the "padding trap," where performance degrades significantly if the runtime shape does not match the pre-tuned samples.
The Vortex Approach: Hardware-Aware Strategy Space Hierarchization
Vortex addresses these limitations by shifting the optimization focus from input shapes to hardware constraints. Instead of treating the hardware as a black box to be probed via sampling, Vortex uses architectural limits (e.g., register counts, cache sizes) to prune the optimization search space.
Bidirectional Compilation Workflow
Vortex employs a unique bidirectional workflow that eliminates the need for runtime shape samples:
- Top-Down Abstraction (rKernel): Vortex introduces the
rKernel, a recursive abstraction that decomposes tensor programs into layers mirroring the hardware hierarchy (e.g., for a GPU: Grid → Block → Warp → Thread). This ensures that the software structure naturally fits the target device. - Bottom-Up Kernel Construction: Rather than searching an exhaustive space of tiling strategies, Vortex builds kernels from the register level upward. It uses hardware specifications to immediately discard strategies that would exceed physical resource limits, such as oversubscribing registers or L1 cache.
- Hybrid Analyzer: To maintain low overhead while ensuring accuracy, Vortex uses a hybrid evaluation model. It employs empirical profiling for low-level micro-kernels—where hardware complexity is highest—and a recursive analytical cost model for higher-level scheduling.
Evaluation and Results
The researchers evaluated Vortex across 1,197 operator configurations and several end-to-end models (BERT, GPT-2, ResNet) on Intel Xeon CPUs and Nvidia A100 GPUs.
Overcoming the Padding Trap
A key advantage of Vortex is its resilience to varying input shapes. Sample-based compilers often rely on padding to fit a runtime shape into a pre-tuned kernel, leading to wasted computation. Vortex’s bottom-up approach ensures that tiling is optimized for the hardware first, confining any necessary padding to the outermost level and maintaining high efficiency across the entire shape space.
Performance Gains
Vortex demonstrates significant improvements in both compilation and execution efficiency:
- Compilation Speed: By removing the iterative tuning loop, Vortex reduces offline compilation time by 176× compared to DietCode, moving from hours to seconds.
- Execution Speed: Vortex outperforms vendor libraries, achieving 1.82× to 2.09× speedups over oneDNN on CPUs and 1.43× to 2.32× over cuBLAS on GPUs. Compared to the leading dynamic compiler (DietCode), it delivers an average speedup of 3.01×.
- Optimality: Vortex reaches 94.7% of the performance of a theoretical "Oracle" compiler that tunes specifically for every individual shape.
Conclusion
Vortex represents a paradigm shift in dynamic tensor program optimization. By leveraging hardware specifications as a primary filter for the search space, it eliminates the costly and fragile dependency on shape sampling. While current work focuses on operator-level optimization, future integration with graph-level compilers promises a comprehensive, high-performance solution for the next generation of dynamic AI models.
Summary updated