Skip to content

Add JEPA forecasting finetuning config and respect enabled flags#1946

Open
csjfwang wants to merge 52 commits intoecmwf:developfrom
csjfwang:develop-add-jepa-forecast-finetune
Open

Add JEPA forecasting finetuning config and respect enabled flags#1946
csjfwang wants to merge 52 commits intoecmwf:developfrom
csjfwang:develop-add-jepa-forecast-finetune

Conversation

@csjfwang
Copy link
Contributor

Description

  1. create config_jepa_forecasting_finetuning.yml
  2. fix issue JEPA fine-tuning fails with 2D-rope #1943 , JEPA finetuning with 2D-RoPE

Issue Number

Closes #1943

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

wang85 and others added 30 commits July 16, 2025 10:07
"student-teacher": {
enabled: False,
type: LossLatentSSLStudentTeacher,
type: Disabled,
Copy link
Contributor

Choose a reason for hiding this comment

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

Why was this change necessary?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Because here is not filtered by enabled: False:

if v.type == "LossLatentSSLStudentTeacher"

Copy link
Contributor

Choose a reason for hiding this comment

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

Thank you!

Copy link
Collaborator

Choose a reason for hiding this comment

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

But the fix here is to change the above line to:

if v.type == "LossLatentSSLStudentTeacher" and v.get( "enabled", True) :

enabled: False,
masking_strategy: "random",
num_samples: 1,
num_samples: 0,
Copy link
Contributor

Choose a reason for hiding this comment

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

if enabled: False already why do we need num_samples 0?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Since I re-used function get_batch_size_from_config (), and it doesn't use filter enabled: False, I will try to send another fix to avoid num_samples: 1 still be used.

self.batch_size_per_gpu = get_batch_size_from_config(cf.training_config)

Copy link
Contributor

Choose a reason for hiding this comment

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

oh I see, I guess in effect this part of the code gets the unfiltered config and that is the source of the error.

For now set it to 0 samples, but maybe raise an issue!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you! Then I will keep the num_samples: 0 and raise an issue to report the unfiltered config thing!

Copy link
Collaborator

Choose a reason for hiding this comment

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

nction get_batch_size_from_config (), and it doesn't use filter enabled: False, I will try to send another fix to

Where is this actually used?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

nction get_batch_size_from_config (), and it doesn't use filter enabled: False, I will try to send another fix to

Where is this actually used?

I previously used it in the model.py to get the batch size which is used during the initialization of the rope_coords . But now, the use of self.batch_size_per_gpu is not needed, because it can be captured by broadcasting, as we discussed and tested here:
#1895 (comment)

I can now remove this line, which caused the error when enabled: False but num_samples is not zero:

self.batch_size_per_gpu = get_batch_size_from_config(cf.training_config)

But I am thinking maybe better to send a PR to fix the function get_batch_size_from_config() as well? Because now it is not filtered by enabled: False, when we call this function from other place, it might cause the same error again.

def get_batch_size_from_config(config: Config) -> int:

Please let me know what do you think? Do we need to fix it as well? If so, in this PR or open a new one?

Copy link
Collaborator

Choose a reason for hiding this comment

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

We can use this PR to clean it up and change the name. The discussion here is valuable.

# granted to it by virtue of its status as an intergovernmental organisation
# nor does it submit to any jurisdiction.

embed_orientation: "channels"
Copy link
Contributor

Choose a reason for hiding this comment

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

let's remove model params of the encoder, because they should be taken from the base_config anyway

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@sophie-xhonneux I removed the params related to encoder, can you look again?

@clessig clessig self-requested a review March 2, 2026 13:50
Copy link
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.

Let's please fix the cause of the problem in model.py and not patch over issues.

Can we please also change the comments to the standard style:

### POSITIONAL EMBEDDINGS ###

"student-teacher": {
enabled: False,
type: LossLatentSSLStudentTeacher,
type: Disabled,
Copy link
Collaborator

Choose a reason for hiding this comment

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

But the fix here is to change the above line to:

if v.type == "LossLatentSSLStudentTeacher" and v.get( "enabled", True) :

enabled: False,
masking_strategy: "random",
num_samples: 1,
num_samples: 0,
Copy link
Collaborator

Choose a reason for hiding this comment

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

nction get_batch_size_from_config (), and it doesn't use filter enabled: False, I will try to send another fix to

Where is this actually used?

@csjfwang csjfwang changed the title Create config for jepa forecasting finetuning, and fix jepa finetuning Add JEPA forecasting finetuning config and respect enabled flags Mar 6, 2026
@csjfwang
Copy link
Contributor Author

csjfwang commented Mar 6, 2026

Hi @clessig ,

thanks again for the feedback, I addressed the points we discussed in the latest commit.
Updates:

  1. Respect enabled flags consistently:
  • Batch size computation now ignores disabled model_input entries.
  • Active loss/loss-head selection now only considers enabled losses.
  1. Updated a few comments you mentioned to a more standard style.

This should resolve the previous issue where enabled: False entries could still affect behavior in some paths.

Could you please take another look when you have time?

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

Labels

None yet

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

JEPA fine-tuning fails with 2D-rope

3 participants