Skip to content

About

No description, website, or topics provided.

Resources

Contributing

Stars

43 stars

Watchers

0 watching

Forks

Repository files navigation

ML Goodput Measurement

PyPI Python License

Goodput is the share of a training workload's wall-clock time spent on preserved, productive work: training steps that completed and were not lost to a restart or rollback. Badput is the remainder, attributed to its cause: accelerator initialization, program startup and compilation, data loading, checkpoint save and restore, evaluation and other custom events, disruptions and the progress they wasted. It is a workload-level metric: one number for the whole job, across all hosts and restarts, computed from the job's own timeline. Goodput says how much accelerator time became training progress; the Badput breakdown says what to fix.

ml-goodput-measurement records the timestamps that define these intervals from any Python training loop (JAX, PyTorch, or any other framework), stores them in Google Cloud Logging, and computes Goodput, the Badput breakdown and step-time deviation on demand or continuously, with export to TensorBoard and Google Cloud Monitoring for dashboards and alerting.

Install

pip install ml-goodput-measurement

Requires a Google Cloud project with the Cloud Logging API enabled; see Prerequisites.

Quick start

from ml_goodput_measurement import goodput

# Record from exactly one process per job (the lead process).
recorder = goodput.GoodputRecorder(
    job_name=run_name, logger_name=f"goodput_{run_name}", logging_enabled=is_lead
)
recorder.record_job_start_time()
for step in range(num_steps):
  recorder.record_step_start_time(step)
  train_step()
recorder.record_job_end_time()

# Compute from anywhere with access to the project's logs.
calculator = goodput.GoodputCalculator(
    job_name=run_name, logger_name=f"goodput_{run_name}"
)
goodput_pct, badput, last_step = calculator.get_job_goodput(
    include_badput_breakdown=True
)

A 100-step run with checkpoints every 25 steps reports, for example:

% of wall-clock
Goodput 52.5
PROGRAM_STARTUP 20.0
UNPRODUCTIVE_CHECKPOINT_SAVE_TIME 11.7
OTHER 8.0
TRAINING_PREP 4.3
DATA_LOADING_SYNC 3.5

Recording the optional intervals (initialization, data loading, checkpointing, custom events such as evaluation) attributes more of the Badput; GoodputMonitor uploads the numbers while the job runs. For asynchronous backends such as PyTorch on TPU, StepClock takes step boundaries from accelerator events.

How it works

  • GoodputRecorder runs in the training process on the lead host and writes timestamped entries to Cloud Logging; nothing blocks the training loop.
  • GoodputCalculator reads the job's entries from anywhere with access to the project, keeps a local cache, and computes Goodput, the Badput breakdown and step-time deviation.
  • GoodputMonitor runs the calculator on a schedule and uploads the results to TensorBoard and Google Cloud Monitoring.

Guides

Goodput timeline

The goodput timeline renders a workload's goodput logs as an HTML page: Goodput, disruptions and the breakdown of each recovery on a timeline of the workload's runs. Its compare command puts several workloads side by side.

Goodput timeline overview of a workload with two interruptions

Synthetic data.

pip install "ml-goodput-measurement[timeline]"
python -m ml_goodput_measurement.timeline --command=list --project_id=my-gcp-project

See the timeline README.

Integrations

  • MaxText (JAX): reference integration

Releases

  • 0.2.5: monitor no longer freezes after a restart on the same host; late-visible log entries are read; StepClock, bounded final flush, min_step_time
  • 0.2.4: elastic restart and checkpoint calculation fixes; custom badput events in the last step are counted
  • 0.2.3: GCS cache sync for faster cold-start reads

Full history in CHANGELOG.md.

Contributing and support

See CONTRIBUTING.md. Questions and bug reports: GitHub issues. Apache-2.0 licensed.

About

No description, website, or topics provided.

Resources

Contributing

Stars

43 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages