-
Notifications
You must be signed in to change notification settings - Fork 977
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/main' into model_sampling
- Loading branch information
Showing
35 changed files
with
821 additions
and
456 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains 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 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,6 +1,5 @@ | ||
#!/usr/bin/env python | ||
|
||
# Copyright 2021 (c) Josh Levy-Kramer <[email protected]>. All rights reserved. | ||
# Copyright (c) 2021, EleutherAI contributors | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
|
@@ -17,11 +16,11 @@ | |
from socket import gethostname | ||
|
||
import shortuuid | ||
import sys | ||
import os | ||
import deepspeed | ||
from deepspeed.launcher.runner import main | ||
import requests | ||
import subprocess | ||
|
||
from megatron.config_monster import ConfigMonster | ||
import logging | ||
|
@@ -30,6 +29,7 @@ | |
|
||
logging.basicConfig(level=os.environ.get("LOGLEVEL", "INFO")) | ||
|
||
|
||
def get_wandb_api_key(): | ||
""" Get Weights and Biases API key from ENV or .netrc file. Otherwise return None """ | ||
if 'WANDB_API_KEY' in os.environ: | ||
|
@@ -40,10 +40,22 @@ def get_wandb_api_key(): | |
if wandb_token is not None: | ||
return wandb_token[1] | ||
|
||
|
||
def get_git_commit_hash(): | ||
""" Gets the git commit hash of your current repo (if it exists) """ | ||
try: | ||
git_hash = git_hash = subprocess.check_output(["git", "describe", "--always"]).strip() | ||
git_hash = git_hash.decode() | ||
except subprocess.CalledProcessError: | ||
git_hash = None | ||
return git_hash | ||
|
||
|
||
# Generate unique run group name | ||
wandb_group = shortuuid.uuid() | ||
default_conf = { | ||
'wandb_group': wandb_group | ||
extra_conf = { | ||
'wandb_group': wandb_group, | ||
'git_hash': get_git_commit_hash() | ||
} | ||
|
||
# Extract wandb API key and inject into worker environments | ||
|
@@ -52,12 +64,12 @@ def get_wandb_api_key(): | |
deepspeed.launcher.runner.EXPORT_ENVS.append('WANDB_API_KEY') | ||
os.environ['WANDB_API_KEY'] = wandb_token | ||
|
||
old_style_args, conf = ConfigMonster().consume_args(default_conf=default_conf) | ||
old_style_args, conf = ConfigMonster().consume_args(default_conf=extra_conf) | ||
|
||
if 'log-dir' in conf: | ||
os.makedirs(conf['log-dir'], exist_ok=True) | ||
file_prefix = os.path.join(conf['log-dir'], '0-deepy') | ||
Tee(file_prefix+'_stdout.txt', err=False) | ||
Tee(file_prefix + '_stdout.txt', err=False) | ||
Tee(file_prefix + '_stderr.txt', err=True) | ||
|
||
if 'save' in conf: | ||
|
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains 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 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 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,4 +1,16 @@ | ||
# Copyright 2021 (c) Josh Levy-Kramer <[email protected]>. All rights reserved. | ||
# Copyright (c) 2021, EleutherAI contributors | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http:https://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
import argparse | ||
import json | ||
|
@@ -9,6 +21,7 @@ | |
|
||
from megatron.utils import obtain_resource_pool | ||
from megatron.arguments import _get_parser | ||
import torch | ||
|
||
log = logging.getLogger('ConfigMonster') | ||
|
||
|
@@ -25,7 +38,7 @@ def _get_megatron_keys(_megatron_keys_exclude): | |
|
||
|
||
ds_runner_keys = ['hostfile', 'include', 'exclude', 'num_nodes', 'num_gpus', 'master_port', 'master_addr', 'launcher', | ||
'launcher_args'] # handle separately: 'user_script', 'user_args' | ||
'launcher_args', 'detect_nvlink_pairs'] # handle separately: 'user_script', 'user_args' | ||
|
||
megatron_keys_exclude = [ | ||
'fp16', # Duplicated in ds_config | ||
|
@@ -46,7 +59,7 @@ def _get_megatron_keys(_megatron_keys_exclude): | |
'dump_state', 'flops_profiler', 'activation_checkpointing', 'sparse_attention', | ||
'zero_allow_untested_optimizer', ] | ||
|
||
neox_config_keys = ['wandb_group', 'wandb_team'] | ||
neox_config_keys = ['wandb_group', 'wandb_team', 'git_hash'] | ||
|
||
ds_runner_keys_exclude = [] | ||
|
||
|
@@ -267,6 +280,11 @@ def parse_args(parser: argparse.ArgumentParser, args=None, extra_conf=None, defa | |
if args.conf_dir: | ||
conf_files = [os.path.join(args.conf_dir, f) for f in conf_files] | ||
|
||
# enables us to pass in `small` instead of `small.yml` | ||
for cf in conf_files: | ||
if not cf.endswith('.yml'): | ||
cf += '.yml' | ||
|
||
# Load and merge all configuration | ||
conf = {} if extra_conf is None else extra_conf | ||
for path in conf_files: | ||
|
@@ -313,7 +331,11 @@ def derive_params_and_split(conf): | |
hostfile_path = conf.get('hostfile', DLTS_HOSTFILE) | ||
resources = obtain_resource_pool(hostfile_path, conf.get('include', ''), conf.get('exclude', '')) | ||
num_gpus = sum(map(len, resources.values())) | ||
log.info(f"Total number of GPUs determined to be: {num_gpus}") | ||
else: | ||
num_gpus = torch.cuda.device_count() | ||
conf["num_gpus"] = num_gpus | ||
|
||
log.info(f"Total number of GPUs determined to be: {num_gpus}") | ||
|
||
# get world size in the model/pipe parallel case, the actual `world size` deepspeed uses is the size of the | ||
# data-parallel group, or (num_gpus / mp_size) / pp_size | ||
|
This file contains 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 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 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,6 +1,7 @@ | ||
# coding=utf-8 | ||
# Copyright 2021 Josh Levy-Kramer <[email protected]> et al. | ||
# Copyright (c) 2021, EleutherAI contributors | ||
# This file is based on code by the authors denoted below and has been modified from its original version. | ||
# | ||
# Copyright (c) 2020, NVIDIA CORPORATION. All rights reserved. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
|
Oops, something went wrong.