Skip to content

About

PyTorch-first SLM computational holography toolkit for optical tweezer arrays, bottle beams, interleaved traps, and Zernike-space aberration correction.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

TweezerForge

Python Tests PyTorch Domain Methods

TweezerForge is a compact research-software package for SLM computational holography: phase retrieval, optical tweezer arrays, bottle-beam shaping, interleaved bright/dark trap layouts, quantitative trap analysis, and Zernike-space aberration correction.

The package is written as readable scientific software. The optical model, phase-retrieval routines, PyTorch/GPU path, trap targets, image-analysis metrics, calibration helpers, and layout generators are separated into small modules with tests and runnable examples. The primary use case is neutral-atom and AMO experiments using phase-only spatial light modulators, but the code is also a useful reference for computational optics, inverse problems, GPU numerical computing, and camera-feedback optimization.

TweezerForge SLM computational holography overview

Why this exists

A phase-only SLM turns a programmable near-field phase mask into a far-field optical intensity pattern. In neutral-atom experiments, this makes it possible to generate arrays of bright optical tweezers, dark-center bottle beams, and mixed geometries for data/ancilla or species-selective layouts. The practical difficulty is that the desired target, simulated field, and experimentally measured camera image are not the same object. Real systems include finite aperture effects, optical aberrations, SLM phase nonidealities, camera affine transforms, imperfect uniformity, and site-dependent trap distortions.

TweezerForge treats the problem as a full workflow:

  • define bright, dark, and mixed optical trap targets;
  • solve phase-retrieval problems with GS/WGS-style algorithms;
  • run the same logic through NumPy or optional PyTorch tensor paths;
  • fit measured trap images rather than relying only on screenshots;
  • update amplitudes, waists, positions, and Zernike corrections from feedback;
  • generate layouts motivated by neutral-atom architectures;
  • keep hardware-specific pieces isolated so the package remains runnable without lab equipment.

Status and provenance

This repository is the cleaned, portable package version of the project. It is meant to be understandable, installable, and runnable without the lab machine.

The experimentally tested raw lab workflow lives here:

https://github.com/legendarybladerofmilkywaygalaxy/holography

That repository contains the original notebooks, lab-facing branches, SLM/camera assumptions, calibration paths, and experimental development code. TweezerForge reorganizes the core ideas into a cleaner package with examples, tests, documentation, and selected figures.

Full technical report

A full report is included here:

SLM computational holography full report

The report covers the optical setup, Fourier propagation model, camera affine calibration, GS/WGS phase retrieval, PyTorch implementations, gradient-based holography, neural-holography directions, bottle beams, modulated bottle beams, interleaved bottle/tweezer layouts, fast-readout trap geometries, optimal-transport 2D bottle beams, superpixel aberration correction, iterative Zernike perturbation, Bayesian optimisation in Zernike space, and quadratic bottle-beam analysis.

Results snapshot

Capability What this repository demonstrates
Optical tweezer arrays 4x4 and larger trap-array targets with GS/WGS-style phase retrieval
Uniformity analysis Per-site Gaussian fitting: height, waist, center, RMSE, R², and uniformity scores
Representative uniformity Amplitude: 99.3%; waist-x: 99.4%; waist-y: 99.5%; position-x/y: 99.95%
Bottle beams Dark-center trap targets and fits using radial r^4 exp(-r^2 / w^2) structure
Modulated bottle beams Analytic phase-mask trials for lobed bottle-beam structures
3D diagnostics XY/XZ/YZ slices, line scans, and fitted surface-style views for axial trap structure
Mixed layouts Interleaved bright tweezer and bottle-beam layouts, including experimental camera images
Surface-code-inspired geometries Fast-readout and data/ancilla-style trap-layout prototypes
Aberration correction Superpixel correction, iterative Zernike perturbation, and GP-UCB style Zernike search
Hardware path Lazy slmsuite wrapper so simulation code imports without SLM/camera dependencies

TweezerForge simulation demo

Technical scope

1. Phase retrieval and SLM propagation

The basic inverse problem is to find a near-field SLM phase phi_nf that produces a desired far-field amplitude:

U_nf(x, y) = A_nf(x, y) exp(i phi_nf(x, y))
U_ff        = Fourier[U_nf]
A_cam       ≈ affine / aberrated / measured version of |U_ff|

TweezerForge includes centered FFT propagation, phase-only field construction, Gerchberg-Saxton optimization, weighted-GS-style feedback, and axial propagation utilities. The implementation is deliberately small enough to inspect while still matching the structure of the algorithms used in holographic optical tweezer work.

Relevant papers and lineage:

  • R. W. Gerchberg and W. O. Saxton, “A practical algorithm for the determination of phase from image and diffraction plane pictures,” Optik 35, 237-246 (1972).
  • R. Di Leonardo, F. Ianni, and G. Ruocco, “Computer generation of optimal holograms for optical trap arrays,” Optics Express 15, 1913-1922 (2007). link
  • H. Kim et al., “Gerchberg-Saxton algorithm for fast and efficient atom rearrangement in optical tweezer traps,” Optics Express 27, 2184-2196 (2019). link
  • M. Pasienski and B. DeMarco, “A high-accuracy algorithm for designing arbitrary holographic atom traps,” Optics Express 16, 2176-2190 (2008). link

2. PyTorch-first design

The original experimental workflow used PyTorch-style tensor computation so large SLM grids could move naturally to GPU and later connect to autograd-based optimization. This cleaned package keeps a NumPy path for lightweight installation and tests, and provides an optional PyTorch GS implementation for GPU-ready simulations:

python -m pip install -e ".[torch,dev]"
from tweezerforge.torch_algorithms import TorchGerchbergSaxton

solver = TorchGerchbergSaxton(target_amplitude=target, device="cuda")
phase, loss = solver.solve(n_iter=100)

This is useful for high-resolution SLM grids, batched experiments, and future differentiable optics work. It is not presented as a replacement for mature differentiable-optics frameworks; it is a focused implementation for trap-generation workflows.

3. Quantitative trap analysis

The analysis code extracts quantities that matter experimentally: peak intensity, Gaussian waists, fitted trap centers, FWHM/ellipticity proxies, RMSE, R², and site-to-site uniformity. This moves the project from “generated an image” to “measured the quality of each optical trap.”

Trap array analysis, Gaussian fitting, and uniformity tracking

Relevant papers and lineage:

  • Y. T. Chew et al., “Ultraprecise holographic optical tweezer array,” Physical Review A 110, 053518 (2024). link
  • P. Zupancic et al., “Ultra-precise holographic beam shaping for microscopic quantum control,” Optics Express 24, 13881-13893 (2016). link
  • S. Wang et al., “Feedback Intensity Equalization Algorithm for Multi-Spots Holographic Optical Tweezers,” arXiv:2407.17049 (2024). link

4. Bottle-beam generation and fitting

Bottle beams are dark-center intensity structures surrounded by an escape barrier. In the fitting utilities, the radial profile is modeled as

I(r) = B + A r^4 exp(-r^2 / w^2)

The repository includes bottle-beam targets, line-profile diagnostics, 2D heat maps, radial fits, and 3D visualizations. These tools are relevant for blue-detuned traps, species-selective trapping ideas, and mixed bright/dark neutral-atom layouts.

Bottle-beam array and fitting diagnostics from the full report

Bottle-beam array, 2D fit, line-profile fit, and 3D fitted intensity from the full report.

Relevant papers and lineage:

  • R. Ozeri et al., “Large-volume single-beam dark optical trap for atoms using binary phase elements,” JOSA B 17, 1113-1116 (2000). link
  • P. Xu et al., “Trapping a single atom in a blue detuned optical bottle beam trap,” Optics Letters 35, 2164-2166 (2010). The experiment used a circular π-phase hologram displayed on an SLM. link
  • Y. Xiao et al., “Efficient generation of optical bottle beams,” Nanophotonics 10, 2893-2901 (2021). link
  • L. Konzett, “Array of Optical Bottle Beams Using a Liquid Crystal Spatial Light Modulator,” ETH Zürich Master’s thesis (2021). link

5. Modulated bottle beams

The full report also explores lobed or modulated bottle-beam structures. The idea is to create dark-center traps with multiple bright regions around the ring, which may be useful for species-selective or multi-site geometries. The implementation experiments with analytic phase masks and random-mask superposition ideas rather than only relying on generic 2D loss minimization.

Modulated bottle-beam target and analytic phase-mask trials

Relevant papers and lineage:

  • J. A. Davis and D. M. Cottrell, “Random mask encoding of multiplexed phase-only and binary phase-only filters,” Optics Letters 19, 496-498 (1994). link
  • M. Montes-Usategui et al., “Fast generation of holographic optical tweezers by random mask encoding of Fourier components,” Optics Express 14, 2101-2107 (2006). link
  • N. Perez and D. Preece, “Enhanced optical vector bottle beams with obscured nodal surfaces,” Optics Express 32, 14010-14017 (2024). link

6. Interleaved and surface-code-inspired layouts

Beyond isolated tweezer grids, TweezerForge includes geometry utilities for interleaving bright and dark trap families. These are layout generators, not a quantum-error-correction simulator. Their purpose is to generate optical targets resembling mixed data/ancilla structures that appear in neutral-atom architectures and in interleaved species/trap proposals.

Experimental interleaved bottle beams and tweezers

Experimental interleaved bottles and tweezers from the SLM/camera workflow.

Simulated and experimental fast-readout traps

Fast-readout trap pattern: simulated target and experimental camera image from the full report.

Surface-code-inspired interleaved bright and dark traps

Relevant papers and lineage:

  • D. Petrosyan et al., “Fast measurements and multiqubit gates in dual-species atomic arrays,” Physical Review A 110, 042404 (2024). link
  • C. Fang et al., “Interleaved dual-species arrays of single atoms using a passive optical element and one trapping laser,” arXiv:2412.20261 / Science Advances version. link
  • S. Anand et al., “A dual-species Rydberg array,” arXiv:2401.10325 (2024). link
  • M. Saffman, “Quantum computing with atomic qubits and Rydberg interactions: progress and challenges,” Journal of Physics B 49, 202001 (2016). link

7. Bayesian optimisation in Zernike space

Low-order Zernike modes provide a compact basis for correcting optical aberrations, and Bayesian optimisation gives a practical way to search that low-dimensional space with expensive camera-feedback measurements. The calibration utilities support one-mode scans, parabolic fitting of metric optima, and optional Bayesian optimisation over a small Zernike coefficient space. The expensive part of the experiment is left as a user-provided objective: write phase, image traps, fit metrics, return a score.

Bayesian optimisation in Zernike space: convergence, coefficients, before and after

Bottle-beam fit and ring-scan before and after Zernike-space optimization

Relevant papers and lineage:

  • K. D. Wulff et al., “Aberration correction in holographic optical tweezers,” Optics Express 14, 4169-4174 (2006). link
  • I. Christen et al., “Full-volume aberration-space holography,” arXiv:2505.08777 (2025). link
  • P. Hill et al., “Optical phase aberration correction with an ultracold quantum gas,” Physical Review A 110, 053308 (2024). link
  • Y. Liang et al., “Aberration correction in holographic optical tweezers using a high-order optical vortex,” Applied Optics 57, 3618-3623 (2018). link
  • Z.-H. Qian et al., “Bayesian Optimization for Wavefront Sensing and Error Correction,” Chinese Physics Letters 38, 064202 (2021). link

8. Additional bottle-beam experiments

The full report includes additional exploratory directions: optimal-transport 2D bottle-beam generation, quadratic bottle-beam analysis, superposing a weak tweezer with a bottle beam to introduce a quadratic component, and scanning the π-mask cutoff radius to trade off center darkness, escape intensity, and harmonicity.

Optimal-transport and quadratic bottle-beam experiments from the report

Relevant papers and lineage:

  • H. Swan et al., “High-fidelity holographic beam shaping with optimal transport and phase diversity,” Optics Express 33, 6290-6303 (2025). link
  • P. Huft et al., “Simple, passive design for large optical trap arrays for single atoms,” Physical Review A 105, 063111 (2022). link
  • D. Barredo et al., “Three-Dimensional Trapping of Individual Rydberg Atoms in Ponderomotive Bottle Beam Traps,” Physical Review Letters 124, 023201 (2020). link

How this differs from nearby tools

TweezerForge is not meant to replace mature SLM-control packages. Its useful niche is a compact, readable, neutral-atom-focused implementation that combines trap generation, PyTorch-friendly phase retrieval, bottle-beam targets, interleaved layouts, 3D diagnostics, trap fitting, and Zernike optimization in one small codebase.

See docs/related_work.md for a careful comparison with slmsuite, pySLM2, HoloGradPy, TorchOptics/Holotorch-style frameworks, and conjugate-gradient SLM codes.

Installation

For local development from this zip/package:

cd tweezerforge_package
python -m pip install -e ".[dev]"
pytest

When publishing this cleaned version, use a separate repository name such as tweezerforge rather than the raw experimental repository name.

Optional extras:

# PyTorch/GPU path
python -m pip install -e ".[torch,dev]"

# Hardware wrappers around slmsuite
python -m pip install -e ".[hardware]"

# Optional Bayesian optimization helper using sklearn Gaussian processes
python -m pip install -e ".[bayes,dev]"

Quickstart

from tweezerforge.targets import rectangular_lattice, spot_array_target
from tweezerforge.algorithms import GerchbergSaxton
from tweezerforge.propagation import farfield_amplitude

shape = (256, 256)
centers = rectangular_lattice(rows=4, cols=4, pitch=34, center=(128, 128))
target = spot_array_target(shape, centers, sigma=1.8)

phase, loss = GerchbergSaxton(target, seed=42).solve(n_iter=100)
reconstruction = farfield_amplitude(phase)

Generate the demo figure:

tweezerforge demo --output docs/assets/simulation_demo.png

Repository layout

.
├── src/tweezerforge/
│   ├── algorithms.py          # NumPy GS/WGS reference implementation
│   ├── torch_algorithms.py    # optional PyTorch/GPU GS implementation
│   ├── propagation.py         # centered FFT propagation utilities
│   ├── targets.py             # tweezer and bottle-beam target fields
│   ├── layouts.py             # interleaved and surface-code-inspired geometries
│   ├── metrics.py             # Gaussian/bottle-beam fitting and uniformity metrics
│   ├── zernike.py             # compact low-order Zernike modes
│   ├── calibration.py         # Zernike scans, parabolic fits, Bayesian search helper
│   ├── hardware.py            # optional slmsuite SLM/camera wrapper
│   └── cli.py                 # command-line demos
├── examples/                  # runnable examples
├── tests/                     # pytest smoke tests
├── docs/                      # technical notes and related-work comparison
├── docs/assets/               # README/report figures
├── reports/                   # full report PDF and report/source assets
└── .github/workflows/ci.yml   # CI for tests

Reproducible software

The portable package is designed so a reader can run meaningful examples without experimental hardware:

pytest
python examples/quickstart_simulation.py
python examples/interleaved_bottle_tweezer_layout.py
python examples/zernike_calibration_scan.py

About

PyTorch-first SLM computational holography toolkit for optical tweezer arrays, bottle beams, interleaved traps, and Zernike-space aberration correction.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages