In Situ Training of Optical Neural Networks by Coding Agents
Ilker Oguz, Colin Christian, Christophe Moser, Demetri Psaltis, Gordon Wetzstein
Stanford University · EPFL
Published November 18, 2026 · on the feed November 20, 2026 · ▲ 3 · arXiv 2611.23875
The abstract
Optical neural networks promise fast, energy-efficient computing, but every device departs from its design and must be trained with the hardware. In situ training relies on an expert-built calibrated digital model of each device or on gradient-free trial and error. Coding agents, large language models that write and run programs, have shown an emergent ability to understand and edit the weights of digital neural networks. Here we introduce optics as code, a method in which a coding agent trains an optical neural network from measurements alone, through a harness that returns camera images of its probes and requires a hypothesis per request. We discovered that the agent forms a physical understanding of the optics and reparametrizes the network with interpretable optical elements tuned on the hardware. It outperforms gradient-free methods in classification and image encoding, approaching backpropagation through a calibrated model at a fraction of the cost. Needing neither per-device calibration nor gradients through the hardware, and improving with more capable models, optics as code offers a practical route to large, scalable optical neural networks and a general tool for calibrating and optimizing optical experiments.
The Brief
2:01A short podcast summary of the paper. Written and voiced by AI.
Transcript
In Situ Training of Optical Neural Networks by Coding Agents. By Ilker Oguz and four others, from Stanford University and EPFL. Published on the eighteenth of November.
Optical neural networks promise computing that is fast and energy-efficient. The catch is that every physical device departs from its design, so each one has to be trained together with the hardware itself. Today, that in situ training leans on one of two things. Either an expert builds a calibrated digital model of each individual device, or the training falls back on gradient-free trial and error. The first is costly per device. The second gives up the guidance that gradients would offer.
The starting observation comes from elsewhere. Coding agents, meaning large language models that write and run programs, have shown an emergent ability to understand and edit the weights of digital neural networks. Optics as code asks the same of an optical one. A coding agent trains the optical network from measurements alone, with no calibrated model standing in for the device.
The agent works through a harness. When it probes the hardware, the harness returns camera images of those probes, and every request the agent makes must come with a hypothesis. That requirement shapes what the agent does. The authors found that it forms a physical understanding of the optics, and then reparametrizes the network using interpretable optical elements, which it tunes directly on the hardware. Rather than adjusting opaque numbers, it ends up describing the system in terms of optical parts it can reason about.
On classification and on image encoding, the agent outperforms gradient-free methods. It also approaches the results of backpropagation through a calibrated model, while costing only a fraction as much. And the method improves as the underlying models become more capable.
The two usual requirements both drop away. There is no per-device calibration, and no gradients have to pass through the hardware. On that basis the authors present optics as code as a practical route toward large, scalable optical neural networks, and more broadly as a general tool for calibrating and optimizing optical experiments. The measurements, and an agent obliged to explain itself, do the work that a hand-built model used to.
More with an account
Listen to every day’s papers
Daily playlists, deep dives, quests for the papers, and quizzes on their key terms.
Join free