-
Notifications
You must be signed in to change notification settings - Fork 5k
Fix autotuner crash when an experiment produces no metric #8421
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
base: master
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -79,6 +79,27 @@ def test_autotuner_resources(tmpdir, active_resources): | |
| assert expected_num_gpus == tuner.exp_num_gpus | ||
|
|
||
|
|
||
| def test_get_best_space_record_ignores_runs_without_a_metric(tmpdir): | ||
|
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.
Commit AGENTS.md reference: AGENTS.md:L8-L8 Useful? React with 👍 / 👎.
Contributor
Author
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. This looks like it's pointing at a commit that isn't part of this PR (23e6d10f3f9...). The actual commit here is 5c25751, which does have a Signed-off-by trailer, you can see it with git log or the commits tab. |
||
| # A run that fails to produce a metric (e.g. OOM) is recorded with metric_val=None. | ||
| # get_best_space_record used to crash with "TypeError: '>' not supported between | ||
| # instances of 'NoneType' and 'NoneType'" whenever every run in a space had no | ||
| # metric, discarding all previously gathered results for the whole tuning run. | ||
| config_dict = {"autotuning": {"enabled": True, "exps_dir": os.path.join(tmpdir, 'exps_dir'), "arg_mappings": {}}} | ||
| config_path = create_config_from_dict(tmpdir, config_dict) | ||
| args = dsrun.parse_args(args=f'--autotuning {TUNE_OPTION} foo.py --deepspeed_config {config_path}'.split()) | ||
| tuner = Autotuner(args=args, active_resources={"worker-0": [0, 1]}) | ||
|
|
||
| tuner.update_records("z0_space", {"name": "exp1"}, None, 1) | ||
| tuner.update_records("z0_space", {"name": "exp2"}, None, 1) | ||
| assert tuner.get_best_space_record("z0_space") is None | ||
|
|
||
| tuner.update_records("z0_space", {"name": "exp3"}, 3.5, 1) | ||
| best = tuner.get_best_space_record("z0_space") | ||
| assert best[0]["name"] == "exp3" | ||
| assert best[1] == 3.5 | ||
| assert best[2] == 3 | ||
|
|
||
|
|
||
| def test_get_val_by_key_searches_all_nested_subdicts(): | ||
| # get_val_by_key must mirror its sibling set_val_by_key: both walk every | ||
| # nested subdict, not just the first one. Here 'device' lives in the SECOND | ||
|
|
||
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.
When a fast micro-batch pass records only one
Nonemetric (for example, a user-specified micro-batch list whose run writes a null metric), this branch now makesget_best_space_record()returnNone;tune_space()then unconditionally evaluatesfast_best_record[0]['name']at line 586. That turns a case which previously completed with a single such record into a'NoneType' object is not subscriptablefailure, so the caller must avoid dereferencing the missing record.Useful? React with 👍 / 👎.
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.
Good catch, this was a real regression. Fixed in 7d770d0: fast_best_record[0]['name'] now goes through the same None-safe ternary as fast_best_mbs and fast_best_metric_val on the lines right above it.