-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for compliance for 4.1 (#382)
Some changes slipped and were not changed in #381 This PR fixes it.
- Loading branch information
1 parent
5190494
commit 9b5f1b4
Showing
26 changed files
with
828 additions
and
30 deletions.
There are no files selected for viewing
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
105 changes: 105 additions & 0 deletions
105
mlperf_logging/compliance_checker/mlp_parser/ruleset_410.py
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 |
---|---|---|
@@ -0,0 +1,105 @@ | ||
''' | ||
Parses a text MLPerf log into a structured format. | ||
''' | ||
|
||
from __future__ import print_function | ||
|
||
import collections | ||
import json | ||
import re | ||
import sys | ||
from dataclasses import dataclass | ||
|
||
from io import open | ||
|
||
@dataclass | ||
class LogLine: | ||
"""Class for keeping track of an item in inventory.""" | ||
full_string: str | ||
timestamp: float | ||
key: str | ||
value: str | ||
lineno: int | ||
|
||
TOKEN = ':::MLLOG ' | ||
|
||
|
||
def parse_line(line): | ||
if not line.startswith(TOKEN): | ||
return None | ||
|
||
return json.loads(line[len(TOKEN):]) | ||
|
||
|
||
def string_to_logline(lineno, string): | ||
''' Returns a LogLine or raises a ValueError ''' | ||
m = parse_line(string) | ||
|
||
if m is None: | ||
raise ValueError('does not match regex') | ||
|
||
args = [] | ||
args.append(string) # full string | ||
|
||
ts = float(m['time_ms']) # may raise error, e.g. "1.2.3" | ||
# TODO check for weird values | ||
args.append(ts) | ||
|
||
args.append(m['key']) # key | ||
|
||
j = { 'value': m['value'], 'metadata': m['metadata'] } | ||
args.append(j) | ||
|
||
args.append(lineno) | ||
return LogLine(*args) | ||
|
||
|
||
def parse_file(filename): | ||
''' Reads a file by name and returns list of loglines and list of errors''' | ||
with open(filename, encoding='latin-1') as f: | ||
return parse_generator(f) | ||
|
||
|
||
def strip_and_dedup(gen): | ||
lines = [] | ||
for l in gen: | ||
if TOKEN not in l: | ||
continue | ||
lines.append(re.sub(".*"+TOKEN, TOKEN, l)) | ||
return lines | ||
|
||
|
||
|
||
def parse_generator(gen): | ||
''' Reads a generator of lines and returns (loglines, errors) | ||
The list of errors are any parsing issues as a tuple (str_line, error_msg) | ||
''' | ||
loglines = [] | ||
failed = [] | ||
for lineno, line in enumerate(strip_and_dedup(gen)): | ||
line = line.strip() | ||
try: | ||
ll = string_to_logline(lineno, line) | ||
loglines.append(ll) | ||
except ValueError as e: | ||
failed.append((line, str(e))) | ||
return loglines, failed | ||
|
||
|
||
if __name__ == '__main__': | ||
if len(sys.argv) != 2: | ||
print('usage: mlp_parser.py FILENAME') | ||
print(' tests parsing on the file.') | ||
sys.exit(1) | ||
|
||
filename = sys.argv[1] | ||
lines, errors = parse_file(filename) | ||
|
||
print('Parsed {} log lines with {} errors.'.format(len(lines), len(errors))) | ||
|
||
if len(errors) > 0: | ||
print('Lines which failed to parse:') | ||
for line, error in errors: | ||
print(' Following line failed: {}'.format(error)) | ||
print(line) | ||
|
48 changes: 48 additions & 0 deletions
48
mlperf_logging/compliance_checker/training_4.1.0/closed_bert.yaml
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 |
---|---|---|
@@ -0,0 +1,48 @@ | ||
- KEY: | ||
NAME: global_batch_size | ||
REQ: EXACTLY_ONE | ||
POST: > | ||
s['global_batch_size'] = v['value'] | ||
- KEY: | ||
NAME: opt_base_learning_rate | ||
REQ: EXACTLY_ONE | ||
|
||
- KEY: | ||
NAME: opt_lamb_epsilon | ||
REQ: EXACTLY_ONE | ||
|
||
- KEY: | ||
NAME: opt_learning_rate_training_steps | ||
REQ: EXACTLY_ONE | ||
|
||
- KEY: | ||
NAME: opt_learning_rate_warmup_steps | ||
REQ: EXACTLY_ONE | ||
|
||
- KEY: | ||
NAME: num_warmup_steps | ||
REQ: EXACTLY_ONE | ||
|
||
- KEY: | ||
NAME: start_warmup_step | ||
REQ: EXACTLY_ONE | ||
|
||
- KEY: | ||
NAME: opt_lamb_beta_1 | ||
REQ: EXACTLY_ONE | ||
|
||
- KEY: | ||
NAME: opt_lamb_beta_2 | ||
REQ: EXACTLY_ONE | ||
|
||
- KEY: | ||
NAME: opt_lamb_weight_decay_rate | ||
REQ: EXACTLY_ONE | ||
|
||
- KEY: | ||
NAME: eval_accuracy | ||
REQ: AT_LEAST_ONE | ||
CHECK: | ||
- "'epoch_num' in v['metadata']" | ||
ATLEAST_ONE_CHECK: "(v['value'] >= 0.720) and v['value'] < 1.0" |
11 changes: 11 additions & 0 deletions
11
mlperf_logging/compliance_checker/training_4.1.0/closed_common.yaml
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 |
---|---|---|
@@ -0,0 +1,11 @@ | ||
|
||
- KEY: | ||
NAME: submission_benchmark | ||
REQ: EXACTLY_ONE | ||
CHECK: " v['value'] in ['resnet', 'ssd', 'stable_diffusion', 'maskrcnn', 'gpt3', 'dlrm_dcnv2', 'bert', 'rnnt', 'unet3d', 'gnn','llama2_70b_lora'] " | ||
POST: " enqueue_config('training_4.1.0/closed_{}.yaml'.format(v['value'])) " | ||
|
||
- KEY: | ||
NAME: gradient_accumulation_steps | ||
REQ: EXACTLY_ONE | ||
CHECK: " v['value'] > 0 " |
59 changes: 59 additions & 0 deletions
59
mlperf_logging/compliance_checker/training_4.1.0/closed_dlrm_dcnv2.yaml
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 |
---|---|---|
@@ -0,0 +1,59 @@ | ||
- KEY: | ||
NAME: global_batch_size | ||
REQ: EXACTLY_ONE | ||
|
||
- KEY: | ||
NAME: opt_name | ||
REQ: EXACTLY_ONE | ||
CHECK: " v['value'] == 'adagrad' " | ||
|
||
- KEY: | ||
NAME: opt_base_learning_rate | ||
REQ: EXACTLY_ONE | ||
|
||
- KEY: | ||
NAME: opt_adagrad_learning_rate_decay | ||
REQ: EXACTLY_ONE | ||
CHECK: " v['value'] == 0 " | ||
|
||
- KEY: | ||
NAME: opt_weight_decay | ||
REQ: EXACTLY_ONE | ||
CHECK: " v['value'] == 0 " | ||
|
||
- KEY: | ||
NAME: opt_adagrad_initial_accumulator_value | ||
REQ: EXACTLY_ONE | ||
CHECK: " v['value'] == 0 " | ||
|
||
- KEY: | ||
NAME: opt_adagrad_epsilon | ||
REQ: EXACTLY_ONE | ||
CHECK: " v['value'] == 1e-8 " | ||
|
||
- KEY: | ||
NAME: opt_learning_rate_warmup_steps | ||
REQ: EXACTLY_ONE | ||
CHECK: " v['value'] == 0 " | ||
|
||
- KEY: | ||
NAME: opt_learning_rate_decay_start_step | ||
REQ: EXACTLY_ONE | ||
CHECK: " v['value'] == 0 " | ||
|
||
- KEY: | ||
NAME: opt_learning_rate_decay_steps | ||
REQ: EXACTLY_ONE | ||
CHECK: " v['value'] == 0 " | ||
|
||
- KEY: | ||
NAME: eval_accuracy | ||
REQ: AT_LEAST_ONE | ||
CHECK: | ||
- "'epoch_num' in v['metadata']" | ||
ATLEAST_ONE_CHECK: "v['value'] >= 0.80275 and v['value'] <= 1.0" | ||
|
||
- KEY: | ||
NAME: eval_samples | ||
REQ: EXACTLY_ONE | ||
CHECK: " v['value'] == 89137319 " |
21 changes: 21 additions & 0 deletions
21
mlperf_logging/compliance_checker/training_4.1.0/closed_gnn.yaml
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 |
---|---|---|
@@ -0,0 +1,21 @@ | ||
- KEY: | ||
NAME: global_batch_size | ||
REQ: EXACTLY_ONE | ||
CHECK: " v['value'] > 0" | ||
|
||
- KEY: | ||
NAME: opt_name | ||
REQ: EXACTLY_ONE | ||
CHECK: " v['value'] == 'adam' " | ||
|
||
- KEY: | ||
NAME: opt_base_learning_rate | ||
REQ: EXACTLY_ONE | ||
CHECK: " v['value'] >= 0.0" | ||
|
||
- KEY: | ||
NAME: eval_accuracy | ||
REQ: AT_LEAST_ONE | ||
CHECK: | ||
- "'epoch_num' in v['metadata']" | ||
ATLEAST_ONE_CHECK: "v['value'] >= 0.72 and v['value'] < 1.0" |
Oops, something went wrong.