From d9619587b45f05f6c0449f184a5386c754238896 Mon Sep 17 00:00:00 2001 From: TPUMS Team Date: Tue, 17 Nov 2026 17:58:29 -0800 Subject: [PATCH] [tpums] specs: Use the bfloat16 peak for float32 compute rooflines float32 GEMM reported roofline efficiency above 100% because the float32 peak was set to half the bfloat16 peak. MXU multiplies take bfloat16 inputs (https://docs.cloud.google.com/tpu/docs/system-architecture-tpu-vm) and the benchmarks run at JAX's default matmul precision, so a float32 matmul is a single bfloat16 pass. Set the float32 peak to the bfloat16 peak for tpu7x and v6e. PiperOrigin-RevId: 1024209837 --- docs/BENCHMARKS.md | 14 ++++++++++++++ src/accelerator_microbenchmarks/specs/tpu7x.py | 6 +++++- src/accelerator_microbenchmarks/specs/v6e.py | 6 +++++- tests/test_system.py | 4 ++-- 4 files changed, 26 insertions(+), 4 deletions(-) diff --git a/docs/BENCHMARKS.md b/docs/BENCHMARKS.md index 5c178c60..fca0bc44 100644 --- a/docs/BENCHMARKS.md +++ b/docs/BENCHMARKS.md @@ -141,6 +141,20 @@ The table below summarizes which `` and `` each ben | `use_scaling_factors` | `bool` | `False` | Allocate and apply row-wise (`M × 1`) and column-wise (`1 × N`) `float32` scaling factor vectors for quantized/FP8 rescaling. | | `seed` | `int` | `0` | PRNG seed for initializing input tensors in HBM. | +> [!NOTE] +> **`float32` shares the `bfloat16` peak.** MXU multiplies take `bfloat16` +> inputs and accumulate in `float32` (see +> [TPU architecture](https://docs.cloud.google.com/tpu/docs/system-architecture-tpu-vm)), +> and the GEMM benchmarks pass no `precision` to the matmul, so JAX's default +> precision applies and a `float32` matmul runs as one `bfloat16` pass. JAX's +> [precision levels](https://docs.jax.dev/en/latest/201/precision.html#precision-the-classic-three-levels) +> affect only `float32` computations. On TPU: +> +> - `Precision.DEFAULT` (what TPUMS runs): fastest, least accurate; computes in +> `bfloat16`. +> - `Precision.HIGH`: slower, more accurate; three `bfloat16` passes. +> - `Precision.HIGHEST`: slowest, most accurate; six `bfloat16` passes. + #### Reported Metrics - **Compute Throughput & Roofline**: diff --git a/src/accelerator_microbenchmarks/specs/tpu7x.py b/src/accelerator_microbenchmarks/specs/tpu7x.py index a7a15997..a9f0b1e9 100644 --- a/src/accelerator_microbenchmarks/specs/tpu7x.py +++ b/src/accelerator_microbenchmarks/specs/tpu7x.py @@ -10,7 +10,11 @@ tflops=schema.TflopsSpec( peak_tflops_per_device={ "bfloat16": 1153.5, - "float32": 576.75, # 2-pass BF16 emulation on MXU + # Same peak as bfloat16: MXU multiplies take bfloat16 inputs and + # accumulate in FP32, so a float32 matmul at JAX's default + # precision is one bfloat16 pass (see docs/BENCHMARKS.md). + # https://docs.cloud.google.com/tpu/docs/system-architecture-tpu-vm + "float32": 1153.5, "float8_e5m2": 2307.0, "float8_e4m3fn": 2307.0, "int8": 1153.5, # Emulated on BF16 datapath diff --git a/src/accelerator_microbenchmarks/specs/v6e.py b/src/accelerator_microbenchmarks/specs/v6e.py index 0018d525..11af34a1 100644 --- a/src/accelerator_microbenchmarks/specs/v6e.py +++ b/src/accelerator_microbenchmarks/specs/v6e.py @@ -10,7 +10,11 @@ tflops=schema.TflopsSpec( peak_tflops_per_device={ "bfloat16": 918.0, - "float32": 459.0, # 2-pass BF16 emulation on MXU + # Same peak as bfloat16: MXU multiplies take bfloat16 inputs and + # accumulate in FP32, so a float32 matmul at JAX's default + # precision is one bfloat16 pass (see docs/BENCHMARKS.md). + # https://docs.cloud.google.com/tpu/docs/system-architecture-tpu-vm + "float32": 918.0, "float8_e5m2": 918.0, "float8_e4m3fn": 918.0, "int8": 1836.0, diff --git a/tests/test_system.py b/tests/test_system.py index 0b220ae6..17d138fc 100644 --- a/tests/test_system.py +++ b/tests/test_system.py @@ -179,7 +179,7 @@ def test_hardware_spec_tpu7x_presets(self): self.assertEqual( hw_spec.tflops.peak_tflops_per_device["bfloat16"], 1153.5 ) - self.assertEqual(hw_spec.tflops.peak_tflops_per_device["float32"], 576.75) + self.assertEqual(hw_spec.tflops.peak_tflops_per_device["float32"], 1153.5) self.assertEqual( hw_spec.tflops.peak_tflops_per_device["float8_e5m2"], 2307.0 ) @@ -215,7 +215,7 @@ def test_hardware_spec_v6e_presets(self): self.assertEqual( hw_spec.tflops.peak_tflops_per_device["bfloat16"], 918.0 ) - self.assertEqual(hw_spec.tflops.peak_tflops_per_device["float32"], 459.0) + self.assertEqual(hw_spec.tflops.peak_tflops_per_device["float32"], 918.0) self.assertEqual( hw_spec.tflops.peak_tflops_per_device["float8_e5m2"], 918.0 )