AI engineering glossary · Inference serving optimisation

What is torch.compile?

torch.compile: A PyTorch feature that traces a model's operations and compiles them into optimised code, fusing operations and generating efficient kernels. It can speed up inference with a single line, though the first call is slow while compiling.

Level: intermediateTopic: Inference serving optimisation

torch.compile: an example

Wrapping a model with torch.compile(model) gives faster repeated calls after a warm-up run.

Related terms

More Inference serving optimisation terms

Where you learn it

torch.compile is part of the AI Engineering Program, which teaches it with notes, a hands-on lab and an exam. The first lesson is free.

Before you go

Take the cheat sheet with you

One free PDF: the key AI-engineering terms, formulas and Python idioms. No spam; unsubscribe any time.