Skip to content

Commit c64840e

Browse files
committed
fix[autograd]: ensure consistent task name mapping for batch autograd
1 parent eeec869 commit c64840e

File tree

3 files changed

+3
-2
lines changed

3 files changed

+3
-2
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1515
### Fixed
1616
- Gradient inaccuracy when a multi-frequency monitor is used but a single frequency is selected.
1717
- Revert single cell center approximation for custom medium gradient.
18+
- Potential task name mismatches between forward and adjoint simulations in batch tasks.
1819

1920
## [2.7.7] - 2024-11-15
2021

tests/test_components/test_autograd.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -755,7 +755,7 @@ def test_autograd_async(use_emulated_run, structure_key, monitor_key):
755755
make_sim = fn_dict["sim"]
756756
postprocess = fn_dict["postprocess"]
757757

758-
task_names = {"1", "2", "3", "4"}
758+
task_names = {"test_a", "adjoint", "task1", "_test"}
759759

760760
def objective(*args):
761761
sims = {task_name: make_sim(*args) for task_name in task_names}

tidy3d/web/api/autograd/autograd.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -695,7 +695,7 @@ def vjp(data_fields_dict_vjp: dict[str, AutogradFieldMap]) -> dict[str, Autograd
695695
return sim_fields_vjp_dict
696696

697697
task_names_adj = list(sims_to_run.keys())
698-
task_names_fwd = [name.rstrip("_adjoint") for name in task_names_adj]
698+
task_names_fwd = [name.removesuffix("_adjoint") for name in task_names_adj]
699699

700700
if local_gradient:
701701
# run adjoint simulation

0 commit comments

Comments
 (0)