Skip to content

Support gradient checkpointing in Graph-EFM - #920

Draft
Sir-Sloth-The-Lazy wants to merge 42 commits into
mllam:mainfrom
Sir-Sloth-The-Lazy:feat/graph-efm-gradient-checkpointing
Draft

Sir-Sloth-The-Lazy wants to merge 42 commits into
mllam:mainfrom
Sir-Sloth-The-Lazy:feat/graph-efm-gradient-checkpointing

Conversation

@Sir-Sloth-The-Lazy

@Sir-Sloth-The-Lazy Sir-Sloth-The-Lazy commented Nov 30, 2026 •

Copy link
Copy Markdown
Collaborator

Describe your changes

Use --gradient_checkpointing for Graph-EFM so the variational predictor step and the prior steps used for CRPS can be recomputed in the backward pass. The rollouts share the static graph embeddings, and recomputation preserves the random draws for each step. The option is off by default.

This draft is based on #712. Once that lands, I’ll rebase the follow-up onto main.

Issue Link

Closes #918.

Type of change

  • 🐛 Bug fix (non-breaking change that fixes an issue)
  • ✨ New feature (non-breaking change that adds functionality)
  • 💥 Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • 📖 Documentation (Addition or improvements to documentation)

Checklist before requesting a review

  • My branch is up-to-date with the target branch - if not update your fork with the changes from the target branch (use pull with --rebase option if possible).
  • I have performed a self-review of my code
  • For any new/modified functions/classes I have added docstrings that clearly describe its purpose, expected inputs and returned values
  • I have placed in-line comments to clarify the intent of any hard-to-understand passages of my code
  • I have updated the README to cover introduced code changes
  • If this PR changes contributor workflow, I've updated CONTRIBUTING.md / AGENTS.md
  • I have added tests that prove my fix is effective or that my feature works
  • I have given the PR a name that clearly describes the change, written in imperative form (context).
  • I have requested a reviewer and an assignee (assignee is responsible for merging). This applies only if you have write access to the repo, otherwise feel free to tag a maintainer to add a reviewer and assignee.

Checklist for reviewers

Each PR comes with its own improvements and flaws. The reviewer should check the following:

  • the code is readable
  • the code is well tested
  • the code is documented (including return types and parameters)
  • the code is easy to maintain

Author checklist after completed review

  • I have added a line to the CHANGELOG describing this change, in a section
    reflecting type of change (add section where missing):
    • added: when you have added new functionality
    • changed: when default behaviour of the code has been changed
    • fixes: when your contribution fixes a bug
    • maintenance: when your contribution is relates to repo maintenance, e.g. CI/CD or documentation

Checklist for assignee

  • PR is up to date with the base branch
  • the tests pass
  • (if the PR is not just maintenance/bugfix) the PR is assigned to the next milestone. If it is not, propose it for a future milestone.
  • author has added an entry to the changelog (and designated the change as added, changed, fixed or maintenance)
  • Once the PR is ready to be merged, squash commits and merge the PR.

Train hierarchical and flat Graph-EFM models through the merged probabilistic
interfaces with a Gaussian ELBO and optional fair CRPS from prior trajectories.
Wire configuration, model selection, and checkpoint restoration into the current
training pipeline, preserving increment rescaling and clamping.

Add numerical objective, gradient, training, checkpoint, and configuration tests,
and document the model settings using the repository's docstring conventions.
Restore probabilistic architecture settings from checkpoints, share fair CRPS scoring, and warn about ignored deterministic options. Name Graph-EFM runs using configured layer depths, simplify module assembly, and allow callers to reuse graph embeddings.
Share probabilistic config restoration between the checkpoint helper
and fit so evaluation and resumed training build the saved architecture.
Warn on conflicting explicit YAML settings and preserve the legacy
fallback when checkpoint configuration is unavailable.

Add dummy-data CLI regressions for both graph families and document
checkpoint precedence.
The encoder approximates the target-conditioned posterior rather than computing the true posterior; name and document that distinction.

Review: mllam#712 (comment)
Replace the forecaster ownership boilerplate with the variational reconstruction, KL and optional prior-sampled CRPS objective.

Review: mllam#712 (comment)
The CRPS samples come from separate prior trajectories, not the target-conditioned variational rollout; clarify the extra sampling cost.

Review: mllam#712 (comment)
CRPS and ensemble sampling recomputed static graph embeddings at every step; compute them once per batch and share them with independent prior rollouts while retaining gradients.

Review: mllam#712 (comment)
Summing CRPS over grid points and forecast steps changed the meaning of the paper's tuning weights; average those dimensions and the batch while summing variables.

Review: mllam#712 (comment)
Expose empirical, fair and almost-fair CRPS variants from the approach in mllam#226, preserving the fair training API and using the correctly normalized direct pair difference for two members.

Review: mllam#712 (comment)
Move device-list, automatic-device and multi-node detection out of trainer construction so unused-parameter handling is reusable and independently testable.

Review: mllam#712 (comment)
Graph-EFM trains all networks when KL is enabled; only request DDP unused-parameter detection during zero-KL training and only when multiple devices or nodes are used.

Review: mllam#712 (comment)
Architecture, objective and ensemble-size settings belonged to a special YAML section unlike other models; expose them through argparse and the existing typed run configs instead.

Review: mllam#712 (comment)
Restoring saved probabilistic settings unconditionally prevented changing KL and CRPS weights for the next stage; inherit only unspecified Graph-EFM options and preserve explicit overrides, including zero.

Review: mllam#712 (comment)
The generic predictor builder mixed deterministic GNN arguments with Graph-EFM latent and layer settings; delegate Graph-EFM construction to a dedicated helper.

Review: mllam#712 (comment)
The helper constructs a forecaster and selects a Lightning module class without instantiating that module; rename it to build_forecaster to avoid implying otherwise.

Review: mllam#712 (comment)
Replace the implementation-history paragraph with one feature summary in the Added section.

Review: mllam#712 (comment)
Move Graph-EFM into the model guide, explain its ensemble objective, and provide the paper's MEPS training curriculum with CLI stage and checkpoint examples.

Review: mllam#712 (comment)
Accept and ignore pred_std in the shared positional slot, including vector scales, and warn before reducing a single-member CRPS to MAE without dropping masking or variable reductions. Keep the fair training wrapper strict about requiring two members.

Port the reviewed behavior from mllam#226.
Review: mllam#226 (comment)
Make fair, biased and almost-fair CRPS (alpha 0.95) available through get_metric using the standard pred/target/pred_std interface. Reject ensemble metrics as deterministic losses and validate the prediction layout to avoid silently scoring the wrong axis.

Build on mllam#226 by @shauryam2807.
Review: mllam#226 (comment)
Limit temporary scoring allocations by splitting a caller-selected batch, forecast-step or spatial dimension. Default to unchunked scoring, preserve gradients, and keep masking and reduction after reassembly. Values and gradients match unchunked scoring for every estimator.

Refs mllam#226.
Review: mllam#226 (comment)
Review: mllam#226 (comment)
Add spread_squared with Bessel correction, the shared metric signature, interior masking and variable reductions. Reject ensembles with fewer than two members and verify values, dimensions and gradients.

Absorb the spread metric work from mllam#226 by @shauryam2807 into mllam#712.
Score one evaluation ensemble with mean error, fair CRPS and unbiased variance on interior nodes. Convert averaged variance to spread only after sample aggregation, then restore physical units so reported spread is comparable with RMSE. Preserve single-member mean-error evaluation.

Refs mllam#226 and mllam#712.
Describe the shared CRPS objective and evaluation metrics, metric lookup variants, watched metric names, physical scaling and optional scoring chunks. Extend the existing mllam#712 changelog entry to cover ensemble spread.

Refs mllam#226 and mllam#712.
@Sir-Sloth-The-Lazy Sir-Sloth-The-Lazy added the enhancement New feature or request label Nov 30, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support gradient checkpointing in Graph-EFM

1 participant