Torch-MLIR PyTorch Compiler Bridge

Torch-MLIR PyTorch Compiler Bridge

github.com

3

About this website

Torch-MLIR is an open-source project that provides a compiler bridge between PyTorch models and MLIR (Multi-Level Intermediate Representation), enabling the compilation of PyTorch models for deployment on diverse hardware backends. Developed as a collaboration between NVIDIA, Meta, AMD, Intel, and the LLVM community, Torch-MLIR is part of the broader PyTorch compiler ecosystem (alongside TorchDynamo/TorchInductor) and the OpenXLA initiative. Key features: PyTorch to MLIR lowering: Torch-MLIR translates PyTorch models (represented as TorchScript or Lazy Tensor Core graphs) into MLIR dialects, providing a path from high-level PyTorch operations to optimized hardware-specific code. The project defines several MLIR dialects: torch dialect (preserving PyTorch semantics), torch_kernel dialect (for fused kernel generation), and lowering paths to downstream dialects (linalg, tosa, stablehlo). TorchScript integration: Torch-MLIR accepts TorchScript (PyTorch's serializable model format) as input, enabling compilation of traced or scripted PyTorch models. Lazy Tensor Core integration: supports Lazy Tensor Core (LTC) for tracing and executing PyTorch models lazily, enabling ahead-of-time compilation. Backend support: Torch-MLIR lowers models to: StableHLO (for XLA and TPU compilation via the OpenXLA project), Linalg/TOSA (for CPU, GPU, and custom accelerators via IREE or MLIR codegen), and custom backends. The StableHLO path enables compilation to Google TPUs, NVIDIA GPUs (via XLA), and AMD GPUs. Eager mode support: via Lazy Tensor Core, supporting eager execution with compilation. Fusion and optimization: MLIR-based optimization passes for operation fusion, constant folding, and dead code elimination. ONNX export path. Used in production at Meta for recommendation systems and at NVIDIA for GPU optimization. Apache-2.0 (with NVIDIA/LLVM contributions).

Tags & Categories

Statistics

3
Views
0
Clicks
0
Like
0
Dislike

Comments

Log In to post a comment

No comments yet. Be the first!