Skip to content

Fix autotuner latency ranking and the FLOPS metric name - #8767

Open
Aravind-11 wants to merge 1 commit into
deepspeedai:masterfrom
Aravind-11:fix-autotune-metric-direction
Open

Aravind-11 wants to merge 1 commit into
deepspeedai:masterfrom
Aravind-11:fix-autotune-metric-direction

Conversation

@Aravind-11

Copy link
Copy Markdown

Fixes #8766

The bug

"metric": "latency" keeps the largest latency, so ds_config_optimal.json is the slowest trial. get_best_space_record, get_best_space_records, ResourceManager.parse_results, and BaseTuner.tune all use >. Throughput and FLOPS are larger-is-better. Latency is the step time, so the smaller number is the better config. find_estimated_top_configs already reverses the sort for latency. The selectors that publish the winner do not.

The engine writes FLOPS as FLOPS_per_gpu (DeepSpeedEngine._autotuning_exit). The README tells users to set "FLOPS", and AUTOTUNING_METRIC_FLOPS is "flops". results[metric] raises KeyError for either name. On the fast path that read is in run_tuning_micro_batch_sizes, outside the tuner's try, so the run aborts.

The fix

metric_is_better in deepspeed/autotuning/utils.py is the one comparison. Latency replaces the incumbent only when it is smaller. Every other metric replaces it only when it is larger. None never wins.

metric_value maps "flops" and "FLOPS" to FLOPS_per_gpu. An exact key already present in the file still wins.

The cross-stage check treats a previous metric of 0 as "no previous stage", not as a measured latency of zero. A real latency is not compared against that sentinel. Throughput ranking is unchanged.

Testing

CPU tests in tests/unit/autotuning/test_autotuning.py:

  • "FLOPS", "flops", and "FLOPS_per_gpu" read the engine's field
  • latency keeps the smaller value, including the global winner across spaces
  • throughput still keeps the larger value
  • parse_results does both
  • BaseTuner.tune keeps the smaller latency and does not let a missing metric replace a real one
  • the 0 sentinel does not count as a regression for latency or throughput

tests/unit/autotuning/test_autotuning.py passes (18 tests). yapf and flake8 are clean on the changed files. No GPU run.

cc @loadams

Latency is lower-is-better, but every selector kept the largest number, so
metric "latency" returned the slowest config. "flops" and "FLOPS" now read
the FLOPS_per_gpu field the training run writes.

Signed-off-by: ARAVINDHAN T <arvindhant01@gmail.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] Autotuner latency metric keeps the slowest config, and FLOPS does not match metrics.json

1 participant