Notes on verified ML

Here's my vision for verification in AI. Some examples I've been working on :)

* I wrote most of these posts, with some AI assistance in the prose and Lean code.

03 / Training

Training a GPT-2-style model in Lean

Let's train a GPT in Lean :) I trained a 124.4-million-parameter model on one A100 and compared fifty matched updates with PyTorch. The loss went down, but getting a dependable assistant out of it was harder.

Along the way we prove results about next-token targets, resuming training, and reusing the attention cache during generation.

Read the experiment →

04 / Tensor programming

Writing tensor programs in Lean

I'd like to write a tensor calculation in Lean and choose the device when I run it. So we try the custom-function API, build attention with einsum, and look at the measured performance. Higher derivatives and binary128 arithmetic let us try other calculations too.

Write a tensor function →

05 / Kimi K3

Kimi K3: the paper and proofs side by side

I wanted to bring the paper-and-proof approach from research mathematics to ML. With K3's report open beside us, we work through its memory, attention, and experts and prove that streaming preserves the logits. We also find a slip at one endpoint of the expert-balancing argument.

Open the annotated report →

07 / Heuristic estimation

Estimating model behavior from its structure

MAISI and ARC ask how a model's structure could help estimate its behavior. We follow shared inputs and attention, use the backward pass to bound the expected error when we average away some input randomness, and then race three structural estimators against sampling on random ReLU networks.

Read the essay →

08 / Program equilibrium

Programs that read each other's code

Jacob Tsimerman's MAISI talk ends on programs that play a prisoner's dilemma after reading each other's source. We prove the classic matchups in a modal model, then ask Inkling to propose policies. One policy passes its original population but fails when the opponents change; later proposals turn out to be rewrites of a handwritten control. We finish with a bounded self-play prototype.

Read the essay →

09 / Bounded proofs

Löb's theorem with a budget

What happens when we bound the length of the proofs an agent can accept? I prove Critch's bounded Löb theorem in Lean and build a checker with the properties it needs. Two copies of DUPOC find a 3,007-character proof and cooperate. The same argument gives mutual defection against DIMCID under explicit proof-system assumptions, and points to a slip in one of the paper's examples.

Read the essay →

10 / Benchmarks

So, how fast is numerical computation in Lean?

I ran FloatLib on eleven benchmarks that weren't written by us. 281 of LLM2Cert's 291 proof obligations go through with a single by interval, all 39,994 floating-point conformance tests in SMT-LIB's Wintersteiger family are proved, and computing with 4,096-bit floats inside Lean's kernel is surprisingly cheap.

Read the essay →