Skip to content

feat(training): speedup multiscale loss#1212

Draft
cathalobrien wants to merge 7 commits into
mainfrom
fix/speedup-sparse-proj
Draft

feat(training): speedup multiscale loss#1212
cathalobrien wants to merge 7 commits into
mainfrom
fix/speedup-sparse-proj

Conversation

@cathalobrien

@cathalobrien cathalobrien commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

Description

This PR introduces a few changes to various losses with the aim of speeding up the multiscale loss in the temporal downscaler.

The main change is grouping the N sparse matmuls in sparse_projector.py to 1 large sparse matmul. the multi scale loss was having to load the projection matrix into L2 memory with each call to sparse matmul.

Additionally the projection matrices are now converted to CSR format during multiscale loss init time. This further speeds up the loading of the projection matrices, as well as reducing peak memory usage.

After these changes, the individual CRPS loss computations begin to dominate. Compiling them gives another speedup (that's set in the config not in this PR)

some rough timings for the loss alone, using a standalone bm script.

version time (s) peak memory (GB)
Initial 3.77 49
grouped sparse matmul 3.30 49
+ CSR format 2.06 44
+ compile CRPS 1.08 45

The results roughly match what I see in the traces from full training runs. The end-to-end throughput of a full training run has gone from 0.22 it/s to 0.62 it/s (0.55 without compiling)

@github-project-automation github-project-automation Bot moved this to To be triaged in Anemoi-dev Jun 24, 2026
@cathalobrien cathalobrien added the ATS Approval Not Needed No approval needed by ATS label Jun 24, 2026
@mc4117 mc4117 changed the title feat(training): speedup temporal downscaler feat(training): speedup multiscale loss Jun 24, 2026
@japols

japols commented Jun 25, 2026

Copy link
Copy Markdown
Member

Nice! Should we consider adding the CRPS loss as a default compile option in config.model.compile?

(probably need to revisit compile defaults when observations are merged, specifically dynamic=False)

@ssmmnn11

Copy link
Copy Markdown
Member

I had this in a branch to allow for directly creating the matrix in csr ; which is relevant when creating large matrices. Can you check how this would fit here as well?

@mc4117

mc4117 commented Jun 25, 2026

Copy link
Copy Markdown
Member

just for context, we're still doing loss correctness tests on this branch and I will post the mlflows here once we have the comparisons

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

Labels

Projects

Status: To be triaged

Development

Successfully merging this pull request may close these issues.

4 participants