-
Notifications
You must be signed in to change notification settings - Fork 226
Floating-point ops counting and reloading #40
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
Merged
Changes from 16 commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
5196f8a
initial flo count/logging setup (need to fix model parameter count)
TevenLeScao a3a4ba4
initial flo count/logging setup (need to fix model parameter count)
TevenLeScao bdd75f1
1B3 parameter setup + flos counting
TevenLeScao c0fc29a
1B3 parameter setup + flos counting
TevenLeScao aefbe3b
1B3 parameter setup + flos counting
TevenLeScao 17e0184
1B3 parameter setup
TevenLeScao 97dd06d
1B3 parameter setup
TevenLeScao 64892e2
synched with latest 13B script
TevenLeScao 3c79aac
synched with latest 13B script
TevenLeScao b7b3167
pipe transformer docstring
8382141
improve DS integration evaluation + logging
06cb18f
use pp engine even for pp=1 (#6)
jeffra d581894
removed slurm_examples
60794bf
flos re-loading
TevenLeScao c79db1c
Merge branch 'main' into training_flos
TevenLeScao fb33f13
Update megatron/training.py
TevenLeScao dff1479
Update megatron/data/gpt_dataset.py
TevenLeScao 2fa3b5b
Update megatron/utils.py
TevenLeScao ff7af10
Update megatron/utils.py
TevenLeScao b9ac381
formatting fix, reserving bug for somewhere else, adding flo-logging …
TevenLeScao f25e25f
indentation bug
TevenLeScao e63503d
fixing possible double counts
TevenLeScao 5bdcf81
tweaks
TevenLeScao 72ad711
warning for double counts
TevenLeScao 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 |
|---|---|---|
|
|
@@ -43,7 +43,7 @@ | |
| from megatron.initialize import write_args_to_tensorboard | ||
| from megatron.learning_rates import AnnealingLR | ||
| from megatron.model import DistributedDataParallel as LocalDDP | ||
| from megatron.utils import check_adlr_autoresume_termination | ||
| from megatron.utils import check_adlr_autoresume_termination, get_parameters_in_billions | ||
| from megatron.utils import unwrap_model | ||
| from megatron.data.data_samplers import build_pretraining_data_loader | ||
| from megatron.utils import calc_params_l2_norm | ||
|
|
@@ -113,6 +113,8 @@ def pretrain(train_valid_test_dataset_provider, | |
| # Model, optimizer, and learning rate. | ||
| timers('model-and-optimizer-setup').start() | ||
| model, optimizer, lr_scheduler = setup_model_and_optimizer(model_provider) | ||
| print(f'estimated model parameters: {get_parameters_in_billions(model)}') | ||
| print(f'estimated model parameters without embeddings: {get_parameters_in_billions(model, exclude_embeddings=True)}') | ||
| timers('model-and-optimizer-setup').stop() | ||
| print_datetime('after model, optimizer, and learning rate ' | ||
| 'scheduler are built') | ||
|
|
@@ -545,7 +547,7 @@ def add_to_logging(name): | |
| total_loss_dict[skipped_iters_key] | ||
|
|
||
| # Tensorboard values. | ||
| if writer and (iteration % args.tensorboard_log_interval == 0 ) and \ | ||
| if writer and (iteration % args.tensorboard_log_interval == 0) and \ | ||
| is_last_rank(): | ||
| writer.add_scalar('steps-vs-samples/y=steps,x=samples', iteration, args.consumed_train_samples) | ||
| writer.add_scalar('steps-vs-samples/y=samples,x=steps', args.consumed_train_samples, iteration) | ||
|
|
@@ -647,6 +649,7 @@ def save_checkpoint_and_time(iteration, model, optimizer, lr_scheduler): | |
| def train(forward_step_func, model, optimizer, lr_scheduler, | ||
| train_data_iterator, valid_data_iterator): | ||
| """Train the model function.""" | ||
| print(f"Number of trainable parameters: {sum(p.numel() for submodel in model for p in submodel.parameters() if p.requires_grad)}") | ||
|
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. and this most likely needs to be fixed to remove double/triple-counting of tied vars: |
||
| args = get_args() | ||
| timers = get_timers() | ||
|
|
||
|
|
@@ -683,9 +686,11 @@ def train(forward_step_func, model, optimizer, lr_scheduler, | |
| optimizer, | ||
| lr_scheduler) | ||
| iteration += 1 | ||
| args.consumed_train_samples += mpu.get_data_parallel_world_size() * \ | ||
| new_samples = mpu.get_data_parallel_world_size() * \ | ||
| args.micro_batch_size * \ | ||
| get_num_microbatches() | ||
| args.consumed_train_samples += new_samples | ||
| args.gigaflos_no_embeds += (6 * new_samples * args.seq_length * get_parameters_in_billions(model, exclude_embeddings=True)) | ||
|
|
||
| # Logging. | ||
| if args.deepspeed: | ||
|
|
@@ -827,6 +832,9 @@ def evaluate_and_print_results(prefix, forward_step_func, | |
| writer.add_scalar(f'lm-loss-validation/{key} validation vs samples', | ||
| total_loss_dict[key].item(), | ||
| args.consumed_train_samples) | ||
| writer.add_scalar('{} validation vs gigaflos (without embeddings)'.format(key), | ||
| total_loss_dict[key].item(), | ||
| args.gigaflos_no_embeds) | ||
|
TevenLeScao marked this conversation as resolved.
|
||
| if args.log_validation_ppl_to_tensorboard: | ||
| writer.add_scalar(f'lm-loss-validation/{key} validation ppl', ppl, | ||
| iteration) | ||
|
|
||
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
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.
Uh oh!
There was an error while loading. Please reload this page.