Relax's Evolution: Overcoming Relay's Limitations

Relax, as the successor to Relay, was developed to tackle critical challenges like dynamic shape support and rigid compilation pipelines in machine learning workloads. It introduces first-class symbolic shape capabilities and integrates seamlessly with Tensor Expression (TE) for efficient operator lowering, enabling more adaptable and performant ML compilation.

The top 3

  1. Relax's Symbolic Shape Advantage: Dynamic Model Optimization: Relay often marked dynamic tensor dimensions as 'unknown,' limiting compile-time optimization. Relax introduces first-class symbolic shape support, enabling the compiler to track dynamic dimensions across operations and function calls, which is crucial for optimizing modern dynamic ML workloads like LLMs.
  2. Beyond Graph-Level: Relax's Unified IR for Cross-Layer Optimization: While Relay functioned primarily as a graph-level IR, Relax unifies computational graphs, loop-level TensorIR programs, and external library calls into a single, cohesive abstraction. This unification, a core tenet of TVM Unity, enables comprehensive cross-layer optimizations previously difficult to achieve.
  3. Simplified Operator Customization: Relax's EmitTE vs. Relay's Complexity: Defining custom operators in Relay was an 8-step process requiring code changes in both C++ and Python. Relax significantly streamlines this with its `emit_te` feature, allowing direct integration with Tensor Expression (TE) and TOPI libraries for much faster and easier custom operator creation and lowering.

Sources

Open the full topic