-
Notifications
You must be signed in to change notification settings - Fork 6
add support for time dim, fix simple bugs #3
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
Closed
Closed
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
6e84ad8
Increase default batch size and learning rate
francois-rozet 0b5345d
Update U-Net architecture
francois-rozet 64f642c
Add ViT-H config
francois-rozet e70544c
Use MSE objective by default
francois-rozet ae0b8c1
Enable loose forking
francois-rozet 24517a5
add support for time dim
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,12 +1,12 @@ | ||
| name: "unet_deep_medium" | ||
| arch: "unet" | ||
| emb_features: 256 | ||
| hid_channels: [64, 128, 256, 384, 512, 768, 1024] | ||
| hid_blocks: [1, 2, 3, 3, 3, 3, 3] | ||
| hid_channels: [64, 128, 256, 512, 768, 1024] | ||
| hid_blocks: [1, 2, 3, 3, 3, 3] | ||
| stride: [1, 2, 2] | ||
| norm: "layer" | ||
| attention_heads: {6: 8} | ||
| periodic: false | ||
| attention_heads: {5: 8} | ||
| periodic: true | ||
| dropout: 0.05 | ||
| checkpointing: true | ||
| identity_init: true |
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 |
|---|---|---|
| @@ -1,12 +1,12 @@ | ||
| name: "unet_deep_small" | ||
| arch: "unet" | ||
| emb_features: 256 | ||
| hid_channels: [32, 64, 128, 256, 512, 768, 1024] | ||
| hid_blocks: [1, 2, 3, 3, 3, 3, 3] | ||
| hid_channels: [32, 64, 128, 256, 512, 1024] | ||
| hid_blocks: [1, 2, 3, 3, 3, 3] | ||
| stride: [1, 2, 2] | ||
| norm: "layer" | ||
| attention_heads: {6: 8} | ||
| periodic: false | ||
| attention_heads: {5: 8} | ||
| periodic: true | ||
| dropout: 0.05 | ||
| checkpointing: true | ||
| identity_init: true |
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 |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| name: "vit_huge" | ||
| arch: "vit" | ||
| emb_features: 256 | ||
| hid_channels: 2048 | ||
| hid_blocks: 16 | ||
| attention_heads: 16 | ||
| qk_norm: true | ||
| rope: true | ||
| patch_size: [1, 1, 1] | ||
| window_size: null | ||
| dropout: 0.05 | ||
| checkpointing: false |
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 |
|---|---|---|
| @@ -1,12 +1,12 @@ | ||
| name: "unet_deep_medium" | ||
| arch: "unet" | ||
| emb_features: 256 | ||
| hid_channels: [64, 128, 256, 384, 512, 768, 1024] | ||
| hid_blocks: [1, 2, 3, 3, 3, 3, 3] | ||
| hid_channels: [64, 128, 256, 512, 768, 1024] | ||
| hid_blocks: [1, 2, 3, 3, 3, 3] | ||
| stride: [1, 2, 2] | ||
| norm: "layer" | ||
| attention_heads: {6: 8} | ||
| periodic: false | ||
| attention_heads: {5: 8} | ||
| periodic: true | ||
| dropout: 0.05 | ||
| checkpointing: true | ||
| identity_init: true |
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 |
|---|---|---|
| @@ -1,12 +1,12 @@ | ||
| name: "unet_deep_small" | ||
| arch: "unet" | ||
| emb_features: 256 | ||
| hid_channels: [32, 64, 128, 256, 512, 768, 1024] | ||
| hid_blocks: [1, 2, 3, 3, 3, 3, 3] | ||
| hid_channels: [32, 64, 128, 256, 512, 1024] | ||
| hid_blocks: [1, 2, 3, 3, 3, 3] | ||
| stride: [1, 2, 2] | ||
| norm: "layer" | ||
| attention_heads: {6: 8} | ||
| periodic: false | ||
| attention_heads: {5: 8} | ||
| periodic: true | ||
| dropout: 0.05 | ||
| checkpointing: true | ||
| identity_init: true |
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 |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| name: "vit_huge" | ||
| arch: "vit" | ||
| emb_features: 256 | ||
| hid_channels: 2048 | ||
| hid_blocks: 16 | ||
| attention_heads: 16 | ||
| qk_norm: true | ||
| rope: true | ||
| patch_size: [1, 1, 1] | ||
| window_size: null | ||
| dropout: 0.05 | ||
| checkpointing: false |
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
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 |
|---|---|---|
|
|
@@ -3,6 +3,7 @@ | |
| import argparse | ||
| import dawgz | ||
| import wandb | ||
| import os | ||
|
|
||
| from functools import partial | ||
| from omegaconf import DictConfig | ||
|
|
@@ -41,8 +42,8 @@ def train(runid: str, cfg: DictConfig): | |
| torch.cuda.set_device(device) | ||
|
|
||
| # Config | ||
| assert cfg.train.batch_size % world_size == 0 | ||
| assert cfg.train.epoch_size % (cfg.train.batch_size * cfg.train.accumulation) == 0 | ||
| assert cfg.train.epoch_size % cfg.train.batch_size == 0 | ||
| assert cfg.train.batch_size % (cfg.train.accumulation * world_size) == 0 | ||
|
|
||
| runname = f"{runid}_{cfg.dataset.name}_{cfg.ae.name}" | ||
|
|
||
|
|
@@ -86,7 +87,7 @@ def train(runid: str, cfg: DictConfig): | |
| path=cfg.server.datasets, | ||
| physics=cfg.dataset.physics, | ||
| split=split, | ||
| steps=1, | ||
| steps=cfg.dataset.steps, | ||
| include_filters=cfg.dataset.include_filters, | ||
| augment=cfg.dataset.augment, | ||
| ) | ||
|
|
@@ -96,7 +97,7 @@ def train(runid: str, cfg: DictConfig): | |
| train_loader, valid_loader = [ | ||
| get_dataloader( | ||
| dataset=dataset[split], | ||
| batch_size=cfg.train.batch_size // world_size, | ||
| batch_size=cfg.train.batch_size // cfg.train.accumulation // world_size, | ||
| shuffle=True if split == "train" else False, | ||
| infinite=True, | ||
| num_workers=cfg.compute.cpus_per_gpu, | ||
|
|
@@ -119,11 +120,13 @@ def train(runid: str, cfg: DictConfig): | |
| pix_channels=dataset["train"].metadata.n_fields, | ||
| **cfg.ae, | ||
| ).to(device) | ||
| if rank == 0: | ||
| print(autoencoder) | ||
|
|
||
| autoencoder_loss = WeightedLoss(**cfg.ae.loss).to(device) | ||
|
|
||
| if cfg.fork.run is not None: | ||
| autoencoder.load_state_dict(stem_state) | ||
| autoencoder.load_state_dict(stem_state, strict=cfg.fork.strict) | ||
| del stem_state | ||
|
|
||
| autoencoder = DistributedDataParallel( | ||
|
|
@@ -138,7 +141,7 @@ def train(runid: str, cfg: DictConfig): | |
| ) | ||
|
|
||
| # W&B | ||
| if rank == 0: | ||
| if rank == 0 and not cfg.wandb.dry_run: | ||
| run = wandb.init( | ||
| entity=cfg.wandb.entity, | ||
| project="mpp-ae", | ||
|
|
@@ -162,7 +165,7 @@ def train(runid: str, cfg: DictConfig): | |
| for i in range(cfg.train.epoch_size // cfg.train.batch_size): | ||
| x, _ = get_well_inputs(next(train_loader), device=device) | ||
| x = preprocess(x) | ||
| x = rearrange(x, "B 1 H W C -> B C H W") | ||
| x = rearrange(x, "B T H W C -> B C T H W") | ||
|
|
||
| if (i + 1) % cfg.train.accumulation == 0: | ||
| y, z = autoencoder(x) | ||
|
|
@@ -173,7 +176,7 @@ def train(runid: str, cfg: DictConfig): | |
| grad_norm = safe_gd_step(optimizer, grad_clip=cfg.optim.grad_clip) | ||
| grads.append(grad_norm) | ||
|
|
||
| counter["update_samples"] += cfg.train.batch_size * cfg.train.accumulation | ||
| counter["update_samples"] += cfg.train.batch_size | ||
| counter["update_steps"] += 1 | ||
| else: | ||
| with autoencoder.no_sync(): | ||
|
|
@@ -221,7 +224,7 @@ def train(runid: str, cfg: DictConfig): | |
| for _ in range(cfg.train.epoch_size // cfg.train.batch_size): | ||
| x, _ = get_well_inputs(next(valid_loader), device=device) | ||
| x = preprocess(x) | ||
| x = rearrange(x, "B 1 H W C -> B C H W") | ||
| x = rearrange(x, "B T H W C -> B C T H W") | ||
|
|
||
| y, z = autoencoder(x) | ||
| loss = autoencoder_loss(x, y) | ||
|
|
@@ -281,7 +284,7 @@ def train(runid: str, cfg: DictConfig): | |
|
|
||
| # Config | ||
| cfg = compose( | ||
| config_file="./configs/train_ae.yaml", | ||
| config_file=os.path.join(os.path.dirname(__file__), "configs", "train_ae.yaml"), | ||
|
Collaborator
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. This should not be necessary. |
||
| overrides=args.overrides, | ||
| ) | ||
|
|
||
|
|
||
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.
Good catch! Introduced in a51de35.