An optical neural network trained in simulation does not, in general, work when the light is switched on. That is the field’s oldest embarrassment, usually stated as a calibration problem: every assembled device departs from its design through fabrication error, modulator response, misalignment, and aberrations, so a network that scores 98% in simulation can collapse to 35% on the experiment. The standard fixes are both expensive: build a calibrated digital model of each individual device — an expert’s job, device by device — and run backpropagation through it; or use gradient-free trial and error, which avoids the model but scales badly.

A team from Stanford and EPFL now reports a third route, and it is the more startling one. In a preprint posted to arXiv on November 18, 2026, Ilker Oguz, Colin Christian, Christophe Moser, Demetri Psaltis, and Gordon Wetzstein describe a coding agent — a large language model that writes and runs programs — training a physical optical neural network directly on the hardware, from camera images alone. No per-device calibration model. No gradients through the hardware. The agent, the authors report, took a three-digit optical classifier from 35% to 96.8% test accuracy, matching backpropagation through a calibrated model, and trained an optical image encoder that beat the gradient-free baselines.

This is a preprint, not a peer-reviewed result. It is also a small-network demonstration: a classifier over three handwritten digits, not a production system. Both facts matter, and neither cancels the interest. The interesting claim is not the accuracy figure. It is the mechanism — an agent that appears to form a working physical understanding of an optical system it was never given a model of, and then rewrites the network in terms a physicist would recognise.

The sim-to-real gap, stated plainly

The device is a folded-cavity optical neural network: light is reflected several times between a single phase-only spatial light modulator (SLM) and a mirror, with the phase masks displayed on the SLM acting as the network’s weights. The SLM is a Meadowlark Optics HSP1920-500-1200, 1,920 by 1,152 pixels — hundreds of thousands of pixels a naive optimiser would have to tune one by one.

That scale is what makes the conventional routes hurt. Backpropagation through a calibrated model reached 96.3% test accuracy, but only after a calibration that consumed about 67,000 camera images, plus many hours of GPU training. Gradient-free methods — proximal policy optimisation (PPO) and policy gradient, the standard tools when gradients are unavailable — raised the same classifier from 35% to only about 52% at best. The gap between the two baselines is the whole story of in situ training: the accurate route is expensive and expert-built; the cheap route stalls.

The agent’s headline number sits between them, and slightly above the expensive one. Given the notes and code of an earlier session — but no phase masks — the agent reached 96.8% test accuracy on the 3,147 test digits, against 96.3% for backpropagation through the calibrated model and at most about 52.5% for the gradient-free methods. That is the number to quote, with its qualification attached: the 96.8% run was not cold. Starting from the task description alone, with no earlier session to draw on, the agent reached 91.1%. One documented run’s validation accuracy rose from 35.5% to 91.0%. The honest reading is that the agent roughly matches calibrated backpropagation from scratch and slightly exceeds it when it can build on a previous session’s notes — still striking for a method that uses no model of the device at all, but the cold-start figure, not the best figure, is the one that generalises.

What the agent actually does

The harness is the paper’s central design choice, and it is deliberately restrictive. The agent can display phase masks and probes on the experiment and receives camera images back, along with scores and its own notes. Each request must carry a hypothesis — the agent has to say what it expects before it is allowed to measure. That single constraint forces the agent out of blind parameter search and into something resembling experimental practice: propose, predict, measure, revise.

What comes back from that loop is the paper’s most interesting claim, and the one that deserves the most scrutiny. The authors report that the agent “forms a physical understanding of the optics and reparametrizes the network with interpretable optical elements tuned on the hardware.” In practice, the agent stops trying to tune hundreds of thousands of SLM pixels individually and instead rewrites the network as a program built from lenses, prisms, and aberration terms — a handful of physically meaningful parameters — and tunes those on the hardware. On the classifier, the agent discovered a class-dependent routing strategy using a phase mask divided into 49 blocks, steering optical energy into detector regions according to the input digit.

A gradient-free method treats the device as a black box with a very large number of knobs. The agent, given the same black box, infers enough of its geometry — plane positions, magnifications, astigmatism, and tilt sensitivities, identified from its own probes and reported to agree with independent characterisation — to replace the knob-turning problem with a design problem. The paper reports that the agent inferred the optical system’s geometry from just 48 probe measurements. Against the roughly 67,000 calibration images the backpropagation baseline required, that is on the order of a thousand times fewer measurements — the “fraction of the cost” the abstract promises, made concrete. “Understanding” should not be taken too literally: the agent’s physical model is a working model, sufficient to design phase masks that perform on this device, not a complete or theoretically exact characterisation. But for training the network, a usable picture is what matters, and the agent built one from measurements alone, with no prior model of the optics.

Two details shape how far the result travels. First, the test set was sealed: the agent could not tune against the digits it was scored on. Second, the measurement budget was bounded — 51,200 measurements for the classifier and 25,600 for the encoder, at 0.107 seconds per measurement, or about an hour and a half for the full classifier budget. The agent is not given unlimited time on the hardware to stumble into a good answer; it spends its budget by designing rather than by searching.

The encoder: a second task, a different kind of evidence

A classifier result alone could be a fluke of one task’s structure. The paper’s second demonstration is an optical image encoder, and it matters because it is a different kind of problem. The same harness trains an optical system that compresses Fashion-MNIST images onto 16 detector regions of the camera — the optics playing the role of the latent space of an autoencoder — from which a small digital decoder reconstructs the image. Starting from random phase masks, the agent reached 16.1 dB test PSNR, against 15.0 dB for PPO and 13.8 dB for the random start, within 0.8 dB of backpropagation through the calibrated model (16.9 dB).

The encoder result is weaker than the classifier result in absolute terms — the agent does not beat the calibrated baseline here, it approaches it — and that is, paradoxically, reassuring. A method that beat the best baseline on every task would invite suspicion; a method that matches it on one task and approaches it on another, while beating the gradient-free methods on both, looks like a real capability with real limits. It also shows the harness is not a classifier trick: the same loop — probe, hypothesise, rewrite as interpretable optics, test on hardware — transfers to a task whose objective is reconstruction quality rather than a decision boundary.

What the paper does not report is also worth stating. The abstract names no dollar cost and no token count for running the agent, and it does not identify which language model was used. No cost figure should be inferred: “a fraction of the cost” in the abstract is a claim about measurements, not a priced comparison, and the agent’s own compute — the model calls behind every hypothesis and code revision — is unquantified in the public material. Nor does the paper report an energy-per-operation figure for the trained optical network. The energy case for optical computing rests on inference efficiency, and this paper is about training; no inference-energy number should be read into it.

Design agents are not training agents

Readers of this desk will recognise the shape of this story, and the distinction is worth drawing carefully. In October, this desk covered PhotonForge 2.0, Flexcompute’s platform that lets AI agents design photonic integrated circuits through code — agents working in a design flow, with simulation and verification behind them, producing layouts a foundry could build. That is agents designing hardware in software. This paper is agents training hardware in situ: the device already exists, on a bench, and the agent’s job is to make it compute correctly despite the ways it departs from its design.

The two ideas are complementary, attacking the same bottleneck from opposite sides. PhotonForge addresses the gap between a design that works in principle and one that can be built; optics as code addresses the gap between a device that has been built and one that performs. A photonic accelerator programme needs both. Neither paper demonstrates the full pipeline; together they sketch what it would look like — agents on both sides of the fab, one designing, one commissioning.

There is also a nearer comparison. Earlier this month, this desk covered the University of Tokyo and NTT’s state-skipping direct feedback alignment, a training rule that lets a physical system learn without recording its intermediate states. That work replaces backpropagation with a cheaper rule; this work replaces the training procedure with an agent. The Tokyo–NTT method is a defined algorithm with a defined cost. The agent method is, by the authors’ own framing, one that “improv[es] with more capable models” — tied to the frontier of language models, which is both its promise and its instability.

What would make this story matter

As with every photonic AI result this desk covers, the right response is a list of checkable developments, not a verdict.

First, a cold-start replication at the best number. The 96.8% figure is the headline, but it depended on notes from an earlier session. A from-scratch run that reaches the same accuracy — or a clear account of what the notes contain and why they matter — would settle whether the method’s ceiling is 91% or 97%.

Second, scale. Three digits is a toy task, chosen because it is small enough to run many times on hardware, and the authors do not pretend otherwise. The next demonstration should be harder: the full ten-digit MNIST set, or a task where the optics must do more than route three classes into three detector regions.

Third, a second device. The strongest claim in the paper is its most general one: that optics as code “requires only a way to set the parameters of a device and a way to observe its response,” making it a general tool for calibrating and optimising optical experiments. That generality is asserted, not shown — one folded-cavity system, one SLM, one lab. A demonstration on a different architecture, an integrated photonic chip rather than a free-space cavity, would test whether the agent’s physical understanding transfers or is specific to this setup’s forgiving geometry.

Fourth, a cost accounting. The measurement economy is real — 48 probes against 67,000 calibration images is a genuine thousand-fold difference — but it is only half the ledger. The agent’s language-model calls, the wall-clock time of a full run, and the failure rate across runs all belong in a serious comparison with the calibrated-model route, which is expensive in expert time but cheap and repeatable once built.

Until those appear, the paper belongs in a category this desk takes seriously but does not overclaim: a genuine advance in how physical systems are trained, demonstrated on real hardware, with its limits visible in its own numbers. An agent that can look at camera images of an optical device, work out how the optics behave, and rewrite the network in the language of lenses and prisms — reaching backpropagation-level accuracy without a model of the device or a gradient through it — is worth watching closely. Whether it is the practical route to large, scalable optical neural networks that its authors claim, or a clever harness that works best on small, forgiving systems, will be settled by the next experiments, not by this preprint.

Sources and further reading

Primary source: Oguz, I., Christian, C., Moser, C., Psaltis, D., and Wetzstein, G., “In Situ Training of Optical Neural Networks by Coding Agents,” arXiv:2611.23875 [physics.optics], submitted November 18, 2026, 14 pages, 4 figures, DOI: 10.48550/arXiv.2611.23875. The abstract is the source for the method, the harness, and the “fraction of the cost” framing; the accuracy, measurement, PSNR, and device figures are from the paper as reported in its project summary and figure captions. The abstract names no language model, dollar cost, or token count, and none is stated here. The preprint is not peer-reviewed. Related coverage on this desk: PhotonForge 2.0 (October 31, 2026) and the Tokyo–NTT state-skipping training paper (November 5, 2026).