-
Notifications
You must be signed in to change notification settings - Fork 64
refc: backwards-compatible componentmodeler run() and autograd-support #2807
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
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
Reviewing changes made in this pull request
538ba3f
to
ca37a45
Compare
Diff CoverageDiff: origin/develop...HEAD, staged and unstaged changes
Summary
|
groberts-flex
approved these changes
Sep 10, 2025
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 to me, just a couple small questions! Thanks @yaugenst-flex
tylerflex
requested changes
Sep 10, 2025
8b4ec67
to
925d99e
Compare
tylerflex
approved these changes
Sep 10, 2025
auto-merge was automatically disabled
September 10, 2025 15:11
Pull Request is not mergeable
…t for web.run as well as modeler.run() paths
925d99e
to
3ef5385
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Greptile Summary
Updated On: 2025-09-10 08:44:14 UTC
This PR implements backwards-compatible component modeler
run()
functionality with autograd support. The changes consolidate the component modeler execution path under the unifiedtidy3d.web.run()
API while maintaining backwards compatibility for existing code.The core changes involve three main areas:
API Consolidation: The autograd
run()
function intidy3d/web/api/autograd/autograd.py
is modified to acceptComponentModeler
objects by broadening the simulation parameter type fromtd.Simulation
totyping.Any
. This enables the function to handle both regular simulations and component modelers through a unified interface.Component Modeler Routing: New routing logic detects
ComponentModeler
instances and routes them to the appropriate smatrix local run function when they contain autograd-valid simulations or whenlocal_gradient
is enabled. This leverages the existing smatrix infrastructure while enabling autograd capabilities.Documentation Cleanup: The migration documentation is updated to remove references to deprecated legacy functionality, specifically removing the "legacy run command" section that documented
tidy3d.plugins.smatrix.run.run
. This aligns the documentation with the deprecation of the legacy helper function.The integration fits well with the existing codebase architecture by reusing established patterns for type checking and routing to different execution paths. The changes maintain the existing
td.Simulation
autograd path unchanged, ensuring no breaking changes for current users while extending functionality to component modelers. The test updates demonstrate that the new API works correctly, withmodeler.run()
now returning smatrix data directly instead of requiring an additionalsmatrix()
call.Important Files Changed
Changed Files
docs/api/plugins/smatrix_migration.rst
tests/test_plugins/smatrix/test_component_modeler_autograd.py
tidy3d/web/api/autograd/autograd.py
Confidence score: 4/5
Sequence Diagram