Skip to content

vasildev4/lightforge

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

LightForge

Inverse design of photonic hardware — using AI/optimization to design devices humans can't design by hand, and ML surrogates to do it fast.

The thesis: AI has hit a physical wall — energy and data movement, not algorithms. The escape hatch is photonics (moving and computing with light). The rare edge sits at physics ∩ AI ∩ photonics, and the unfair advantage is using AI to design the photonic hardware and to compress the fab-iteration loop from weeks to hours.

This repo climbs that ladder end-to-end, in pure numpy/scipy/scikit-learn, with every physics engine validated against an independent ground truth.

📄 Full write-up: research/RESULTS.md — the validated engine and an honest investigation into whether learned surrogates can accelerate inverse design (two well-characterized negative results, and why).


Validation first (because completeness without correctness is worthless)

check result
TMM reflectance vs analytic Fresnel exact
Energy conservation R+T+A (lossless) 1 to 1e-16
Adjoint gradient (TMM) vs finite differences 4e-9 max rel. error
Mode solver n_eff vs analytic slab dispersion 8e-5
2D FDFD reflectance vs TMM (independent solver) <0.5%
2D adjoint gradient vs finite differences 3e-8
Mode-overlap adjoint vs finite differences 3e-9
Adjoint through filter+projection vs FD 6e-9
Straight-waveguide mode transmission 1.000

Run python tmm.py, python adjoint.py, python modes.py, python fdfd.py to reproduce.


The ladder

Rung 1 — inverse design works (demo_ar_coating.py)

A transfer-matrix solver + global optimizer. Given only "minimize reflectance, 420–680 nm, at 0/30/45°," it designs an anti-reflection coating: glass 4.26% → 0.205% reflectance (20.8×), and collapses unneeded layers on its own. → ar_coating_result.png

Rung 2 — gradients + manufacturability (demo_rung2.py)

  • Analytic adjoint gradients (adjoint.py): all layer sensitivities in one backward pass, O(1) in the number of parameters — the method that scales to 10⁵-voxel chips. Validated to 1e-8.
  • Real dispersion n(λ) (materials.py, Sellmeier/Cauchy).
  • Yield analysis: adjoint-designs a 0.073% AR coating, then runs a Monte-Carlo tolerance sweep — mean/95th-pct reflectance and the yield (fraction meeting a 0.40% ship spec) vs deposition error. Yield falls below 90% once 1σ error exceeds ~2 nm. That curve is what decides whether a coating ships. → rung2_robust.png

Rung 3 — on-chip building block (demo_rung3.py)

A finite-difference waveguide mode solver (modes.py) with subpixel-averaged interfaces and a sparse eigensolver, validated to 8e-5 against the analytic slab. Produces the effective-index-vs-geometry curve and the single-mode cutoff (~260 nm for a Si/SiO₂ slab at 1550 nm) — the first thing you compute laying out any photonic chip. → rung3_modes.png

Rung 4 — the surrogate moat (demo_rung4.py, surrogate.py)

A neural region-of-interest surrogate maps thicknesses → spectrum at R² = 0.993, ~140× faster than the solver. Design is screen-and-verify: the surrogate ranks 300 000 candidates in ~2 s, the true solver verifies only the top 64 — landing within 0.1% of the solver optimum at 64 solver calls instead of thousands (and ~186 s of brute force). The solver always has the final say, so surrogate error costs ranking, never correctness. This compression is the moat — and it needs both halves: physics to make the data, ML to fit it. → rung4_surrogate.png

Rung 5 — aim at the bottleneck (demo_rung5.py)

DWDM channel filters for optical interconnect — the WDM multiplexing that multiplies AI-cluster bandwidth. Synthesizes a thin-film Fabry-Pérot channel: 96.7% peak transmission, 1.10 nm FWHM, 25 dB neighbour rejection (33 layers), and assembles a 3-channel WDM comb. Reuses the same adjoint machinery via T = 1 − R. → rung5_wdm.png

Rung 6 — free-form 2D device (fdfd.py, demo_rung6.py)

A 2D FDFD Maxwell solver with PML (fdfd.py) — handles arbitrary geometry, not just layers — cross-validated against TMM to <0.5% (normal) at normal and oblique incidence: two solvers built on completely different math agreeing. On top of it, adjoint topology optimization: the gradient of focal intensity w.r.t. ~1500 free pixels in one extra solve (validated vs finite differences to 3e-8), Adam-optimized into a free-form dielectric lens that focuses a plane wave to a point (5.0× intensity) — a device no one drew by hand. → rung6_lens.png

Rung 7 — the interconnect device (photonic_ports.py, demo_rung7.py)

A free-form silicon wavelength demultiplexer — rung 5's WDM function as a chip. Adds waveguide ports: a guided-mode source (a straight Si wire transmits its mode at T = 1.000) and mode-overlap readout. One input carries 1550 + 1310 nm; the adjoint designs a compact Si/SiO₂ pattern that routes 1550 nm → top port at 97% and 1310 nm → bottom port at 95%, with ≤1% crosstalk. The mode-overlap adjoint gradient is validated to 3e-9 (the fix: don't normalize by an input monitor that sees back-reflections — that made the gradient wrong on some pixels). → rung7_demux.png

Rung 8 — make it manufacturable (demo_rung8.py)

The rung-7 demux is grayscale — every pixel a continuous Si/SiO₂ mix, which no foundry can build. Rung 8 adds the three-field density method: a filter (minimum length scale) → a tanh threshold projection with β-continuation that drives every pixel to pure Si or pure SiO₂ while optimizing. Result: a 97% binary demux, 80 nm minimum feature (DRC-style opening/closing check: <4% violating pixels), still routing 95% / 95% — a layout a silicon-photonics foundry could actually etch. The gradient is validated through the projection to 6e-9. → rung8_fab_demux.png


Run it

python -m venv .venv && .venv/Scripts/activate     # Windows
pip install -r requirements.txt
python run_all.py        # every self-check + every rung demo + all figures

Files

tmm.py              physics engine: transfer-matrix solver (validated)
materials.py        dispersive n(λ): Sellmeier / Cauchy
adjoint.py          analytic adjoint gradients through the TMM (validated)
modes.py            waveguide eigenmode solver (validated)
surrogate.py        neural region-of-interest surrogate
fdfd.py             2D FDFD Maxwell solver + PML (validated vs TMM)
photonic_ports.py   waveguide mode sources + mode-overlap readout
demo_ar_coating.py  rung 1   demo_rung2.py  rung 2   demo_rung3.py  rung 3
demo_rung4.py       rung 4   demo_rung5.py  rung 5   demo_rung6.py  rung 6
demo_rung7.py       rung 7   demo_rung8.py  rung 8
run_all.py          every self-check + every rung

Where this goes next

Rungs 1–8 are the validated core: 1D layered design, adjoint gradients, manufacturability, mode solving, ML surrogates, 2D free-form topology optimization, a working on-chip wavelength demultiplexer, and fabrication constraints that make it foundry-etchable — every engine checked against an independent ground truth. The loop — parameterize → simulate → adjoint gradient → optimize → (surrogate-accelerate) — now runs end-to-end on manufacturable silicon-photonic devices. Next: more ports and 3D FDTD, robust (fabrication- variation) design, and a surrogate trained on the FDFD itself. Aimed, throughout, at optical interconnect and optical compute for AI — the Ayar Labs / Lightmatter / Celestial AI lane.

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors