-
Notifications
You must be signed in to change notification settings - Fork 66
fix(tidy3d): FXC-3948-fix-caching-for-autograd #2956
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.
Additional Comments (1)
-
tidy3d/web/api/webapi.py, line 377-378 (link)syntax: docstring doesn't match the new return type - should document both the path and task_id return values
3 files reviewed, 3 comments
21d3662 to
4c25be6
Compare
Diff CoverageDiff: origin/develop...HEAD, staged and unstaged changes
Summary
|
60fd0f0 to
4b4365d
Compare
yaugenst-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.
Thanks @marcorudolphflex!
4b4365d to
976046a
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.
Additional Comments (1)
-
tidy3d/web/api/webapi.py, line 375-378 (link)style: docstring not updated to reflect new return value - should document that it returns a tuple of
(path, task_id)
7 files reviewed, 3 comments
976046a to
ddd622d
Compare
Previous: Caching does not work with autograd and non-local gradients because some data access via web is tried to made with a dummy task id for cached simulations.
Solution: Get original task id from originally cached simulation to get the trace-relevant data.
Greptile Overview
Updated On: 2025-11-04 12:14:42 UTC
Greptile Summary
Fixes caching for autograd with non-local gradients by retrieving and using the original task_id from cached simulations.
Key changes:
restore_simulation_if_cachedto return both the restored path and the cached task_iduuid.uuid4()instead of_cached_task_idto avoid None valuesBatch.monitorfor cached jobsIssues found:
autograd.py:583-589:load()is called withpath=Noneinstead of usingrestored_path, which will cause the load to failcontainer.py:1128:load_if_cachedis a@cached_propertybut is accessed inside the monitor loop, causing repeated cache checkswebapi.pyfor the new tuple return valueConfidence Score: 2/5
load()is called withpath=Noneinstead ofrestored_path, which will cause autograd cache loading to fail. Additionally, there's a performance issue with repeated cached property access in the monitor loop.tidy3d/web/api/autograd/autograd.py(incorrect path parameter). Performance issue intidy3d/web/api/container.py(inefficient cached property access).Important Files Changed
File Analysis
restore_simulation_if_cachedto return tuple of (path, task_id); has incorrect return type annotation and outdated docstring_cached_task_idattribute and uuid-based stash paths; inefficient cached property access in monitor loopload()instead of usingrestored_pathSequence Diagram
sequenceDiagram participant AG as Autograd participant Cache as restore_simulation_if_cached participant Load as load() participant Web as WebAPI Note over AG: Non-local gradient case AG->>Cache: restore_simulation_if_cached(sim_original) Cache-->>AG: (restored_path, cached_task_id) alt Cache Hit Note over AG: BUG: passes path=None instead of restored_path AG->>Load: load(task_id=None, path=None) Note over Load: Will fail - cannot load from None path Load--xAG: Error else Cache Miss AG->>Web: _run_tidy3d(sim_original) Web-->>AG: (sim_data_orig, task_id_fwd) end Note over AG: aux_data[FWD_TASK_ID] = task_id_fwd Note over AG: Later: Backward pass uses cached task_id