Skip to content

Add uniform cold-start fallback for stateful models on file restarts - #2942

Open
copybara-service[bot] wants to merge 1 commit into
mainfrom
test_1020227701
Open

copybara-service[bot] wants to merge 1 commit into
mainfrom
test_1020227701

Conversation

@copybara-service

Copy link
Copy Markdown

Add uniform cold-start fallback for stateful models on file restarts

Replace strict models.initial_state_from_datatree restoration in state_evaluation.evaluate_initial_state with per-model restore-or-cold-start so any stateful model can be enabled, disabled, or reconfigured across a file restart without changing public V2 API signatures:

  • For each stateful model (sources, pedestal top-level/structure/formation, transport components, and edge state/outputs), restore saved state when has_saved_state is true and compatible; otherwise log a warning and cold-start from the plasma state at t_restart.
  • Treat saved state that is partly NaN padding (e.g. the pedestal node of a stitched file after a pedestal mode switch) as not saved, and never mark NaN edge boundary conditions read from a file as valid for core update.
  • Preserve restored states for explicit/previous-step models while keeping post-evaluation seeded states for cold-started models.
  • Delete the now-unused Models, SourceModels, TransportModel, and GeometryModel initial_state_from_datatree helpers.
  • Add unit and restart-toggle tests covering particle feedback, pedestal martin_scaling include_dW_dt_in_P_SOL and mode switches, edge extended_lengyel, NaN-padded saved state, and cold-start fallback warnings.

Replace strict `models.initial_state_from_datatree` restoration in `state_evaluation.evaluate_initial_state` with per-model restore-or-cold-start so any stateful model can be enabled, disabled, or reconfigured across a file restart without changing public V2 API signatures:
- For each stateful model (sources, pedestal top-level/structure/formation, transport components, and edge state/outputs), restore saved state when `has_saved_state` is true and compatible; otherwise log a warning and cold-start from the plasma state at `t_restart`.
- Treat saved state that is partly NaN padding (e.g. the pedestal node of a stitched file after a pedestal mode switch) as not saved, and never mark NaN edge boundary conditions read from a file as valid for core update.
- Preserve restored states for explicit/previous-step models while keeping post-evaluation seeded states for cold-started models.
- Delete the now-unused `Models`, `SourceModels`, `TransportModel`, and `GeometryModel` `initial_state_from_datatree` helpers.
- Add unit and restart-toggle tests covering particle feedback, pedestal `martin_scaling` `include_dW_dt_in_P_SOL` and mode switches, edge `extended_lengyel`, NaN-padded saved state, and cold-start fallback warnings.

PiperOrigin-RevId: 1020227701
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant