-
Notifications
You must be signed in to change notification settings - Fork 3
[NEW DEVICES AND MLP] H100 and batch_norm mlp #56
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 all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
32931fe
mlp models for h100
johncalesp 1d858b7
register new mlp batch_norm
johncalesp e7b4f1d
fixed limited record number
johncalesp 994bc1d
new batch_norm model
johncalesp 79c11ef
changed how we colapse batch_norm2d
johncalesp f96058d
reverted to original batch sizes
johncalesp 7a09055
update batch norm MLP with a40 and a4000 data
johncalesp 3cb49e8
changed order of image_size and channels
johncalesp 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
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
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
Git LFS file not shown
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 |
|---|---|---|
| @@ -0,0 +1,94 @@ | ||
| import argparse | ||
| import logging | ||
| import math | ||
| import torch | ||
| from record_common import Measurer | ||
| import features as f | ||
|
|
||
| logger = logging.getLogger(__name__) | ||
|
|
||
| torch.backends.cudnn.benchmark = False | ||
|
|
||
| def index_to_config(args, index): | ||
| batch = (index % args.batches) + 1 | ||
| index //= args.batches | ||
|
|
||
| channels = (index % args.channels) + 1 | ||
| index //= args.image_size | ||
|
|
||
| image_size = (index % args.image_size) + 1 | ||
|
|
||
| return ( | ||
| batch, | ||
| image_size, | ||
| channels, | ||
| ) | ||
|
|
||
| def index_filter(args, index): | ||
| config = index_to_config(args, index) # (batch, channels, image_size) | ||
| # NOTE: We multiply because the dimensions have different ranges; we want | ||
| # them to each "contribute equally". We weigh the image size more to | ||
| # select smaller image sizes. | ||
| # image_size (1-dim) * channels | ||
| batchnorm_size = math.pow(config[1], 1.15) * config[2] | ||
|
|
||
| # NOTE: This value was chosen arbitrarily: we don't want the | ||
| # channels and image size to all be too large. This way, large values | ||
| # for the channels would lead to a smaller image size (and | ||
| # vice versa). | ||
|
|
||
| # NOTE: batch size can't be 1. in _verify_batch_size | ||
| # raise ValueError(f"Expected more than 1 value per channel when training, got input size {size}") | ||
| return batchnorm_size <= 35000000 and config[0] > 1 | ||
|
|
||
| def config_to_profiler_args(config): | ||
| ( | ||
| batch, | ||
| image_size, | ||
| channels, | ||
| ) = config | ||
|
|
||
| device = torch.device('cuda') | ||
| batchnorm = torch.nn.BatchNorm2d(channels).to(device) | ||
| inp = torch.randn((batch, channels, image_size, image_size), device=device) | ||
| inp = inp.requires_grad_() | ||
|
|
||
| return { | ||
| 'func': batchnorm, | ||
| 'args': (inp, ), | ||
| 'kwargs': {}, | ||
| } | ||
|
|
||
| def main(): | ||
| measurer = Measurer( | ||
| op_name = 'batch_norm', | ||
| recorder_config=f.batch_norm, | ||
| index_to_config=index_to_config, | ||
| index_filter=index_filter, | ||
| config_to_profiler_args=config_to_profiler_args | ||
| ) | ||
|
|
||
| parser = argparse.ArgumentParser() | ||
| measurer.add_args(parser) | ||
| parser.add_argument('--batches', type=int, default=64) | ||
| parser.add_argument('--image-size', type=int, default=256) | ||
| parser.add_argument('--channels', type=int, default=2048) | ||
|
|
||
| args = parser.parse_args() | ||
|
|
||
| num_configs = ( | ||
| args.batches * | ||
| args.image_size * | ||
| args.channels | ||
| ) | ||
|
|
||
| measurer.measure_configurations(args, num_configs) | ||
|
|
||
| if __name__ == '__main__': | ||
|
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. Identical blocks of code found in 6 locations. Consider refactoring. |
||
| kwargs = { | ||
| "format": "%(asctime)s %(levelname)-8s %(message)s", | ||
| "datefmt": "%Y-%m-%d %H:%M", | ||
| "level": logging.INFO, | ||
| } | ||
| logging.basicConfig(**kwargs) | ||
| main() | ||
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.
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.
Avoid too many
returnstatements within this function.