Skip to content

Add verbosity and refactor startup logging #1359

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 31 additions & 3 deletions megatron/neox_arguments/arguments.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ def from_ymls(cls, paths_to_yml_files: List[str], overwrite_values: Dict = None)
overwrite_values: If provided, overwrite any values in the yamls with these values
"""

print(cls.__name__ + ".from_ymls() " + str(paths_to_yml_files), flush=True)
print("Configuration Files" + str(paths_to_yml_files), flush=True)

# initialize an empty config dictionary to be filled by yamls
config = dict()
Expand Down Expand Up @@ -747,6 +747,22 @@ def enable_logging(self):
"""
enable Tee logs based on the configured logdir
"""

level_map = {
"quiet": logging.WARNING,
"default": logging.INFO,
"verbose": logging.INFO,
}
logging.basicConfig(
level=level_map[self.verbosity],
format="[%(asctime)s] [%(levelname)s] %(message)s",
datefmt="%Y-%m-%d %H:%M:%S",
force=True,
)

if self.verbosity == "quiet":
return

if self.log_dir:
os.makedirs(self.log_dir, exist_ok=True)
hostname = gethostname()
Expand All @@ -756,7 +772,17 @@ def enable_logging(self):

def print(self):
"""Print arguments."""
if self.rank == 0 or self.rank is None:
if self.verbosity == "quiet":
return
if self.verbosity == "default":
# just header/footer
if self.rank in (0, None):
print(
"------ GPT‑NeoX initialised (verbosity=default) ------", flush=True
)
return

if self.rank in (0, None):
print("-------------------- arguments --------------------", flush=True)
str_list = []
for arg in vars(self):
Expand Down Expand Up @@ -1086,7 +1112,9 @@ def calculate_derived(self):

# MoE config
if self.moe_num_experts > 1:
assert self.zero_optimization["stage"] < 2, "MoE is not compatible with zero stages 2 and 3"
assert (
self.zero_optimization["stage"] < 2
), "MoE is not compatible with zero stages 2 and 3"

# Attention config
if self.attention_config is None:
Expand Down
8 changes: 8 additions & 0 deletions megatron/neox_arguments/neox_args.py
Original file line number Diff line number Diff line change
Expand Up @@ -723,6 +723,14 @@ class NeoXArgsLogging(NeoXArgsTemplate):
"""Initialize wandb on all ranks."""
### END WANDB ARGS ###

verbosity: Literal["quiet", "default", "verbose"] = "verbose"
"""
Controls verbosity of startup
• quiet → suppress NeoXArgs argument dump, set python-logging to WARNING+
• default → show one-line banner, keep logging.INFO (Deepspeed etc.)
• verbose → *current behaviour* (full dump + INFO lines). 〈default〉
"""

git_hash: str = get_git_commit_hash()
"""current git hash of repository"""

Expand Down
Loading