Skip to content

refactor(notebooks): use internal adam and optimize helper - batch 4#465

Closed
marcorudolphflex wants to merge 5 commits into
developfrom
use-internal-adam-and-optimize-helper-batch-4
Closed

refactor(notebooks): use internal adam and optimize helper - batch 4#465
marcorudolphflex wants to merge 5 commits into
developfrom
use-internal-adam-and-optimize-helper-batch-4

Conversation

@marcorudolphflex

@marcorudolphflex marcorudolphflex commented Apr 1, 2026

Copy link
Copy Markdown
Contributor

follow-up from #463

Replaces the optax Adam with our Adam and makes use of the optimize helper where easily possible. This is the fourth batch, covering the 12 notebooks currently in this PR where develop still had real optax usage.

Results are roughly unchanged overall. Notable differences are sorted by risk first; images can be inserted/updated inline as needed.

Percent differences below use (branch - develop) / develop. For max objectives, positive is better; for min objectives/costs, negative is better.

Status Notebook Direction develop branch diff diff % Note
⚠️ Autograd27Smatrix min 1.0909e-02 3.6146e-02 +2.5237e-02 +231.34% objective, worse
TidyFab0GC max 3.0199e-01 5.1519e-01 +2.1320e-01 +70.60% objective, unexpectedly better
Metalens max 6.9960e+01 1.2850e+02 +5.854e+01 +83.68% saved output shifted; old develop output did not match the current two-source code
Autograd19ApodizedCoupler max 4.799e-01 4.801e-01 +2.0e-04 +0.04% objective; coupling efficiency develop -1.98 dB vs. branch -1.99 dB
Autograd7Metalens max 2.2378e+01 2.3344e+01 +9.660e-01 +4.32% objective, roughly unchanged
Autograd25WaveguideCrossing max 9.6852e-01 9.4947e-01 -1.905e-02 -1.97% objective; changed fwidth from f0 / 20 to f0 / 5
Autograd26DiffractiveBeamSplitter max 8.792e-01 8.790e-01 -2.0e-04 -0.02% loss value; cost min changes by +0.02%; final efficiency 0.91 to 0.89
Autograd28FiberLens max 4.0488e-02 4.0460e-02 -2.8e-05 -0.07% final flux, plot/result nearly unchanged
BilayerSiNSiGC max 8.134e-01 8.139e-01 +5.0e-04 +0.06% objective, effectively unchanged
RFAutograd1RectangularPatchAntenna max 20.812315 20.717626 -9.4689e-02 -0.45% final nonzero FOM, roughly unchanged
Autograd13Metasurface min 1.194e-01 1.185e-01 -9.0e-04 -0.75% final loss, roughly unchanged
Autograd23FabricationAwareInvdes max 0.09930831775707324 0.09930831775707324 0 0.00% initial objective check; no credits for full rerun

⚠️ Autograd27Smatrix.ipynb

Objective (min.): develop 1.0909e-02 vs. branch 3.6146e-02 (+231.34%)

develop
image

branch
image

TidyFab0GC.ipynb

Objective (max.): develop 3.0199e-01 vs. branch 5.1519e-01 (+70.60%)

Unexpectedly better. This may be from client/solver changes rather than the optimizer refactor.

Metalens.ipynb

Objective (max., saved notebook output): develop 6.9960e+01 vs. branch 1.2850e+02 (+83.68%)

Branch output is internally consistent with the current source and the rerun (120.32 to 128.50, 30 optimization steps). The large shift is not expected from the optimizer refactor; the old develop output cells did not match the current code path with both source_x and source_y. I checked with Filipe that this is okay to keep, and the changed results are explainable from that stale-output/code mismatch.

Autograd19ApodizedCoupler.ipynb

Objective (max.): develop 4.799e-01 vs. branch 4.801e-01 (+0.04%)

Maximum coupling efficiency: develop -1.98 dB vs. branch -1.99 dB

Rerun is back in line with develop.

Autograd7Metalens.ipynb

Objective (max.): develop 2.2378e+01 vs. branch 2.3344e+01 (+4.32%)

Plot/result roughly unchanged.

Autograd25WaveguideCrossing.ipynb: had to change fwidth from f0 / 20 to f0 / 5; otherwise the transmission output got glitchy values above 1.

Objective (max.): develop 9.6852e-01 vs. branch 9.4947e-01 (-1.97%)

develop:
image

branch:
image

Autograd26DiffractiveBeamSplitter.ipynb

develop:

Loss value (maximize): 0.8792
  Cost (minimize): 9.2696e-01
  Fab penalty: 9.9816e-01
  Efficiency: 0.9999
image

branch:

Loss value (maximize): 0.8790
  Cost (minimize): 9.2712e-01
  Fab penalty: 9.9816e-01
  Efficiency: 0.9999
image

Later final-efficiency output: develop 0.91 vs. branch 0.89.

Autograd28FiberLens.ipynb

Objective / final flux (max.): develop 4.0488e-02 vs. branch 4.0460e-02 (-0.07%)

Plot/result nearly unchanged.

BilayerSiNSiGC.ipynb

Objective (max.): develop 8.134e-01 vs. branch 8.139e-01 (+0.06%)

Effectively unchanged.

RFAutograd1RectangularPatchAntenna.ipynb

Final nonzero FOM: develop 20.812315 vs. branch 20.717626 (-0.45%).

Optimization a little less smooth now, result differs a bit:

image image image image

Autograd13Metasurface.ipynb

Final loss (min.): develop 1.194e-01 vs. branch 1.185e-01 (-0.75%).

Autograd23FabricationAwareInvdes.ipynb

Did not rerun this notebook because I do not have credits for the prefab/fabrication-aware run path. No result shift is expected from this diff.

@github-actions

github-actions Bot commented Apr 1, 2026

Copy link
Copy Markdown
Contributor

Spell check passed successfully for 12 notebook(s).
Generated by GitHub Action run: https://github.com/flexcompute/tidy3d-notebooks/actions/runs/26500556775

@marcorudolphflex marcorudolphflex force-pushed the use-internal-adam-and-optimize-helper-batch-4 branch from 5692255 to a76d195 Compare April 1, 2026 09:05
@marcorudolphflex

Copy link
Copy Markdown
Contributor Author

will rerun Autograd27 with other seed to check if we can still see that objective setback.

@marcorudolphflex marcorudolphflex force-pushed the use-internal-adam-and-optimize-helper-batch-4 branch from a76d195 to 4985eb2 Compare May 19, 2026 12:06
@marcorudolphflex marcorudolphflex force-pushed the use-internal-adam-and-optimize-helper-batch-4 branch from a0742b4 to e717c70 Compare May 22, 2026 11:06
@marcorudolphflex

Copy link
Copy Markdown
Contributor Author

Superseded by #513, which keeps only the no-brainer subset and leaves Metalens, Autograd27Smatrix, and Autograd25WaveguideCrossing out for separate discussion.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant