Skip to content

switch for consistently enabling gradient tracking - #2711

Draft
enssow wants to merge 1 commit into
ecmwf:developfrom
enssow:sorcha/dev/2661
Draft

switch for consistently enabling gradient tracking#2711
enssow wants to merge 1 commit into
ecmwf:developfrom
enssow:sorcha/dev/2661

Conversation

@enssow

@enssow enssow commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Description

In the current WeatherGenerator setup when the model does a forward pass, it runs through _scatter in some instances this does not preserve the autograd graph back to the ERA5 input tokens. I've implemented a switch in the config. Will add some sample runs to show that performance of model doesn't change here.

Issue Number

Closes #2661

Is this PR a draft? Mark it as draft.

Checklist before asking for review

  • I have performed a self-review of my code
  • My changes comply with basic sanity checks:
    • I have fixed formatting issues with ./scripts/actions.sh lint
    • I have run unit tests with ./scripts/actions.sh unit-test
    • I have documented my code and I have updated the docstrings.
    • I have added unit tests, if relevant
  • I have tried my changes with data and code:
    • I have run the integration tests with ./scripts/actions.sh integration-test
    • (bigger changes) I have run a full training and I have written in the comment the run_id(s): launch-slurm.py --time 60
    • (bigger changes and experiments) I have shared a hegdedoc in the github issue with all the configurations and runs for this experiments
  • I have informed and aligned with people impacted by my change:
    • for config changes: the MatterMost channels and/or a design doc
    • for changes of dependencies: the MatterMost software development channel

@enssow
enssow marked this pull request as draft August 3, 2026 08:29
@github-actions github-actions Bot added model Related to model training or definition (not generic infra) science Scientific questions labels Aug 3, 2026

@clessig clessig left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the contribution. Minor changes required.

Comment thread config/default_config.yml
norm_type: "LayerNorm"
qk_norm_type: null # if null, defaults to norm_type

lrp_enabled: False

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The meaning of config options should be self-explanatory, at least for someone familiar with the model. This is not the case here.

if self.cf.lrp_enabled:
tokens_all = tokens_all.scatter(0, scatter_idxs, torch.cat(x_embeds))
else:
# actual scatter operation and apply per cell positional encoding

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment should be above the if-statement, the comment in l126 above l128

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

Labels

model Related to model training or definition (not generic infra) science Scientific questions

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

add config arg for inplace scatter

2 participants