Skip to content

Commit d4c2c89

Browse files
feat(tidy3d): FXC-3294-add-opt-in-local-cache-for-simulation-results
1 parent c52a9a5 commit d4c2c89

File tree

14 files changed

+1381
-108
lines changed

14 files changed

+1381
-108
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2626
- Validation for `run_only` field in component modelers to catch duplicate or invalid matrix indices early with clear error messages.
2727
- Introduced a profile-based configuration manager with TOML persistence and runtime overrides exposed via `tidy3d.config`.
2828
- Added support of `os.PathLike` objects as paths like `pathlib.Path` alongside `str` paths in all path-related functions.
29+
- Added configurable local simulation result caching with checksum validation, eviction limits, and per-call overrides across `web.run`, `web.load`, and job workflows.
2930

3031
### Changed
3132
- Improved performance of antenna metrics calculation by utilizing cached wave amplitude calculations instead of recomputing wave amplitudes for each port excitation in the `TerminalComponentModelerData`.

docs/index.rst

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,18 @@ This will produce the following plot, which visualizes the electromagnetic field
168168

169169
You can now postprocess simulation data using the same python session, or view the results of this simulation on our web-based `graphical user interface (GUI) <https://tidy3d.simulation.cloud>`_.
170170

171+
.. admonition:: Caching for repeated simulations
172+
:class: tip
173+
174+
Repeated runs of the same simulation can reuse solver results by enabling the
175+
local cache: ``td.config.local_cache.enabled = True``. You may configure the cache directory
176+
with ``local_cache.directory``. If the number of entries (``local_cache.max_entries``) or the storage size
177+
(``local_cache.max_size_gb``) is exceeded, cache entries are evicted by least-recently-used (LRU) order.
178+
You can clear all stored artifacts with ``td.web.cache.clear()``.
179+
Additionally, there is server-side caching controlled via ``td.config.web.enable_caching``
180+
(enabled by default). While this can avoid recomputation on the server, it still requires
181+
upload/download of results which is why we recommend enabling the local cache.
182+
171183
.. `TODO: open example in colab <https://github.com/flexcompute/tidy3d>`_
172184
173185
@@ -262,4 +274,3 @@ Contents
262274

263275

264276

265-

tests/config/conftest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ def mock_config_dir(tmp_path, monkeypatch):
4242

4343
base_dir = tmp_path / "config_home"
4444
monkeypatch.setenv("TIDY3D_BASE_DIR", str(base_dir))
45-
return base_dir / ".tidy3d"
45+
return base_dir / "config"
4646

4747

4848
@pytest.fixture

tests/test_cli/test_migrate.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ def temp_config_dir(monkeypatch, tmp_path) -> Path:
1818
original_base = os.environ.get("TIDY3D_BASE_DIR")
1919
monkeypatch.setenv("TIDY3D_BASE_DIR", str(tmp_path))
2020
reload_config(profile="default")
21-
config_dir = Path(tmp_path) / ".tidy3d"
21+
config_dir = Path(tmp_path) / "config"
2222
config_dir.mkdir(parents=True, exist_ok=True)
2323
yield config_dir
2424
if original_base is None:

tests/test_components/autograd/test_autograd.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -661,7 +661,7 @@ def plot_sim(sim: td.Simulation, plot_eps: bool = True) -> None:
661661
# args = [("polyslab", "mode")]
662662

663663

664-
def get_functions(structure_key: str, monitor_key: str) -> typing.Callable:
664+
def get_functions(structure_key: str, monitor_key: str) -> dict[str, typing.Callable]:
665665
if structure_key == ALL_KEY:
666666
structure_keys = structure_keys_
667667
else:

0 commit comments

Comments
 (0)