tristanfaure.com /projects / pytorch-bis

Py-Allumette

From-scratch autodiff engine driving a differentiable MPC racing controller

2026 · ACADEMIC

Stack

Python · NumPy · Autodiff · MPC · pytest · GitLab CI

Key figures

Tests
51 — incl. PyTorch oracle
Engine
~24 ops, reverse-mode
Learned dynamics
R² 0.985
Best lap
15.30s, 0.176m max offset

A reverse-mode automatic differentiation engine written from scratch in pure Python/NumPy — an AST-scan compliance test bans 16 ML frameworks from the student code. Dynamic computation graph, broadcasting-aware backward, ~24 differentiable ops, Linear/MLP layers, and hand-written SGD and Adam.

The engine drives a differentiable MPC autonomous racing controller: a dynamic bicycle model rolled out on Tensors, the horizon cost backpropagated directly to the action sequence, projected gradient descent with warm starting. Hand-written Adam solves a control step to cost 1.94 where SGD oscillates around 90.

Learned residual dynamics: a 7→64→64→6 MLP trained on 500 collected samples corrects a deliberately-wrong nominal model — R² 0.985, residual RMSE 0.0178 → 0.0020, and a 1-second open-loop rollout matching the true plant to 0.001 m/s.

Closed-loop result on a 34.4 m track (1:43-scale car): the learned controller laps in 15.30 s with the tightest max track offset of all variants (0.176 m).

Verified like a real framework: 51 tests, every op gradient-checked against three finite-difference schemes and a PyTorch reference oracle; 7-stage GitLab CI with coverage; a written report with honest failure analysis (why the learned model was initially slower). Team of 3.

Links

All 33 projects · Open the interactive portfolio · About Tristan