-
Notifications
You must be signed in to change notification settings - Fork 61
Warm start and frozen teachers #1876
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
Merged
sophie-xhonneux
merged 25 commits into
develop
from
sophiex/dev/warm-and-frozen-teachers
Mar 27, 2026
Merged
Changes from all commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
d6d51da
Write first solution with Claude
a6e4c25
Add test configs, works on santis
sophie-xhonneux e65241a
Merge branch 'develop' of github.com:ecmwf/WeatherGenerator into soph…
clessig 66de4c0
Merge branch 'develop' into sophiex/dev/warm-and-frozen-teachers
clessig 9fbe081
Merge branch 'develop' of github.com:ecmwf/WeatherGenerator into soph…
clessig af9a02c
Disabling rope; removing model config from finetuning since it needs …
clessig da23d8a
Merge branch 'develop' into sophiex/dev/warm-and-frozen-teachers
sophie-xhonneux 1ccad2b
Add new JEPA config
sophie-xhonneux ac59fc3
Address comments on PR
sophie-xhonneux 026e272
Merge branch 'develop' into sophiex/dev/warm-and-frozen-teachers
clessig c2b40b9
Merge branch 'develop' of https://github.com/ecmwf/WeatherGenerator i…
clessig 8f19264
Linting
clessig 9116f0d
Linting
clessig d9a83ca
Fixed some corner cases in handling of when batch samples are NaN and
clessig e163c52
Fixed handling of when batch valid is
clessig 2a54039
Fixed path handling
clessig 16dc9eb
Fixed problems with loading of teacher model
clessig 2079049
Revert incorrect changes to default_config
clessig 9eff5ac
Merge branch 'develop' of github.com:ecmwf/WeatherGenerator into soph…
clessig d2eccc5
Fix problem with missing run_id as dir in path for loading teacher model
clessig ccaf97c
Updated logging
clessig 65ee9d3
Updated config
clessig 3dba1eb
Merge branch 'develop' of github.com:ecmwf/WeatherGenerator into soph…
clessig 8899a91
Address PR review
sophie-xhonneux a93b7e9
Lint
sophie-xhonneux 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -33,7 +33,8 @@ | |
| from weathergen.model.model import Model, ModelParams | ||
| from weathergen.model.utils import apply_fct_to_blocks, freeze_weights | ||
| from weathergen.train.target_and_aux_module_base import PhysicalTargetAndAux | ||
| from weathergen.train.target_and_aux_ssl_teacher import EMATeacher | ||
| from weathergen.train.target_and_aux_ssl_teacher import EMATeacher, FrozenTeacher | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Great! |
||
| from weathergen.train.teacher_utils import load_encoder_from_checkpoint, prepare_encoder_teacher | ||
| from weathergen.utils.distributed import is_root | ||
| from weathergen.utils.utils import get_dtype | ||
|
|
||
|
|
@@ -315,6 +316,13 @@ def get_target_aux_calculator( | |
| with_fsdp=False, | ||
| overrides=target_and_aux_calc_params.get("model_param_overrides", {}), | ||
| ) | ||
|
|
||
| # Strip to encoder + create fresh heads | ||
| cf_overridden = merge_configs( | ||
| cf, target_and_aux_calc_params.get("model_param_overrides", {}) | ||
| ) | ||
| prepare_encoder_teacher(meta_ema_model, cf.training_config, cf_overridden) | ||
|
|
||
| ema_model = EMAModel( | ||
| model, | ||
| meta_ema_model, | ||
|
|
@@ -326,6 +334,17 @@ def get_target_aux_calculator( | |
| batch_size = cf.get("world_size_original", cf.get("world_size")) * batch_size_per_gpu | ||
| target_aux = EMATeacher(model, ema_model, batch_size, cf.training_config) | ||
|
|
||
| # Optional: warm start encoder from checkpoint | ||
| teacher_run_id = target_and_aux_calc_params.get("teacher_run_id") | ||
| if teacher_run_id is not None: | ||
| teacher_mini_epoch = target_and_aux_calc_params.get("teacher_mini_epoch", -1) | ||
| load_encoder_from_checkpoint( | ||
| ema_model.ema_model, cf, teacher_run_id, teacher_mini_epoch, device | ||
| ) | ||
|
|
||
| elif target_and_aux_calc == "FrozenTeacher": | ||
| target_aux = FrozenTeacher.from_pretrained(cf, dataset, device, target_and_aux_calc_params) | ||
|
|
||
| else: | ||
| raise NotImplementedError(f"{target_and_aux_calc} is not implemented") | ||
|
|
||
|
|
||
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.
Revert changes to default config