Skip to content

enable per-channel location weight scaling#2293

Draft
jpolz wants to merge 2 commits into
ecmwf:developfrom
jpolz:jpolz/develop/2292_per_channel_location_weigh_scaling
Draft

enable per-channel location weight scaling#2293
jpolz wants to merge 2 commits into
ecmwf:developfrom
jpolz:jpolz/develop/2292_per_channel_location_weigh_scaling

Conversation

@jpolz
Copy link
Copy Markdown
Contributor

@jpolz jpolz commented Apr 30, 2026

Description

Backward compatible per channel scaling of the location loss weighting.

Example config:

location_weight: cosine_latitude
location_weight_fraction:
  q: 0.0    # no lat weighting
  u: 0.5    # half lat weighting
  t: 1.0    # full (same as omitting)
  # unlisted channels default to 1.0
channel_weights:
  q: 2.0    # applied after, as before

Issue Number

Closes #2292

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

@github-actions github-actions Bot added model Related to model training or definition (not generic infra) science Scientific questions labels Apr 30, 2026
Copy link
Copy Markdown
Collaborator

@clessig clessig left a comment

Choose a reason for hiding this comment

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

For me the concept of a fractional location weight is strange since it corrects for something that is either there or not. I see why one might want to control the weighting but conceptually it is still questionable.

In terms of the config, the pattern matching is problematic e.g. for z. So having an explicit list with all channels explicitly and the explicit weights is much preferable.

# apply point weighting
if weights_points is not None:
kcrps_locs_chs = kcrps_locs_chs * weights_points
if weights_points.dim() == 1:
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.

Can't we handle this without and if by broadcasting the shape in the uniform case?

)
if weights_points is not None:
diff_p = (diff_p.transpose(1, 0) * weights_points).transpose(1, 0)
if weights_points.dim() == 1:
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.

Same as above

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.

Allow for per channel location weights in loss computation

2 participants