-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix!: Rework Loss Scalings to provide better modularity #52
Open
sahahner
wants to merge
57
commits into
main
Choose a base branch
from
7-pressure-level-scalings-only-applied-in-specific-circumstances
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+1,263
−544
Open
Changes from all commits
Commits
Show all changes
57 commits
Select commit
Hold shift + click to select a range
511ed18
first version of refactor of variable scaling
sahahner 7ddf6d6
config training changes
sahahner 3ddeccc
avoid multiple scaling
sahahner be4602c
docstring and explain variable reference
sahahner 195af07
fix to config for pressure level scaler
mc4117 2644c18
instantiating scalars as a list
mc4117 718fc57
preparing for tendency losses
mc4117 a34ac02
Merge branch '7-pressure-level-scalings-only-applied-in-specific-circ…
mc4117 b91af11
log the variable level scaling information as before
sahahner c22c50b
adding tendency scaler to additional scalers
pinnstorm 1f4a532
reformatting
pinnstorm 2843d98
updating description in configs
pinnstorm c978871
updating var-tendency-scaler spec
pinnstorm f56f9b2
updating training/default config
pinnstorm be90000
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] e474ae9
updating training/default.yaml
pinnstorm f005f84
updating training/default.yaml
pinnstorm 7cdccc5
first try at tests
mc4117 61e7933
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 462bb34
variable name and level from mars metadata
sahahner 960a602
Merge branch '7-pressure-level-scalings-only-applied-in-specific-circ…
sahahner af10173
get variable group and level in utils file
sahahner 395cd6f
empty line
sahahner 1f53a82
convert test for new strucutre. pressure level and general variable s…
sahahner 3747959
more plausible check for availability of mars metadata
sahahner 68cd6e3
update to tendency tests (still not working)
mc4117 d3a7c29
Merge branch '7-pressure-level-scalings-only-applied-in-specific-circ…
mc4117 d6e127a
tendency scaler tests now working
mc4117 fd29cbc
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 8bff68b
change function into class, extracting variable group and name
sahahner 4c7cbc1
Merge branch '7-pressure-level-scalings-only-applied-in-specific-circ…
sahahner 7d8c76d
correct function call
sahahner d928b30
correct typo in test
sahahner bb054ce
incorporate comments
sahahner d0046fa
introduce base class for all loss scalings
sahahner a03d6ba
type checking check after all imports
sahahner aa7f558
comment: explanation about variable groups in config file
sahahner 9a8a4b9
rm if statement for tendency scaler
mc4117 66d66ed
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] db05ce5
use utils function to retrieve variable group and reference for valid…
sahahner 61766cd
Merge branch '7-pressure-level-scalings-only-applied-in-specific-circ…
sahahner 3adf924
comment in config file that scler name needs to be added to loss as w…
sahahner f19d69d
fix pre-commit hooks
mc4117 c26d744
Merge branch '7-pressure-level-scalings-only-applied-in-specific-circ…
mc4117 00439cb
Update description in training/default
mc4117 6c857a6
refactor into training/scaling both the code and the config files, re…
sahahner a2f2728
more scalar renaming to scaler
sahahner b5f6b5f
fix tendency loss
mc4117 b5fa55b
fix merge conflict
mc4117 cdb9e19
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 963c543
Add '*' to scaler selection.
HCookie 4f1566b
Add exclusion of scalers
HCookie e4ceb8e
Fix scalar reference in tests
HCookie 7178074
Add all and exclude tests
HCookie 08b4cb3
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 0dbf0b8
fix: update all tests, move scaling module into losses
sahahner 2dccbd2
print final variable scaling in debug mode
sahahner File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 58 additions & 0 deletions
58
training/src/anemoi/training/config/training/scalers/scalers.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
variable_groups: | ||
default: sfc | ||
pl: [q, t, u, v, w, z] | ||
|
||
# Several scalers can be added here. In order to be applied their names must be included in the loss. | ||
# scaler name must be included in `scalers` in the losses for this to be applied. | ||
builders: | ||
general_variable: | ||
# Variable groups definition for scaling by variable level. | ||
# The variable level scaling methods are defined under additional_scalers | ||
# A default group is required and is appended as prefix to the metric of all variables not assigned to a group. | ||
_target_: anemoi.training.losses.scaling.variable.GeneralVariableLossScaler | ||
scale_dim: -1 # dimension on which scaling applied | ||
weights: | ||
default: 1 | ||
q: 0.6 #1 | ||
t: 6 #1 | ||
u: 0.8 #0.5 | ||
v: 0.5 #0.33 | ||
w: 0.001 | ||
z: 12 #1 | ||
sp: 10 | ||
10u: 0.1 | ||
10v: 0.1 | ||
2d: 0.5 | ||
tp: 0.025 | ||
cp: 0.0025 | ||
|
||
pressure_level: | ||
_target_: anemoi.training.losses.scaling.variable_level.ReluVariableLevelScaler | ||
group: pl | ||
y_intercept: 0.2 | ||
slope: 0.001 | ||
scale_dim: -1 # dimension on which scaling applied | ||
|
||
# mask NaNs with zeros in the loss function | ||
nan_mask_weights: | ||
_target_: anemoi.training.losses.scaling.loss_weights_mask.NaNMaskScaler | ||
scale_dim: (-2, -1) # dimension on which scaling applied | ||
|
||
# tendency scalers | ||
# scale the prognostic losses by the stdev of the variable tendencies (e.g. the 6-hourly differences of the data) | ||
# useful if including slow vs fast evolving variables in the training (e.g. Land/Ocean vs Atmosphere) | ||
# if using this option 'variable_loss_scalings' should all be set close to 1.0 for prognostic variables | ||
stdev_tendency: | ||
_target_: anemoi.training.losses.scaling.variable_tendency.StdevTendencyScaler | ||
scale_dim: -1 # dimension on which scaling applied | ||
var_tendency: | ||
_target_: anemoi.training.losses.scaling.variable_tendency.VarTendencyScaler | ||
scale_dim: -1 # dimension on which scaling applied | ||
|
||
node_weights: | ||
_target_: anemoi.training.losses.nodeweights.GraphNodeAttribute | ||
target_nodes: ${graph.data} | ||
node_attribute: area_weight | ||
scale_dim: 2 # dimension on which scaling applied | ||
|
||
# limited_area_mask |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This class doesn't have a scale_dim attribute.
It may also be useful to add a general scale by node attribute scaler.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not yet. Refactor is still ongoing.