Relay's Dynamic Shape Limitations vs. Unity's Breakthrough
Before TVM Unity, the older Relay IR struggled with dynamic shapes, representing unknown dimensions as generic 'Any'. This limitation prevented critical compile-time optimizations, pushed memory allocation and computation decisions to runtime, and reduced the expressibility for dynamic workloads, leading to performance bottlenecks.
The top 3
- Relay's 'Any' vs. Unity's Symbolic Shape Breakthrough: Apache TVM Relay represented dynamic dimensions as an opaque 'Any' type, losing crucial information about shape relationships and pushing memory allocation to runtime; TVM Unity's Relax introduces first-class symbolic integer shapes, enabling precise compile-time deduction of tensor relationships for advanced optimization.
- Cross-Layer Optimization Unlocked by Dynamic Shapes: Unity's symbolic shapes enable cross-layer interactions, allowing dynamic shape information to flow between high-level computational graphs and low-level tensor programs. This fosters advanced optimizations like dynamic memory planning and more effective micro-kernel integration, which were significantly hindered by Relay's limited dynamic shape awareness.
- LLM Performance Boost: Dynamic Batching & Sequence Lengths: TVM Unity's enhanced dynamic shape handling is critical for optimizing Large Language Models (LLMs), enabling efficient support for variable batch sizes and dynamic sequence lengths. This capability, crucial for projects like MLC-LLM, addresses a significant limitation of Relay which often led to performance regressions for such dynamic workloads.
Sources
Open the full topic