Skip to content

Fix gemm_multiple_run to report the slowest TPU device - #140

Merged
linamy85 merged 1 commit into
AI-Hypercomputer:chsfrom
shivam222:feature/fix_gemm
Oct 5, 2026
Merged

linamy85 merged 1 commit into
AI-Hypercomputer:chsfrom
shivam222:feature/fix_gemm

Conversation

@shivam222

@shivam222 shivam222 commented Sep 28, 2026 •

Copy link
Copy Markdown
Collaborator

Earlier, per-iteration durations were taken only from the lowest-PID device (TPU-0). XLA:TPU has no end-of-program barrier, so a slower non-zero device does not show up in TPU-0's timings, and a degraded chip on the host went unreported.

Now gemm_multiple_run groups trace durations by device and reports the device with the lowest median throughput.

Median is used because CHS compares the reported Throughput (median) against its threshold. That figure is the median of total_flops / duration, and total_flops is the same on every device, so selecting by median of 1/duration picks exactly the device with the lowest throughput CHS checks.

Testing

  • Unit tests on synthetic traces: slowest device selected across 2 and 4 devices, median-of-1/duration rule with an even number of runs, events without device_duration_ps ignored, default behavior still returns TPU-0, and gemm_multiple_run passes report_slowest_device=True.
  • Used the changes to do e2e run of CHS

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a report_slowest_device option to TPU benchmarking utilities, allowing the slowest device's durations to be reported when XLA:TPU lacks an end-of-program barrier. The feedback suggests several improvements: safely retrieving the pid from trace events to avoid potential KeyErrors, removing a verbose debug print statement that clutters logs, and addressing a potential bypass of the new logic when no marker events are found.

Comment thread Ironwood/src/benchmark_utils.py
Comment thread Ironwood/src/benchmark_utils.py
Comment thread Ironwood/src/benchmark_utils.py
Comment thread Ironwood/src/benchmark_gemm.py Outdated
Comment thread Ironwood/src/benchmark_gemm.py Outdated
run_on_local_node: bool = False,
report_slowest_device: bool = True,
) -> Dict[str, Any]:
del report_slowest_device

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Why do we need to del?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Because run_benchmark.py passes the exact same YAML config dictionary (**benchmark_param) to both functions.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Rather than del, we should consider recording report_slowest_device in metadata such that it's clear if we're using the designated mode.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Done

Earlier, per-iteration durations were taken only from the lowest-PID
device (TPU-0). XLA:TPU has no end-of-program barrier, so a slower
non-zero device does not show up in TPU-0's timings, and a degraded
chip on the host went unreported.

Now gemm_multiple_run groups trace durations by device and reports the
device with the lowest median throughput.

Median is used because CHS compares the reported Throughput (median)
against its threshold. That figure is the median of
total_flops / duration, and total_flops is the same on every device, so
selecting by median of 1/duration picks exactly the device with the
lowest throughput CHS checks.

Testing
- Unit tests on synthetic traces: slowest device selected across 2 and
  4 devices, median-of-1/duration rule with an even number of runs,
  events without device_duration_ps ignored, default behavior still
  returns TPU-0, and gemm_multiple_run passes report_slowest_device=True.
@linamy85
linamy85 merged commit cd8741d into AI-Hypercomputer:chs Oct 5, 2026
2 checks passed
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.

2 participants