Skip to content

refactor(notebooks): use internal adam for autograd27 smatrix#521

Merged
marcorudolphflex merged 1 commit into
developfrom
refactor-autograd27-smatrix-internal-adam
Jun 18, 2026
Merged

refactor(notebooks): use internal adam for autograd27 smatrix#521
marcorudolphflex merged 1 commit into
developfrom
refactor-autograd27-smatrix-internal-adam

Conversation

@marcorudolphflex

@marcorudolphflex marcorudolphflex commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

Summary

This updates Autograd27Smatrix.ipynb as a standalone extraction from #465.

  • Replaces the direct optax optimizer setup and manual update loop with Tidy3D's internal adam and optimize helpers.
  • Uses learning_rate = 0.04, which avoids the large objective spike seen with the earlier 0.05 rerun.
  • Removes the notebook-level optax dependency.
  • Sanitizes local output metadata and local path warning outputs from the rerun.

Optimization Result

Lower-LR internal-Adam rerun, final saved step:

  • Step: 25
  • Objective J: 2.6270e-02 (vs 1.0909e-02 before)
  • Gradient norm: 1.5076e-02
    before
image

after
image

Validation

  • uvx ruff format --check --diff Autograd27Smatrix.ipynb
  • uvx ruff check Autograd27Smatrix.ipynb
  • uv run --no-project python scripts/sync_metadata_tags.py --check
  • uv run --no-project python scripts/validate_notebook_metadata.py Autograd27Smatrix.ipynb
  • uv run --no-project python scripts/check_notebook_private_paths.py Autograd27Smatrix.ipynb
  • python3 misc/check_misc_references.py
  • uv run spellcheck.py Autograd27Smatrix.ipynb

Note

Low Risk
Notebook-only refactor with no production code paths; main review note is that the rerun yields a higher final objective than before, which is expected from the hyperparameter change rather than a functional regression.

Overview
Autograd27Smatrix.ipynb now follows the same optimization pattern as other autograd examples: the inverse-design loop uses tidy3d.plugins.autograd adam and optimize instead of a third-party optax setup and hand-written update steps.

The optimization cell wires record_step as a optimize callback (density plots plus step logs for J, beta, and gradient norm) and keeps parameters in [0, 1] via bounds. learning_rate is set to 0.04 for the rerun (replacing 0.05), which the author reports avoids a large objective spike. Committed outputs were refreshed for the new run (e.g. final step 25, J ≈ 2.63e-02).

This is documentation/example-only: no library or simulation API changes.

Reviewed by Cursor Bugbot for commit fa22e8c. Bugbot is set up for automated code reviews on this repo. Configure here.

@github-actions

github-actions Bot commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

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

@marcorudolphflex marcorudolphflex force-pushed the refactor-autograd27-smatrix-internal-adam branch from 24fd2b6 to fa22e8c Compare June 18, 2026 12:18
@marcorudolphflex marcorudolphflex marked this pull request as ready for review June 18, 2026 13:11

@groberts-flex groberts-flex left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good thanks @marcorudolphflex

@marcorudolphflex marcorudolphflex merged commit 5cf7d32 into develop Jun 18, 2026
2 checks passed
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.

2 participants