Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
10 changes: 9 additions & 1 deletion tpu_sync/benchmarks/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,14 @@ filegroup(
visibility = ["//:internal"],
)

filegroup(
name = "gating_baselines",
srcs = [
"h2d_d2h_gating_jax_baselines.json",
"h2d_d2h_gating_torch_baselines.json",
],
)

py_library(
name = "bap_metrics",
testonly = True,
Expand Down Expand Up @@ -59,7 +67,7 @@ py_binary(
name = "h2d_d2h_benchmark_gating",
testonly = True,
srcs = ["h2d_d2h_benchmark_gating.py"],
data = ["h2d_d2h_gating_baselines.json"],
data = [":gating_baselines"],
deps = [
":bap_metrics",
":perf_core",
Expand Down
25 changes: 22 additions & 3 deletions tpu_sync/benchmarks/H2D_D2H_GATING_TEST.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,19 @@ bandwidth number**. This gate blocks a PR that regresses it.

## Setup

```mermaid
flowchart LR
J[("baselines.json")]
J -->|"read: configs, iters, warmup"| M["perf_core.measure()"]
M --> R["measured samples"]
R -->|"--record mode"| W["floor = median - 3.5*MADσ"]
W -->|"overwrite baseline_* and floor_*"| J
R -->|"gate mode (default)"| C{"median >= floor_*?"}
J -->|"read: floor_*"| C
C -->|yes| P["PASS"]
C -->|no| F["exit(1) — blocks the CL"]
```

The gate binary (`h2d_d2h_benchmark_gating.py`) measures, via `perf_core`, the
aggregate d2h and h2d bandwidth over the node's 8 chips.

Expand Down Expand Up @@ -75,13 +88,19 @@ A perf-floor failure blocks the PR, unless the author adds `[skip-perf-gate]`
## Running it

```bash
# Full gate across both JAX and PyTorch (default):
bazel run -c opt --config=oss --config=ci \
//tpu_sync/benchmarks:h2d_d2h_benchmark_gating

# Select a single framework:
bazel run -c opt --config=oss --config=ci \
//tpu_sync/benchmarks:h2d_d2h_benchmark_gating -- --framework=torch # or --framework=jax
```

In CI it runs as the `h2d_d2h_gating` workload in `benchmark_registry.pbtxt` via
the `run_benchmarks` workflow (on pull requests). Re-record baselines with the
`--record` flag (or the record workflow).
In CI it runs as the unified `h2d_d2h_gating` workload in `benchmark_registry.pbtxt`
via the `run_benchmarks` workflow (on pull requests), evaluating both frameworks
on the assigned Cloud TPU runner. Re-record baselines for all frameworks with
the `--record` flag (or the `h2d_d2h_record` workflow).

## Scope

Expand Down
16 changes: 14 additions & 2 deletions tpu_sync/benchmarks/benchmark_registry.pbtxt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
benchmarks {
name: "h2d_d2h_gating"
description: "Perf gate: 5 stable configs, fail if median Gbps drops >3% vs gating_baselines.json"
description: "Perf gate: stable configs across JAX and PyTorch, fail if median Gbps drops below statistical floor vs gating_baselines.json"
owner: "raiden-dev"

workload {
Expand All @@ -16,11 +16,23 @@ benchmarks {
workload_action_inputs { key: "bazel_run_flags" value: "-c opt --config=oss --config=ci" }
}

# Symmetrical framework metrics: JAX
metrics { name: "jax_int32_L1_8x128x1024x128/d2h_gbps" unit: "Gbps" stats { stat: MEAN } }
metrics { name: "jax_int32_L1_8x128x1024x128/h2d_gbps" unit: "Gbps" stats { stat: MEAN } }
metrics { name: "jax_float32_L1_8x128x1024x128/d2h_gbps" unit: "Gbps" stats { stat: MEAN } }
metrics { name: "jax_float32_L1_8x128x1024x128/h2d_gbps" unit: "Gbps" stats { stat: MEAN } }

# Symmetrical framework metrics: PyTorch
metrics { name: "torch_int32_L1_8x128x1024x128/d2h_gbps" unit: "Gbps" stats { stat: MEAN } }
metrics { name: "torch_int32_L1_8x128x1024x128/h2d_gbps" unit: "Gbps" stats { stat: MEAN } }
metrics { name: "torch_float32_L1_8x128x1024x128/d2h_gbps" unit: "Gbps" stats { stat: MEAN } }
metrics { name: "torch_float32_L1_8x128x1024x128/h2d_gbps" unit: "Gbps" stats { stat: MEAN } }

# Legacy un-prefixed aliases for MLCompass monitoring (go/tpu-sync-oss-mlcompass)
metrics { name: "int32_L1_8x128x1024x128/d2h_gbps" unit: "Gbps" stats { stat: MEAN } }
metrics { name: "int32_L1_8x128x1024x128/h2d_gbps" unit: "Gbps" stats { stat: MEAN } }
metrics { name: "float32_L1_8x128x1024x128/d2h_gbps" unit: "Gbps" stats { stat: MEAN } }
metrics { name: "float32_L1_8x128x1024x128/h2d_gbps" unit: "Gbps" stats { stat: MEAN } }

}

benchmarks {
Expand Down
Loading
Loading