TorchScript: Tracing vs. Scripting - Yuxin's Blog
PyTorch provides two methods to turn an nn.Module into a graph represented in TorchScript format: tracing and scripting. This article will: Compare their pros and cons, with a focus on useful tips fo
Posted 22/May/2022 TorchScript: Tracing vs. Scripting PyTorch provides two methods to turn an nn.Module into a graph represented in TorchScript format: tracing and scripting. This article will: Compare their pros and cons, with a focus on useful tips for tracing. Try to convince you that torch.jit.trace should be preferred over torch.jit.script for deployment of non-trivial models. The second point might be an uncommon opinion: If I Google "tracing vs scripting", the first article recommends scripting as default. But tracing has many advantages. In fact, by the time I left, "tracing as default
Explore this link on the map →related reading
- UW PLSE | How does torch.compile work?uwplse.org
- <no title> — PyTorch Tutorials 2.13.0+cu130 documentationpytorch.org
- State of torch.compile for training (August 2025) : ezyang's blogblog.ezyang.com
- PyTorch internals : ezyang's blogblog.ezyang.com
- Circuit Tracing: Revealing Computational Graphs in Language Modelstransformer-circuits.pub
- Reddit - Please wait for verificationreddit.com
- Tristan's Site - Tristan Humethume.ca
- the bug that taught me more about PyTorch than years of using it | Elana Simonelanapearl.github.io
- Learning PyTorch with Examples — PyTorch Tutorials 2.12.0+cu130 documentationpytorch.org
- Current and New Activation Checkpointing Techniques in PyTorch – PyTorchpytorch.org
- PyTorch Inference | onnxruntimeonnxruntime.ai
- PyTorch Profiling 101 with Modded-NanoGPTblog.underfit.ai