-
Notifications
You must be signed in to change notification settings - Fork 66
fix: autograd regressions #2984
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
yaugenst-flex
merged 1 commit into
develop
from
FXC-4065-fix-regressions-caused-by-config-pr
Nov 12, 2025
Merged
fix: autograd regressions #2984
yaugenst-flex
merged 1 commit into
develop
from
FXC-4065-fix-regressions-caused-by-config-pr
Nov 12, 2025
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
9c6374c to
7dd7df7
Compare
7dd7df7 to
9f90c49
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.
2 files reviewed, 1 comment
9f90c49 to
666d772
Compare
666d772 to
37db41e
Compare
Contributor
Diff CoverageDiff: origin/develop...HEAD, staged and unstaged changes
Summary
tidy3d/components/geometry/base.py |
groberts-flex
approved these changes
Nov 12, 2025
Contributor
groberts-flex
left a comment
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, thanks for tracking down these changes!
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.
===================== 8 passed in 1581.62s (0:26:21) ===================🎉fixes regressions introduced in 8bdf76e for changes that weren't carried over from c038f17
Greptile Overview
Greptile Summary
Fixes autograd gradient computation regressions by refactoring the derivative calculation approach for
BoxandPolySlabgeometries.Key changes:
xarray,EPSILON_0,MU_0, and field data utility imports that are no longer neededThe refactoring simplifies the gradient computation logic significantly while fixing numerical issues that were causing test failures.
Confidence Score: 4/5
tidy3d/components/geometry/base.py(debug comment on line 2616)Important Files Changed
File Analysis
Box._derivative_facemethod from xarray-based integration to point-based grid sampling approach, removing 300+ lines of complex field interpolation logic. Contains minor leftover debug comment.Sequence Diagram
sequenceDiagram participant Caller as Autograd System participant BoxFaces as Box._derivative_faces participant BoxFace as Box._derivative_face participant GridBuilder as Grid Builder participant Evaluator as evaluate_gradient_at_points Caller->>BoxFaces: compute gradients for box BoxFaces->>BoxFaces: determine axes_to_compute from paths loop For each face (6 faces) BoxFaces->>BoxFace: compute gradient for face BoxFace->>BoxFace: check if face outside simulation alt Face outside bounds BoxFace-->>BoxFaces: return 0.0 else Face inside bounds BoxFace->>BoxFace: compute intersection bounds BoxFace->>BoxFace: detect if 2D geometry alt is 2D BoxFace->>GridBuilder: build 1D grid along edge GridBuilder-->>BoxFace: grid_points (1D) else is 3D BoxFace->>GridBuilder: build 2D grid on face GridBuilder-->>BoxFace: grid_points (2D mesh) end BoxFace->>Evaluator: evaluate_gradient_at_points Evaluator-->>BoxFace: gradient values at points BoxFace->>BoxFace: integrate (sum * weight) BoxFace-->>BoxFaces: vjp_value end end BoxFaces-->>Caller: vjp_faces array