ptc-tutorial icon indicating copy to clipboard operation
ptc-tutorial copied to clipboard

PyTorch compilation tutorial covering TorchScript, torch.fx, and Slapo

PyTorch Compilation Tutorial

Open In Colab

This tutorial is designed for ECE6980 Spring 2023 @ Cornell. It covers the basic compilation techniques in the PyTorch ecosystem.

  1. Basic PyTorch
    • Hierarchical module construction
  2. TorchScript
    • Tracing mode
    • Scripting mode
  3. torch.fx
    • Symbolic trace
    • Intermediate representation (IR)
    • Graph traversal and manipulation
    • limitation
  4. slapo
    • Progressive optimization (manual + compiler optimization)
    • Subgraph matching
    • Operator fusion
    • Module replacement
    • Quantization (optional)
  5. PyTorch 2.0 (optional)

Set up environment

Please use a clean environment and install the following package.

pip3 install torch numpy slapo tabulate transformers

Reading materials

Paper

Blogs and Documents