Skip to content

fix: Optimiser schema was ignoring kwargs#885

Merged
HCookie merged 2 commits intomainfrom
HCookie-patch-1
Feb 12, 2026
Merged

fix: Optimiser schema was ignoring kwargs#885
HCookie merged 2 commits intomainfrom
HCookie-patch-1

Conversation

@HCookie
Copy link
Member

@HCookie HCookie commented Feb 10, 2026

Description

Allow extra inputs in optimiser schema for use in setting betas, and other keys. Before it was being ignored.

@github-project-automation github-project-automation bot moved this to To be triaged in Anemoi-dev Feb 10, 2026
@HCookie HCookie requested a review from gabrieloks February 10, 2026 17:59
@HCookie HCookie added the ATS Approval Not Needed No approval needed by ATS label Feb 10, 2026
@HCookie HCookie self-assigned this Feb 10, 2026
@HCookie HCookie changed the title fix: Optimiser schema was ignore kwargs fix: Optimiser schema was ignoring kwargs Feb 11, 2026
@icedoom888
Copy link
Contributor

icedoom888 commented Feb 11, 2026

@anaprietonem Testing this right now.
Shoudln't all of these be patched as well?
https://github.com/search?q=repo%3Aecmwf%2Fanemoi-core%20PydanticBaseModel&type=code

Also why not revert back to inherit from BaseModel in anemoi.utils? What was the logic of the switch?

@icedoom888
Copy link
Contributor

As expected, this fixed the Betas overwrite, but not all the other ones: normalizers, scalers, graph attributes and layer_kernels.
The should all be patched.

Comparison Fixed and No config_validation: https://mlflow.ecmwf.int/#/compare-runs?runs=[%22e638d811e39f41728168852c81ae2119%22,%22bbc6f6560e1c492c8190fb6f9bf6c4bb%22]&experiments=[%22109%22]

Coimparison Fixed and config_validation: https://mlflow.ecmwf.int/#/compare-runs?runs=[%2236480c41c7904cbcbfbcbfa0a83a5a6b%22,%22bbc6f6560e1c492c8190fb6f9bf6c4bb%22]&experiments=[%22109%22] (only diff is Betas)

@HCookie
Copy link
Member Author

HCookie commented Feb 11, 2026

@icedoom888 Yes, likely all of those should be patched. I believe the reasoning here is to allow any kwargs, whereas the utils basemodel explicitly forbids that.

@icedoom888
Copy link
Contributor

@HCookie I can confirm that inheriting from the anemoi.utils schema causes issues due to forbedden extra inputs.
I am now experimenting with applying this fix in all other instances of PydanticBaseModel ,

@anaprietonem
Copy link
Contributor

@icedoom888 do you already have a list of the schemas that needs patching? as Harrison said some of this was related to the flexibility for passing kwargs, but this is not something that we may want to enable for each of the schemas we have.

@icedoom888
Copy link
Contributor

icedoom888 commented Feb 11, 2026

Issue seems to be solved when patching all schemas:
https://mlflow.ecmwf.int/#/metric?runs=[%22e638d811e39f41728168852c81ae2119%22,%2236480c41c7904cbcbfbcbfa0a83a5a6b%22,%22bbc6f6560e1c492c8190fb6f9bf6c4bb%22,%22a3a86d94bc544bef972453ee7a29423b%22]&metric=%22train_mse_loss_step%22&experiments=[%22109%22]&plot_metric_keys=%5B%22train_mse_loss_step%22%5D&plot_layout={}&x_axis=step&y_axis_scale=linear&line_smoothness=1&show_point=false&deselected_curves=[]&last_linear_y_axis_range=[]

@anaprietonem The full list is:

  • UnvalidatedBaseSchema in base_schema.py
  • DataSchema in data.py
  • DatasetSchema in dataloader.py
  • InputSchema and LogsSchema in system.py
  • OptimizerSchema in training.py

These are all the ones i patched in the latest run.

@JPXKQX
Copy link
Member

JPXKQX commented Feb 11, 2026

We currently don’t log or print the optimizer configuration. It would be helpful to include this in the training logs (e.g. optimizer type and key hyperparameters).

Since we are changing the default value of optimizer.betas (when config_validatios is set to True), we should explicitly document this in the changelog to make the change visible to users.

@HCookie HCookie force-pushed the HCookie-patch-1 branch 2 times, most recently from 58c8f12 to 3e62e83 Compare February 12, 2026 15:53
Gabriel made a boo boo,
@HCookie HCookie moved this from To be triaged to Under Review in Anemoi-dev Feb 12, 2026
Co-authored-by: MOLDOVAN Gabriel Ionut <gabrielmieng@gmail.com>
Co-authored-by: Mario Santa Cruz <48736305+JPXKQX@users.noreply.github.com>
Co-authored-by: Vera Gahlen <vera.gahlen@ecmwf.int>
Co-authored-by: Ana Prieto Nemesio <91897203+anaprietonem@users.noreply.github.com>
@HCookie HCookie removed the graphs label Feb 12, 2026
Copy link
Collaborator

@VeraChristina VeraChristina left a comment

Choose a reason for hiding this comment

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

LGTM, thanks for fixing this!

@github-project-automation github-project-automation bot moved this from Under Review to For merging in Anemoi-dev Feb 12, 2026
@icedoom888
Copy link
Contributor

Do it @HCookie

@HCookie HCookie merged commit 1f1a030 into main Feb 12, 2026
19 checks passed
@HCookie HCookie deleted the HCookie-patch-1 branch February 12, 2026 16:34
@github-project-automation github-project-automation bot moved this from For merging to Done in Anemoi-dev Feb 12, 2026
@DeployDuck DeployDuck mentioned this pull request Feb 12, 2026
j-fannon pushed a commit to j-fannon/anemoi-core that referenced this pull request Feb 27, 2026
## Description
Allow extra inputs in optimiser schema for use in setting betas, and
other keys. Before it was being ignored.

---------

Co-authored-by: Gabriel Ionut MOLDOVAN <gabriel.moldovan@ecmwf.int>
Co-authored-by: Mario Santa Cruz <48736305+JPXKQX@users.noreply.github.com>
Co-authored-by: Vera Gahlen <vera.gahlen@ecmwf.int>
Co-authored-by: Ana Prieto Nemesio <91897203+anaprietonem@users.noreply.github.com>
j-fannon pushed a commit to j-fannon/anemoi-core that referenced this pull request Mar 2, 2026
## Description
Allow extra inputs in optimiser schema for use in setting betas, and
other keys. Before it was being ignored.

---------

Co-authored-by: Gabriel Ionut MOLDOVAN <gabriel.moldovan@ecmwf.int>
Co-authored-by: Mario Santa Cruz <48736305+JPXKQX@users.noreply.github.com>
Co-authored-by: Vera Gahlen <vera.gahlen@ecmwf.int>
Co-authored-by: Ana Prieto Nemesio <91897203+anaprietonem@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ATS Approval Not Needed No approval needed by ATS training

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Pydantic might be overwriting Configs when config_validation=True Unstable training loops, exploding loss values

6 participants