Date
Tuesday, October 27, 2026
Name
How to build a Python DSL for MLIR
Session Type
Tutorial
Abstract

Python is mutable and dynamically typed; MLIR is statically typed and built on SSA. So how do you build a Python DSL that feels like real Python — its objects, imports, and metaprogramming — yet compiles all the way down to MLIR? In this tutorial we build one from zero to hero, guided by two ideas: don't reinvent the language (reuse Python instead of re-implementing a Python-shaped one), and don't tie yourself to a target (build the Python→MLIR core once, then derive thin, target-specific sub-DSLs from it). We show how expressions become arith, how native Python control flow becomes scf, and how we tackle the one genuinely hard part — a variable reassigned across a loop, which SSA cannot express — by recording mutation into a small python dialect and recovering scf iter_args with a single MLIR pass. We then stand up a GPU sub-DSL on the same core by swapping only the lowering pipeline, and close with a look at how we used specialized AI agents as stand-in users to gather feedback on the DSL long before real users arrived. Throughout, the framing is multi-stage programming: Python is the meta-language, MLIR is the object language.

Location Name
Grand Ballroom