Skip to content

fix[autograd]: sample fields along slab height and polygon edges #2418

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

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Fixed
- Fixed issue with `CustomMedium` gradients where other frequencies would wrongly contribute to the gradient.
- Fixed bug when computing `PolySlab` bounds in plotting functions.
### Changed
- Finer sampling along `PolySlab` edges in VJP for more accurate gradients.

## [2.8.3] - 2025-04-24

Expand Down
13 changes: 4 additions & 9 deletions tests/test_components/test_autograd.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@
import tidy3d.web as web
import xarray as xr
from autograd.test_util import check_grads
from tidy3d.components.autograd.constants import MAX_NUM_TRACED_STRUCTURES
from tidy3d.components.autograd.derivative_utils import DerivativeInfo
from tidy3d.components.autograd.utils import is_tidy_box
from tidy3d.components.data.data_array import DataArray
from tidy3d.exceptions import AdjointError
from tidy3d.plugins.polyslab import ComplexPolySlab
from tidy3d.web import run, run_async
from tidy3d.web.api.autograd.autograd import MAX_NUM_TRACED_STRUCTURES
from tidy3d.web.api.autograd.utils import FieldMap

from ..utils import SIM_FULL, AssertLogLevel, run_emulated, tracer_arr
Expand Down Expand Up @@ -810,7 +810,7 @@ def test_autograd_async(use_emulated_run, structure_key, monitor_key):
make_sim = fn_dict["sim"]
postprocess = fn_dict["postprocess"]

task_names = {"test_a", "adjoint", "task1", "_test"}
task_names = {"test_a", "adjoint", "_test"}

def objective(*args):
sims = {task_name: make_sim(*args) for task_name in task_names}
Expand Down Expand Up @@ -910,7 +910,7 @@ def test_autograd_async_some_zero_grad(use_emulated_run, structure_key, monitor_
make_sim = fn_dict["sim"]
postprocess = fn_dict["postprocess"]

task_names = {"1", "2", "3", "4"}
task_names = {"1", "2"}

def objective(*args):
sims = {task_name: make_sim(*args) for task_name in task_names}
Expand All @@ -932,7 +932,7 @@ def test_autograd_async_all_zero_grad(use_emulated_run):
make_sim = fn_dict["sim"]
postprocess = fn_dict["postprocess"]

task_names = {"1", "2", "3", "4"}
task_names = {"1", "2"}

def objective(*args):
sims = {task_name: make_sim(*args) for task_name in task_names}
Expand Down Expand Up @@ -1783,11 +1783,6 @@ def postprocess(sim_data: td.SimulationData) -> float:
def test_multi_freq_edge_cases(use_emulated_run, structure_key, label, check_fn, monkeypatch):
# test multi-frequency adjoint handling

import tidy3d.components.data.sim_data as sd

monkeypatch.setattr(sd, "RESIDUAL_CUTOFF_ADJOINT", 1)
reload(td)

postprocess_fn = check_fn(structure_key=structure_key)

def objective(params):
Expand Down
Loading