liveBook · Manning

Just-in-time compilation

As explained in GPU Programming with Triton

JIT compilation translates program code into executable machine code at or near the time it is invoked.

Just-in-time (JIT) compilation translates code into executable form when it is needed during execution, rather than producing a complete executable ahead of time. section 2.2.1

In Triton, @triton.jit marks a kernel for compilation on its first launch. Triton specializes GPU code for the argument types and shapes, then caches the compiled result. The first call includes compilation overhead; later calls use the cached code. section 2.2.1

A live interpreter

Imagine an interpreter translating a speaker’s words as they are delivered, rather than preparing a full translation beforehand. A JIT compiler similarly compiles code paths when they are first executed. section 2.2.1

import torch
import triton
import triton.language as tl


@triton.jit

The @triton.jit decorator marks the following function for Triton compilation. section 2.2.1

How GPU Programming with Triton covers it

How deep it goes
Explains first-launch compilation, specialization, and caching, without detailing the intermediate-representation lowering pipeline.
Examples
Uses a live-interpreter analogy and the @triton.jit decorator to illustrate deferred compilation.
What it assumes
Assumes intermediate Python familiarity and introduces Triton kernels within a basic GPU execution context.
What you can do after
Apply JIT compilation by marking a Triton kernel with @triton.jit and accounting for compilation on its first launch.
How it connects
Connects JIT compilation with Triton kernels, GPU code, and ahead-of-time compilation.

Also explained in

Compare how 8 books explain just-in-time compilation →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of GPU Programming with Triton. The section links point to the parts of the book it draws on.