01 What to automate, and at which timescale
Automation is a stack of loops. Each one senses something, decides, and acts, and each closes at its own speed. The fast loops are electronics; the slower ones are scripts on the control PC; the slowest are optimisers and, since 2024, AI agents. A loop belongs at the slowest level that still keeps up with the disturbance it fights.
Blue: electronics. Teal, amber and violet: software on the control PC. Bars show orders of magnitude for one pass round each loop, not limits. A PDH lock corrects in microseconds; a resonance recalibration takes a few minutes of shots; an optimisation run can take a night.
What you do by hand every day
Relocking a laser, re-peaking a fibre, checking a resonance, re-measuring a π-pulse. These are well understood, easy to verify, and they eat hours of student time. Automating them also makes the data more consistent, because the check is done the same way every time.
What can break hardware
Coil currents, high laser powers, RF amplifiers, vacuum valves and anything that heats. Limits for these belong in hardware (interlocks, current limits, thermal switches), with software limits on top. A loop that rails at full scale must fail safe, not try harder.
What you do not understand
An optimiser maximises the number you give it, including its flaws. If the "atom number" can be inflated by a background count, a saturated camera or a mis-set threshold, the optimiser will find that first. Understand the measurement before you let a machine push on it.
02 Feedback and feedforward: holding a laser's power
The first servo most students build. A photodiode samples the beam after the AOM, a servo compares it with a setpoint and adjusts the AOM's RF amplitude. Feedback corrects whatever it sees, but only after it sees it and only up to its bandwidth. Feedforward acts before an error appears, but only on what you can predict or measure, and only as well as it is calibrated. Real systems use both.
Power-servo simulator
50 ms of a beam whose laser power has mains ripple, slow drift, a sudden 8% drop at 20 ms and fast noise. The setpoint holds, then ramps up at 30 ms. Grey: what reaches the atoms with no control. Coloured: with your servo.
Simulated in the page at 0.25 µs steps. Laser power: 3% mains ripple, slow drift of about 2%, an 8% drop at 20 ms, 0.3% fast noise. Photodiodes: 0.1% noise. The AOM is a 0.5 µs first-order response after the loop delay, and its transmission is clamped between 0 and 1. The pick-off feedforward assumes a 5% calibration error. The numbers are illustrative; the behaviour is general.
- Sample the light where the atoms are. After the fibre, if there is one; fibre coupling and polarisation drift change the power after the AOM.
- The loop is only as quiet as its photodiode. Sensor noise is written onto the beam. Check with a second, out-of-loop photodiode: the in-loop one always looks good.
- Delay sets the bandwidth. A pure integrator with a total delay τ goes unstable near f ≈ 1/(4τ), where the delay has used up its 90° of phase margin. Cables, the acoustic travel time in the AOM and digital processing all count.
- Leave headroom. Run the AOM below full diffraction so the servo can push up when the laser sags. At the limit the servo saturates and the power simply follows the laser.
- Pulsed beams. A servo cannot regulate light that is off. Use a sample-and-hold (servo while on, hold the drive while off) or a digital loop that measures each pulse and corrects the next shot.
- Which actuator. Feeding back to a diode laser's current also moves its frequency, so the AOM is the usual actuator. An EOM between polarisers ("noise eater") is faster still.
- Setpoint feedforward is a calibration table: measured power against AOM drive. Then a ramp is followed immediately and the servo only cleans up the residual.
- Digital or analog. FPGA servos (ARTIQ's SU-Servo combines ADC, servo and DDS amplitude in one loop) make the setpoint part of the sequence; analog PI boxes are simpler and have less delay.
03 Fields, frequencies and the mains
The same two ideas, feedback for what you cannot predict and feedforward for what you can, hold magnetic fields and laser frequencies steady. The mains is the textbook case for feedforward: its noise repeats every cycle.
Feedforward on the mains: a trapped-ion example
Merkel et al. stabilised a 14.6 mT field for a 43Ca+ clock qubit with a fluxgate sensor in a feedback loop, then added feedforward that cancels the 50 Hz mains harmonics. Qubit coherence time, from their Ramsey measurements:
Values from Table II of Merkel et al., arXiv:1808.03310. Their abstract quotes 4.3 nT rms (0.29 ppm) for the stabilised field against more than 100 nT without stabilisation; the coherence time improved 25-fold.
- Line triggering. Start every shot at the same phase of the mains. The residual 50/60 Hz field is then the same in every shot, so it shifts a resonance by a fixed amount you can calibrate, instead of broadening it.
- Laser frequency, fast. A PDH lock cannot suppress noise above its bandwidth. Chao et al. fed the PDH error signal forward to the light after a delay fibre and report phase-noise suppression around a few MHz about four orders of magnitude better than PDH feedback alone (Optica 2024). An adaptive version reports ≥40 dB around 2 MHz with up to 50 MHz bandwidth (preprint).
- Laser frequency, slow. A software loop reads a wavemeter or a reference cavity and nudges a piezo or setpoint every second or so. It keeps a laser in range for the fast lock; see the laser locking guide.
- Fields from known sources. If your own sequence switches a nearby coil, its stray field arrives at a known time. Feed the expected change forward to the compensation coils rather than waiting for the magnetometer to see it.
04 Keeping beams pointed: quadrant detectors and auto-alignment
Beams wander as the lab warms and cools, as mounts relax and as air moves. A position-sensitive detector turns that wander into an error signal and a piezo-driven mirror turns it back. The same hardware, with a smarter loop, can re-couple a fibre on its own.
A quadrant photodiode as an error signal
Drag the spot. The four quadrant signals give a horizontal error X = [(A+D) − (B+C)] / Σ and a vertical error Y = [(A+B) − (C+D)] / Σ, while Σ itself is the total power. Turn on drift to see the beam wander, then lock it.
For a Gaussian spot of 1/e² radius w on an ideal split detector, X = erf(√2·x/w): linear only for displacements well below w, then saturating at ±1. A small spot is sensitive but has a short range; a large spot the reverse. Detector size is in units of the half-width of the detector; gaps between quadrants are ignored.
A beam has a position and an angle in each transverse direction. One detector sees position; a second placed at the focus of a lens sees angle. Two detectors and two piezo mirrors close all four loops. One detector and one mirror only fixes the spot at the detector, and may tilt the beam elsewhere.
Closed-loop beam stabilisers (MRC Systems is a well-known example) combine piezo-driven steering mirrors with four-quadrant diodes and a controller. They are common in front of long beam paths, high-power fibres, SLMs and AODs, where a small angle becomes a large shift of a tweezer array.
When you only care about the throughput (a fibre), use the throughput itself: a photodiode after the fibre and motorised mirror mounts, driven by a search or an optimiser. Slower, but it optimises exactly what you need.
Automatic fibre coupling: three published approaches
| Approach | Hardware | Method | Reported result |
|---|---|---|---|
| Model-based (Geng et al., 2024) | Two 2D position-sensitive detectors, two piezo mirror mounts, a microcontroller | A linearised geometric model of the beam path, run as a state machine | Recovers the maximum coupling in about 10 s, even from a beam misaligned to zero coupling preprint |
| Optimiser (Mathew et al., 2020) | Stepper motors on the knobs of two kinematic mounts, a photodiode after the fibre, a Raspberry Pi | Gaussian-process optimiser (M-LOOP) | About 20 minutes for 200 runs; coupling as good as, or slightly better than, an experienced experimenter |
| Reinforcement learning (Richtmann et al., 2024) | Motorised mirror mounts with backlash and lost steps | Model-free RL agent trained on the real setup | 90% coupling, comparable to a human expert; training took nearly four days at about one second per step preprint |
05 Auto-relock and calibration loops
The most valuable automation in most labs is unglamorous: noticing that a lock has dropped, relocking it, and re-measuring the parameters that drift. Done well, it turns a machine that needs a student watching it into one that runs overnight.
- Cavity transmission or a beat note drops below a threshold.
- The error signal's rms grows, or the integrator output approaches its rail (it will soon run out of range even if still locked).
- A wavemeter reading leaves its window.
- The atoms tell you: fluorescence or loading rate collapses. Treat this as a symptom to diagnose, not as a lock signal on its own.
- Flag, don't average. Every shot records the lock state of every laser; shots taken while anything was unlocked are marked bad, not silently averaged in.
- Log every relock. A laser that relocks ten times a night is telling you something about its temperature or its current.
- Give up gracefully. A relock script that keeps trying forever can drive a laser to a mode hop or a piezo to its limit.
Calibrations worth running on a schedule
| What drifts | Calibration experiment | What the script updates |
|---|---|---|
| A transition frequency (field drift, light shifts) | Short spectroscopy scan across the line, fit the centre | The detuning parameter used by every later experiment |
| Rabi frequency (beam power, pointing, polarisation) | Rabi flop or a pulse-length scan, fit the period | The π-pulse time or amplitude |
| Bias magnetic field | Microwave or Raman spectroscopy on a field-sensitive transition | Compensation-coil setpoints |
| Tweezer-to-tweezer uniformity | Per-site light shift, loading or trap-frequency measurement | Per-tone amplitudes on the AWG (see the tweezer designer) |
| Imaging threshold | Histogram of counts per site, fit the two peaks | The atom/no-atom threshold for each site |
06 Workflow: optimising one stage of the experiment
Say the tweezer-loading probability has dropped and you want to re-optimise the stage that loads atoms from the MOT into the tweezers. The steps below work for any stage, with or without machine learning.
- Define one number to maximise, measured at the end of the stage you are tuning (loading probability, atom number, temperature, survival). If you care about two things, combine them deliberately, for example atom number with a penalty above a temperature limit.Why: the optimiser will maximise exactly this number, flaws included (Section 01).
- Measure the noise of that number. Repeat the current settings 10–20 times. For a loading probability p from N shots the statistical error is √(p(1−p)/N): about 5% at p = 0.5 with 100 shots per point.Why: if two settings differ by less than this, no optimiser can tell them apart. It sets how many shots each point needs.
- Choose the parameters and safe bounds. Detunings, intensities, field gradients, durations. Start with the few you believe matter; bound each so that every combination is safe for the hardware.Why: cost grows with the number of parameters, and an optimiser will try the corners of the box.
- Freeze and monitor everything else. Lock states, laser powers, fields and the lab temperature should be logged alongside every shot.Why: a drift during the run looks to the optimiser like a change in the landscape.
- Look before you optimise. One-dimensional scans of each parameter around the current point show which ones matter and how smooth the landscape is.Why: if a 1D scan already finds the problem (a detuning off by a linewidth), you are done.
- Run the optimiser with reference points. Every so often re-measure the original settings.Why: if the reference drifts, the experiment changed under you, and the run must be corrected or restarted.
- Validate the winner. Re-measure the best settings many times, interleaved with the old ones. The best single measurement in a noisy run is biased high (the "winner's curse").Why: the improvement you report should survive a fair comparison.
- Understand it. Look at what the optimiser changed, and use its model of the landscape (if it has one) to see which parameters are sensitive.Why: a surprising optimum often reveals a misaligned beam or a wrong calibration, which is worth more than the gain itself.
- Write it down and schedule it. Commit the new values with a note (see control systems: git). If the optimum drifts, turn the stage into a periodic calibration (Section 05).Why: next month's student needs to know what changed and why.
07 Choosing an optimiser
Every shot costs seconds and every measurement is noisy, so the question is not which optimiser is cleverest but which finds a good setting in the fewest shots, without being fooled by noise. The race below runs four common strategies on the same toy landscape.
Optimiser race on a noisy two-parameter landscape
Each panel shows the true landscape (stronger colour is better) and the points each strategy measured. The chart below shows, after each shot, how good the strategy's current best guess really is. Raise the noise to see which methods get fooled.
A toy landscape, not a real MOT: a broad main peak, a smaller second peak and a gentle slope, with Gaussian measurement noise in units of the peak height. Grid, random and Nelder–Mead report the best point they measured; the Bayesian optimiser reports the measured point its model rates highest, which is what protects it from lucky noisy shots. The grid uses the largest square number of shots that fits the budget. Results vary with the noise seed, so press "New noise" a few times before drawing conclusions.
Grid and 1D scans
Easy to understand and to plot, and the right first look. The cost is kd points for k values of d parameters, so a grid is hopeless beyond two or three parameters.
Nelder–Mead
Needs no model and few points per step. It was the workhorse of early online optimisation, but it can mistake noise for a slope and stall on a ridge, and it only finds the nearest peak.
Bayesian optimisation
Fits a Gaussian process (a smooth model with error bars) to every shot so far, then measures where the model says improvement is likely. Efficient for expensive, noisy shots and tens of parameters; Vendeiro et al. tuned up to 55.
Evolutionary methods
Differential evolution and CMA-ES keep a population of settings and breed better ones. Robust to noise and local peaks, but they spend more shots; good when shots are fast.
Neural-network learners
Replace the Gaussian process with a network when there are many parameters. Tranter et al. tuned a 63-parameter MOT compression sequence this way.
Reinforcement learning
For a different task: not one best set of numbers, but a policy that reacts to what it observes during the shot. Costly to train; usually trained in simulation first.
08 Machine learning in AMO labs: what has been done
Machine learning entered cold-atom labs as an optimiser for sequences too long to tune by hand, then spread to readout, control and alignment. These are representative papers, with what each one actually reports.
| Paper | What was automated | Method | Reported result |
|---|---|---|---|
| Wigley et al., Sci. Rep. 6, 25890 (2016) | Evaporation ramp for a Bose–Einstein condensate | Gaussian-process online optimiser (the origin of M-LOOP) | A ramp producing high-quality BECs in 10 times fewer iterations than the previous online optimiser (Nelder–Mead) |
| Tranter et al., Nat. Commun. 9, 4360 (2018) | MOT compression sequence for maximum optical depth | Stochastic artificial neural network; 63 parameters (21 time bins × 3 controls) | Optical depth 970 ± 20 against 535 ± 8 for the best human-designed sequence |
| Barker et al., Mach. Learn.: Sci. Technol. 1, 015007 (2020) | Laser cooling and evaporation together, for a BEC | Differential evolution, Gaussian process and neural network compared | Four times the BEC atom number of the manually optimised settings; a BEC from fully randomised starting parameters |
| Vendeiro et al., Phys. Rev. Research 4, 043216 (2022) | Fast BEC production via Raman cooling in an optical trap | Bayesian optimisation of up to 55 control parameters | BECs of 2.8 × 10³ 87Rb atoms from a room-temperature gas in 575 ms |
| Reinschmidt et al., Nat. Commun. 15, 8532 (2024) | Live control of a 87Rb MOT (detuning and field gradient) from fluorescence images | Deep reinforcement learning, trained in simulation and transferred to the experiment | Adaptive loading control; compensated a sudden detuning step and met atom-number targets on demand |
| Phuttitarn et al., Phys. Rev. Applied 22, 024011 (2024) | State readout of a Cs tweezer array | Convolutional neural networks on the camera images | Up to 56% (single-site) and 32% (whole-array) lower readout error; crosstalk correlation reduced by up to 78.5% |
| Lee & Chae, arXiv:2401.04893 | Choosing tweezer moves for defect-free rearrangement | Reinforcement learning (PPO), simulations of 50–300 tweezers | A simulation study, compared against A* path search; no experiment preprint |
09 AI agents and language models in the lab
Since late 2024 several groups have connected large language models to real experiments, letting them plan, run and interpret measurements. These are early results, mostly preprints, and the architecture of each system is as instructive as the result.
k-agents (Cao et al.)
LLM agents turn a lab procedure written in plain language into a state machine of experiments, run it, and use separate inspection agents to judge each result before moving on. They ran calibrations autonomously for hours on a 16-qubit processor, reaching 99.87% single-qubit gate fidelity after recalibration.
arXiv:2412.07978; journal version in Patterns (2025).
QCopilot (Sha et al.)
A team of LLM agents (decision maker, experimenter, analyst, fault diagnoser, recorder) ran Bayesian optimisation on a Rb cold-atom apparatus and diagnosed faults. The authors report 108 sub-µK atoms without human intervention within a few hours, about 100 times faster than manual tuning.
arXiv:2508.05421 preprint
Agentic quantum sensing (Isogawa et al.)
An LLM agent planned and interpreted NV-centre measurements, deciding for itself to run a CPMG follow-up after a weak Ramsey feature. It had no direct hardware access: it wrote requests to a queue that deterministic control software checked and executed.
arXiv:2607.25145 preprint
- Writing and explaining instrument drivers, analysis scripts and sequence code, which you then test like a new student's code.
- Reading the night's logs and summarising what failed and when.
- Turning a procedure you already do by hand into a script or a checklist.
- Searching manuals and datasheets for the setting you need.
- Hardware interlocks stay independent of all software, agent or not.
- The agent proposes, the control system disposes. Requests go through a queue that checks every parameter against fixed, safe ranges (the design in the NV-centre paper above).
- A person approves anything irreversible or hazardous: high laser power, coil currents, valves, bake-outs.
- Every action is logged with the reasoning the agent gave, so a bad night can be reconstructed.
10 The infrastructure that makes automation safe
Automation without monitoring is a machine that fails quietly. These four pieces are what let a group trust an experiment that runs while nobody is watching.
Laser powers, lock states, wavemeter readings, temperatures and humidity, vacuum pressures, coil currents: sampled continuously into a time-series database with dashboards (a common choice is InfluxDB with Grafana). When the atom number dropped at 3 a.m., the logs show that the lab temperature rose at 2:40.
A message to the group chat or a phone when a lock fails repeatedly, a pressure rises, cooling water stops, or a calibration lands far from its usual value. Alerts should be rare and specific, or people learn to ignore them.
Calibrated values (resonances, π-times, thresholds) live in one database or file with history. Every shot records which values it used, and every automatic update is logged with the data that justified it.
Run new automation against a simulator or with the lasers blocked before letting it loose. Check what it does when a sensor is unplugged, a reading is NaN or a device does not answer: those are the failures that happen at night.
11 Checklist before you let it run overnight
- Every loop has limits on its output and a defined safe state when it gives up.
- Every shot records the lock states, the parameters used and the code version.
- The figure of merit has been checked by hand: it cannot be raised by a background, a saturated camera or a mis-set threshold.
- Reference measurements are interleaved so drift can be told apart from improvement.
- Someone gets a message if it stops, and knows what to do.
- In the morning, validate before you believe: re-measure the winner against the old settings.