Fourier Optics for Training — Presentation 02

Optical Backpropagation and In-Situ Training

The question turned around: how is optical hardware itself trained, and what does that teach about putting optics in an LLM training loop? In-silico training and the reality gap, the adjoint method, physics-aware training, direct feedback alignment, forward-only methods, analogue noise and a measured case of it inside DeMo's feedback loop, the ADC precision a training format asks for, and a live experiment that trains one distorted filter three ways.

Reality gap Adjoint method Physics-aware training DFA Forward-only FP8 gradients Error feedback
Physical parameters → Forward on hardware → Gradient: measured or modelled → Update → Calibrated engine
00

Topics We'll Cover

Concepts used here, and where they are explained. Each links to a glossary entry: this series glossary, or the Fourier Optics for Inference glossary for the physics and precision concepts that series already explains.

01

The Question, Turned Around

Deck 01 asked whether a Fourier-optical engine could take over part of an LLM training step, and found the share small: 0.15% of a step for a Hyena-2 model at 4,096 tokens, 12.19% with block-circulant weights (results.md §2). In that picture the LLM's weights live in digital memory, the optimizer is digital, and the engine computes fixed transforms on values it is handed.

This deck asks the other question. The optics has parameters of its own: phase shifters in a mesh, pixels on a mask, the alignment of a lens. How are they set, when no digital model of the hardware is exact? Photonic-computing research has answered this in several ways, each with a different answer to “who computes the gradient”:

ApproachWho computes the gradientSlides
In-silicoA digital model, before the hardware exists03
In-situ backpropagationThe hardware, by interfering forward and adjoint fields04–05
Physics-aware trainingA digital twin, fed the hardware's real outputs06
Direct feedback alignmentA fixed random projection of the error (done optically)07
Forward-only methodsThe hardware, from forward passes alone08

The lesson for an LLM engine comes at the end (slide 14): these methods matter for calibrating the engine's own parameters, not for training the LLM. The physics of meshes, SLMs and detectors is in FOptInf 01 and is not repeated here.

02

Why Training Optics Differs from Training Digital

Backpropagation on a GPU rests on three assumptions that optical hardware breaks: the forward function is known exactly, every intermediate value can be stored and read back, and a weight can be written to the precision the optimizer asks for.

Digital trainingTraining optical parameters
Forward functionExactly the codeA physical process: fabrication error, crosstalk, loss, temperature drift. A model of it is approximate
Intermediate valuesStored activations, read back for the backward passFields inside a mesh or at a Fourier plane, visible only through detectors that measure intensity, not phase (the phase problem)
GradientComputed by the chain ruleMust be measured on the hardware, modelled by a twin, or avoided
Parameter writesAny float, any timeA heater current or SLM pixel with finite resolution and settling time
Read-outExact to the number formatAn ADC at finite ENOB, plus noise

Two kinds of error result, and they behave differently in training. Systematic error (the model is wrong) biases every gradient the same way; random error (read-out noise) mostly averages out over steps. The rest of the deck is about which method copes with which, and the experiment on slide 12 shows both.

03

In-Silico Training and the Reality Gap

The simplest method: train a digital model of the optics, then build or program the hardware with the result. Lin et al.'s diffractive deep neural network (D²NN) did exactly this: layers of diffractive elements whose transmission was trained in simulation, then 3D-printed and run at terahertz frequencies as a handwritten-digit classifier and an imaging lens (Lin et al., Science 361, 1004, 2018). Training was entirely digital; the optics only ran inference.

Digital model → Train (backprop, on a computer) → Fabricate / program → Run on the real optics

It works when the model is good, and it is the only option for a passive, fabricated device. Its weakness is the reality gap: the trained parameters are optimal for the model, not for the hardware. Misalignment between layers, fabrication tolerance, material absorption and detector response all move the real device away from the model, and nothing in the training loop sees it.

The reality gap does not shrink with more training

In-silico training converges to the model's optimum. More steps, a better optimizer or a bigger batch only get closer to that point; the error from the mismatch stays. The only fixes are a better model or putting the hardware in the loop. The experiment on slide 12 shows the plateau.

04

The Adjoint Method: Gradients by Interference

Hughes, Minkov, Shi and Fan showed that a reciprocal photonic circuit can measure its own gradient (Optica 5, 864, 2018). The adjoint method, long used for inverse design, says the derivative of a loss with respect to a phase shifter depends only on the forward field and the adjoint field at that shifter. The adjoint field is what you get by sending the output error backwards through the same circuit; reciprocity makes that the transpose the chain rule needs.

input x MZI mesh (reciprocal) MZI φ_i MZI MZI y, loss L error ∂L/∂y 1. forward: E_fwd, record |E_fwd|² at every φ 2. adjoint: error sent back from the outputs, record |E_adj|² monitor at φ_i 3. input + time-reversed adjoint: record |E_fwd + E_adj*|² ∂L/∂φ_i ∝ Re(E_fwd·E_adj) = ½(|E_fwd + E_adj*|² − |E_fwd|² − |E_adj|²)

Because detectors measure intensity, the cross term is recovered from three intensity measurements at each phase shifter: the forward field, the adjoint field, and the two interfering. The gradient for every phase shifter comes out of the same three passes, in parallel, as the chain rule's dot product does on a GPU. What the method asks for is reciprocity, coherent sources that can inject a chosen adjoint field, and an intensity monitor beside every parameter.

The identity |a + b*|² = |a|² + |b|² + 2 Re(a·b) is what turns three intensities into the product of two fields. Sign and scale constants are in the paper.

05

In-Situ Backpropagation, Demonstrated

Pai et al. implemented the scheme on a programmable silicon-photonic MZI mesh and trained small classifiers with gradients measured on the chip (Science 380, 398, 2023). The hardware computed its own gradient, so whatever the chip actually does, the gradient is of that, not of a model of it.

What it buys

  • No reality gap in the gradient: fabrication error and crosstalk are inside the measurement
  • Gradients for all parameters from a fixed number of passes, not one perturbation per parameter
  • Training can continue as the device drifts

What it costs

  • Several hardware passes per sample (forward, adjoint, interference), each read out at finite ENOB
  • A monitor beside every parameter, and coherent injection of the adjoint field
  • Nonlinearities between optical layers handled outside the optics
  • Demonstrated at small scale: a mesh of a few ports, not a megapixel mask

What it would mean in a 4f system (this deck's analysis)

In a 4f engine the parameters are the Fourier-plane mask pixels. For y = h ∗ u, the gradient with respect to the mask H is G·conj(U), the filter gradient of deck 01's correlation rule. An adjoint pass would put the error spectrum and the input spectrum at the same plane, so a coherent camera there could measure the data-by-data product that deck 01 said could not sit on a mask. It needs phase-sensitive detection at every pixel (the phase problem) and is speculation: no such measurement at LLM scale has been published.

06

Physics-Aware Training

Wright et al. proposed a hybrid: run the forward pass on the physical system, and the backward pass through a differentiable digital model of it (Nature 601, 549, 2022). They trained three different physical systems this way: broadband optical second-harmonic generation, a mechanical oscillating plate, and an analogue electronic circuit.

Forward: real hardware → Real output, real error → Backward: digital twin → Update the physical parameters
When it breaks

For a linear filter the 90° condition is per frequency: physics-aware training converges if the twin's phase error stays below 90° at every frequency, and stalls or diverges where it does not. The experiment on slide 12 computes the worst phase error of its hidden distortion live; push the distortion until it passes 90° and watch the physics-aware curve fail while the in-situ curve does not.

07

Direct Feedback Alignment and the Optical Random Projection

Direct feedback alignment (DFA) drops the backward pass altogether. Each hidden layer receives the output error multiplied by its own fixed random matrix, instead of the error backpropagated through the transposed weights; the forward weights learn to align with the feedback (Nøkland, NeurIPS 2016, arXiv:1609.01596).

Backpropagation

δl = (Wl+1T δl+1) ⊙ f′(al): sequential, layer by layer, through the transposed forward weights.

DFA

δl = (Bl e) ⊙ f′(al): every layer at once, from one fixed random Bl. No weight transport, no model of the forward path.

The fixed random projection B e is a large dense matrix multiply that never changes, which is what light through a scattering medium computes: a fixed random transmission matrix, applied in one pass, read out by a camera. Launay et al. built a photonic co-processor that does this projection and trained networks with DFA on it (arXiv:2012.06373, 2020).

The catch

The projection needs no calibration because it only has to be fixed, not known: an elegant fit for optics. But DFA is a different learning rule, and its accuracy trails backpropagation on harder tasks; published evidence that it matches backpropagation when training large transformers is lacking. For LLM training, the optical part is a random matrix multiply, not a Fourier transform, and the method changes the algorithm the model is trained with.

08

Backprop-Free and Forward-Only Training

Two 2023–2024 results train physical systems without any digital backward pass and without a model of the hardware:

Local, forward-only learning

Momeni et al. train each physical layer with a local objective computed from forward passes alone, in the spirit of Hinton's forward-forward algorithm, and demonstrate it on acoustic, microwave and optical systems (Science 382, 1297, 2023). No error is propagated between layers; no layer needs a model of the others.

Fully forward mode

Xue et al. use spatial symmetry and Lorentz reciprocity so that the backward propagation of the error can itself be carried out as a forward propagation through the physical system, measured rather than modelled, in free-space and integrated optical networks (Nature 632, 280, 2024).

09

Analogue Noise in a Training Loop

Stochastic gradient descent already lives with noise: a minibatch gradient is a noisy estimate of the full one. What matters about analogue error is not its size alone but whether it is zero-mean.

ErrorExampleIn the forward passIn the gradient
Zero-mean, independentADC quantisation with dither, shot and thermal noiseActs like injected noise; training tolerates it, and noise injection is a known regulariserAdds variance to the minibatch noise; averages out over steps, at a cost in convergence speed
Biased, systematicGain and phase error, saturation, offset, crosstalk, a mis-modelled twinThe model computes a different function; in-silico training never sees itShifts every gradient the same way; does not average out; moves the converged point
Slow driftTemperature, laser power, SLM ageingBiased within a window, changing across windowsTracked by in-loop training; must be recalibrated otherwise

The same distinction appears in low-precision digital training: rounding every update to nearest loses updates smaller than half a step, a biased error, while stochastic rounding is zero-mean and keeps them in expectation (Gupta et al., ICML 2015, arXiv:1502.02551). For analogue parameter writes, the same holds: an SLM pixel or heater with finite resolution silently drops updates below its step unless the master copy of the parameter is kept digitally.

A real case. In the Compute in Transit experiment (a 15.8M-parameter GPT on TinyStories, 8 simulated workers), emulated analogue optics computed DeMo's fixed DCT band while error feedback removed the exact band. All six runs of that first design diverged, to final losses of 11.153–558.834 against 3.124 for the band computed exactly, and ENOB 12 ended worse than ENOB 6. The cause was bias: quantisation and clipping errors that repeated every step and were never fed back. Feeding back the band actually sent fixed it. The details are on the next slide.

So, calibrate the bias; average the noise

Read-out noise sets a floor on what the deployed engine can deliver (the dashed line on slide 12), but within a training loop it mostly washes out. Bias is what training on the wrong model cannot fix. Repeated passes cut random noise by √k (averaging) and do nothing for bias.

10

A Measured Case: Optics Inside DeMo's Feedback Loop

The Compute in Transit experiment (CiT 04) put an emulated analogue transform inside a real training loop. It trained a 15.8M-parameter GPT (15,833,472 parameters, 8 layers, width 384) on TinyStories with 8 simulated workers for 3,000 steps, using DeMo (glossary): each worker DCT-transforms its update in 256-point chunks and sends only a fixed frequency band, one coefficient in sixteen. Variant E computed that band with an emulated optical transform modelled on a photonic link module (Kundu et al., arXiv:2608.21536): each value quantised against a full scale into P binary bit planes, each plane through the transform with read-out noise at a given ENOB, the planes recombined. Variant C computed the same band exactly.

momentum m_t + Δ_t emulated optics FS = κ·RMS(Δ), κ = 4 P bit planes, DCT band, ENOB noise b̂_t sentall-gather (own too) residual e_t+1 = Δ_t − band kept, decaying ×0.999 per step next step fix: − b̂_t (the band sent) first design: − b_t (exact band)

Error feedback is what makes a compressed update work: the delta Δt = mt + et is the momentum plus everything not yet sent, the band is removed, and the rest stays in the residual, decaying only by 0.999 per step. DeMo then applies the sign of the update. The optics' input range was set as full scale = κ·RMS(Δ) with κ = 4, measured over calibration steps 200–299 and then either held fixed or re-set every 100 steps from the delta's mean square. As first designed (full scale fixed, the exact band fed back), all six E runs diverged while C trained:

E runFirst design: final loss (clip rate)Band sent fed back: final loss (clip rate)
ENOB 6, 8 planes11.153 (22.59%)3.423 (0.28%)
ENOB 8, 8 planes214.647 (45.80%)3.017 (0.29%)
ENOB 10, 8 planes42.183 (24.93%)2.878 (0.30%)
ENOB 12, 8 planes336.981 (57.50%)2.905 (0.30%)
ENOB 8, 4 planes344.388 (56.52%)3.137 (0.22%)
ENOB 8, 12 planes558.834 (54.57%)3.024 (0.30%)
C, exact band (3 seeds)3.124 ± 0.008

Final validation loss at step 3,000, clip rate over the whole run; one seed per E run. Source: CiT experiment results.md §1 and §3, plotted on the results site; the repaired runs re-set the full scale every 100 steps.

Why it diverged

  • Not noise: ENOB 12 ended worse than ENOB 6 (336.981 against 11.153), and 12 planes worse than 8.
  • A stale full scale: the band is removed every step and the residual keeps growing, so the band's share of the delta's energy falls from 1.4–2.3×10−3 at step 200 to 1.6–1.8×10−5 at step 3,000. A full scale fixed at the end of calibration saturates: the clip rate jumped from about 1% (steps 300–400) to 35–51% (steps 400–600).
  • A bias: the residual changes slowly, so quantisation and clipping errors repeat almost identically every step. The sender believed it had sent the exact band; every receiver applied the optics' version; the difference was never corrected. Because DeMo applies the sign, a consistent error moves every weight a full step the wrong way, step after step.

The fix

  • Feed back the band actually sent. In an all-gather every worker receives every worker's values, its own included, so the sender sees what the optics produced, errors and all, and removes that from its delta (the loop).
  • Every repaired run trains, final loss 2.878–3.423, with about 0.3% of inputs clipped.
  • Re-setting the full scale then adds nothing: 3.017 with it, 3.021 with it fixed (ENOB 8), where 1.34% clip but the clipping error is fed back like any other.

The diagnosis was isolated on the CPU with TinyShakespeare runs (4 layers, width 128, 600 steps): the first design reached 8.809 against 2.464 for the exact band; re-setting the full scale with the exact band still fed back gave 3.404; removing the read-out noise entirely still left 2.967; feeding back the band sent gave 2.520–2.535. Quantisation and clipping errors that were never fed back were enough to break training. Source: CiT experiment optics_investigation.md §1–4.

Bias, not noise

This is the “biased, systematic” row of slide 09, measured: more ENOB did not help because the damage was a repeated error, not a random one. The cure was not better optics but closing the loop on what the optics actually did, the same lesson as hardware-in-the-loop training (slide 06). Precision then matters again, on the next slide.

11

Precision for Training Formats

Mixed-precision LLM training keeps activations and weights in BF16 or FP8 E4M3 and gradients in FP8 E5M2, which trades mantissa bits for range (Micikevicius et al., “FP8 formats for deep learning”, arXiv:2209.05433: E4M3 reaches 448, E5M2 57,344). An analogue engine in that loop need not be exact; its read-out should add no more error than the format's own rounding. The inference series' noise rule, relative error = crest × 2−ENOB × 2/√12, applied to a 4,096-sample long convolution and its two gradients:

SignalCrest factorENOB for BF16FP8 E4M3FP8 E5M2
Forward y3.5510.36.35.3
Gradient dU (input)3.7210.36.35.3
Gradient dH (filter)4.9210.76.75.8

Source: results.md, §5. The gradient signal carries rare spikes (1% of samples ×4, an illustrative model of gradient outliers), which raise the crest factor.

Measured in a training loop. The repaired runs of slide 10 (band sent fed back, full scale re-set every 100 steps) show what ENOB and how many bit planes an LLM training loop needed, at one size: a 15.8M-parameter GPT on TinyStories, 8 simulated workers, one seed per optics run.

RunFinal lossSteps to 3.158
ENOB 6, 8 planes3.423never
ENOB 8, 8 planes3.0171,800
ENOB 10, 8 planes2.8781,600
ENOB 12, 8 planes2.9051,800
ENOB 8, 4 planes3.1372,600
ENOB 8, 12 planes3.0242,000
Perfect optics (control: no quantisation, no noise)3.1412,800
C, exact band (3 seeds)3.124 ± 0.0082,667

Source: CiT experiment results.md §1 (final loss; steps to 3.158, the 2-D fixed band's final loss, evaluated every 200 steps) and §3; CiT simulation results.md §7c. On the results site: ENOB and bit planes, repaired.

Hypothesis, single seed

From ENOB 8 up, the repaired optics band ends below the exact band it emulates: 2.878 at ENOB 10 against 3.124 ± 0.008. A hypothesis from the experiment's notes, untested: quantisation and clipping are non-linear, so the values sent carry a little of the large out-of-band residual, and feeding them back lets some out-of-band information reach the model. Against it: every optics run is a single seed, and on TinyShakespeare the repaired optics ended slightly above the exact band (2.520–2.535 against 2.464) (results site). Either way it does not rescue the fixed band: the best optics run, 2.878, is still 1.09 above top-k's 1.785.

12

Interactive: Three Trainers, One Distorted Filter

The “hardware” is a 1-D causal convolution with a hidden fixed distortion: a short kernel (equivalently a per-frequency gain and phase error) and a tanh saturation, read out with zero-mean noise at the chosen ENOB. The task: learn a 16-tap target filter by gradient descent. Three trainers see the same inputs:

0.50
6
0.10
200
In-silico
—
Physics-aware
—
In-situ
—
Worst phase error
—
in-silicophysics-awarein-situread-out noise floor at this ENOB

Illustrative toy, computed live in your browser with a seeded PRNG (results are reproducible). Defaults: distortion 0.5, ENOB 6, learning rate 0.1, 200 steps, seed 7. Setup: 64-sample sequences of Gaussian input, 8 per step, plain SGD from a zero filter; ADC full scale ±4× the target's RMS; the in-situ gradient read-out is auto-ranged to its own peak. Metrics are the hardware loss (normalised MSE) averaged over the last 10 steps, on 4 fixed evaluation sequences with the noise-free hardware; the dashed line is the read-out noise alone, which deployment adds on top.

13

The Methods Compared

MethodWho computes the gradientNeeds a model?Hardware passes per stepScaling evidence
Digital backprop (reference)The chain rule, on stored activationsThe code is the modelNone; backward costs about 2× forward (the 6N rule)Every LLM
In-silico (D²NN)A computer, on a model of the opticsYes, and it must be accurateNone while training; the hardware only runs the resultFabricated diffractive networks on small vision tasks (Lin 2018)
In-situ backprop (adjoint)The hardware, by interferenceNo; needs reciprocity, adjoint injection, monitors at every parameterForward, adjoint and interference passes per sampleSmall MZI meshes (Pai 2023)
Physics-awareA digital twin, on the hardware's real outputsYes, differentiable but approximateOne forward pass per sampleThree different physical systems on small tasks (Wright 2022)
DFA, optical projectionFixed random projection of the output errorNo: the projection must be fixed, not knownOne projection per sample, plus the forward passPhotonic co-processor (Launay 2020); lags backprop on harder tasks
Forward-onlyThe hardware, from forward passes (local objectives, or a reciprocal mirror of the backward pass)NoTwo or more forward passes per sampleOptical, acoustic, microwave demonstrations (Momeni 2023; Xue 2024)

Two axes separate them: how much of the gradient comes from the real device (in-silico none, physics-aware the error only, in-situ and forward-only all of it), and whether the learning rule is still backpropagation (DFA and local learning change it). Only methods that keep backpropagation and take the gradient from the device remove both the reality gap and the algorithm risk; they are also the ones that ask the most of the hardware.

14

What Maps onto an LLM-Scale Transform Engine

The engine of deck 01 computes fixed transforms (FFTs and Fourier-domain products) on values it is handed. The LLM's weights, master copies and optimizer stay digital; a weight spectrum is written to the mask once per step and read back by nothing. So the training methods in this deck are not a way to train the LLM. They matter for the engine's own parameters: the transfer function of its lenses, mask pixels and detectors.

What carries over

  • Calibration is training. Fitting a correction so the engine computes the transform the digital code assumes is a small in-loop training problem: probe inputs, measured outputs, a fitted correction.
  • Hardware in the loop beats a model. Characterise the engine on the engine (in-situ or physics-aware style), not only from its design (in-silico), or the reality gap appears as a bias in every forward and backward pass.
  • Bias versus noise. Calibrate gain, phase, offset and saturation; tolerate zero-mean read-out noise at the format's ENOB (slide 11). Where the engine sits inside an error-feedback loop, feed back what it actually produced (slide 10).
  • Drift. Recalibration has to run during a long training job, between optimizer steps.

What does not

  • The LLM's gradients are computed digitally by the chain rule, with the engine doing some of the transforms; nothing here replaces that.
  • DFA and forward-only rules change the learning algorithm, a risk no LLM training run will take for a 0.15% FLOP share.
  • In-situ measurement of the weight gradient (slide 05) is the one speculative bridge: it would measure the data-by-data product optically, but needs coherent detection at megapixel scale.
The physics-aware lesson, applied (speculation)

If the engine computes the forward and backward transforms of an LLM layer and the digital side computes the chain rule as if they were exact, the LLM itself is being trained physics-aware style: real (distorted) outputs, idealised gradients. The experiment shows that converges while the per-frequency phase error stays well inside 90°, and that the residual error is set by the bias, not the noise. That gives a calibration target for an engine in a training loop. This mapping is the author's own analysis, attributed to no company.

15

What to Take Away