Skip to content

[Userbenchmark] Add configuration support for test_bench #2592

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 5 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
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
30 changes: 30 additions & 0 deletions userbenchmark/test_bench/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,34 @@ def generate_model_configs_from_bisect_yaml(
return result


def generate_model_configs_from_yaml(
yaml_file: str,
) -> List[TorchBenchModelConfig]:
yaml_file_path = os.path.join(yaml_file)
assert os.path.exists(yaml_file_path)

with open(yaml_file_path, "r") as yf:
config_obj = yaml.safe_load(yf)
model_set = set(list_models(internal=False))
device = config_obj["device"]
configs = []
for model in model_set:
cfg = next(filter(lambda c: c["model"] == model, config_obj["models"]), None)
tests = cfg.get("tests", "eval") if cfg is not None else ["eval"]
for test in tests:
config = TorchBenchModelConfig(
name=model,
device=device,
test=test,
batch_size=cfg.get("batch_size", None) if cfg is not None else None,
extra_args=[],
skip=cfg is not None and cfg.get("skip", False),
)
print(config)
configs.append(config)
return configs
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This means that we always list all models and apply configuration on them.



def init_output_dir(
configs: List[TorchBenchModelConfig], output_dir: pathlib.Path
) -> List[TorchBenchModelConfig]:
Expand Down Expand Up @@ -340,6 +368,8 @@ def run(args: List[str]):
args, extra_args = parse_known_args(args)
if args.run_bisect:
configs = generate_model_configs_from_bisect_yaml(args.run_bisect)
elif args.config:
configs = generate_model_configs_from_yaml(args.config)
else:
modelset = set(list_models(internal=(not args.oss)))
timm_set = set(list_extended_models(suite_name="timm"))
Expand Down