liveBook · Manning

Intermediate representation

As explained in GPU Programming with Triton

An intermediate representation is a structured compiler artifact that expresses a program between its source form and its final executable form.

An intermediate representation (IR) is a compiler form between a Triton kernel’s Python source and its final GPU code. Inspecting successive forms helps reveal how the compiler transforms the kernel, particularly when investigating performance problems or unexpected behavior. section 2.3.2

Triton exposes compilation outputs including:

Retrieve compiled forms

After launching a kernel, access its compiled representations through `compiled.asm`, a dictionary keyed by stage names such as `ttir`, `ptx`, and `cubin`. section 2.3.2

Figure 2.11 Programmatic access to all compiler stages for a Triton kernel and the corresponding file outputs produced after compilation
CH02 F11 Fartale

See how Triton’s compiler stages correspond to files produced after compilation. section 2.3.2

How GPU Programming with Triton covers it

How deep it goes
Trace Triton IR, Triton GPU IR, LLVM IR, PTX, and binary outputs, but stop short of detailing every representation.
Examples
Uses a compiled Triton kernel’s `asm` attribute to retrieve intermediate forms.
What it assumes
Assumes a Triton kernel has been invoked once and does not teach IR details from first principles.
What you can do after
Diagnose kernel behavior or performance by retrieving compiled stages through Triton’s `asm` attribute.
How it connects
Connects Triton kernels to compiler pipelines, LLVM IR, and PTX assembly.

Also explained in

Compare how 3 books explain intermediate representation →

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.