-
Notifications
You must be signed in to change notification settings - Fork 64
Autograd support for component modelers #2779
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
4 files reviewed, 3 comments
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @groberts-flex looks good, if you can just address greptile and test the run.py changes then add this to the merge queue later today when you're ready
8acb4a6
to
7f4ed44
Compare
266eb13
to
cad146f
Compare
Diff CoverageDiff: origin/develop...HEAD, staged and unstaged changes
Summary
tidy3d/plugins/smatrix/run.py
|
cad146f
to
ff82241
Compare
ff82241
to
ffd14b6
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! Exciting.
Have you checked you can run an example normally already?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @yaugenst-flex just a few clarifying questions
4951f43
to
8273564
Compare
…b.run Co-authored-by: groberts-flex <[email protected]>
8273564
to
82bd2e4
Compare
Most of the initial code here from @yaugenst-flex - I added/fixed up a few things to get it working with component modeler based optimizations for s params. I tested my patch antenna optimization for terminal component modeler and a modal example.
Greptile Summary
This pull request adds autograd (automatic differentiation) support for component modelers in Tidy3D, specifically enabling optimization workflows for
TerminalComponentModeler
andModalComponentModeler
. The changes extend the existing autograd infrastructure to handle these higher-level abstractions that manage multiple simulations for electromagnetic component modeling.The core modification expands the web API's batch categorization system to recognize autograd simulation types, allowing proper routing of forward and backward (adjoint) simulations. The autograd module is enhanced to validate and execute component modelers by leveraging their internal simulation dictionaries through the existing batch execution infrastructure. When a component modeler contains autograd-compatible simulations, it routes through the new autograd pathway; otherwise, it falls back to the standard web API.
The implementation maintains full backward compatibility while adding sophisticated handling for composite simulation objects. Component modelers internally contain multiple simulations that need to be executed in batch and then reconstructed into appropriate data structures. The changes include validation logic to check underlying simulations for autograd compatibility and composition functions to properly reconstruct
ComponentModelerData
objects from batch execution results.A comprehensive test suite validates the autograd integration using an offline emulator that generates realistic monitor data without requiring web API calls. The testing covers both modal and terminal component modelers, with the terminal modeler using stubbed S-matrix construction to bypass non-autograd-compatible voltage/current integral calculations.
Important Files Changed
Click to expand
tidy3d/web/api/container.py
CHANGELOG.md
tidy3d/web/api/autograd/autograd.py
tests/test_plugins/smatrix/test_component_modeler_autograd.py
Confidence score: 4/5
Sequence Diagram