Skip to content

Commit ed45549

Browse files
committed
Add PCIe transfer benchmark (H2D/D2H) to Ironwood
- Implement benchmark_pcie_transfer.py to measure H2D and D2H transfer performance using JAX, supporting various transfer modes (Standard, Parallel, Threaded, Chunked). - Integrate the new benchmark into run_benchmark.py. - Add configuration files for single device, single chip, and single VM topologies in configs/pcie_transfer/. - Add scripts/run_pcie_transfer_benchmark.sh for bulk execution with numactl interleaving option.
1 parent 1e6c308 commit ed45549

8 files changed

Lines changed: 504 additions & 0 deletions
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
benchmarks:
2+
- benchmark_name: pcie_transfer
3+
num_runs: 20
4+
benchmark_sweep_params:
5+
# Single Chip (2 Devices)
6+
- {mesh_shape: "1x2", data_size_mb_list: [1, 16, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768]}
7+
8+
csv_path: "../microbenchmarks/pcie_transfer/single_chip"
9+
trace_dir: "../microbenchmarks/pcie_transfer/single_chip/trace"
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
benchmarks:
2+
- benchmark_name: pcie_transfer
3+
num_runs: 20
4+
benchmark_sweep_params:
5+
# Single Device
6+
- {mesh_shape: "1", data_size_mb_list: [1, 16, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768]}
7+
8+
csv_path: "../microbenchmarks/pcie_transfer/single_device"
9+
trace_dir: "../microbenchmarks/pcie_transfer/single_device/trace"
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
benchmarks:
2+
- benchmark_name: pcie_transfer
3+
num_runs: 20
4+
benchmark_sweep_params:
5+
# Single VM (4 Chips, 8 Devices)
6+
- {mesh_shape: "2x4", data_size_mb_list: [1, 16, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768]}
7+
8+
csv_path: "../microbenchmarks/pcie_transfer/single_vm"
9+
trace_dir: "../microbenchmarks/pcie_transfer/single_vm/trace"
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# PCIe Transfer Microbenchmarks on tpu7x-2x2x1
2+
3+
This guide provides instructions for running PCIe Transfer (Host-to-Device and Device-to-Host) microbenchmarks on tpu7x-2x2x1 Google Kubernetes Engine (GKE) clusters. It covers creating a node pool, running the benchmarks, and viewing the output.
4+
5+
> [!NOTE]
6+
> This benchmark is currently a Work In Progress (WIP). Expected bandwidth numbers are not yet finalized.
7+
8+
## Create Node Pools
9+
10+
Follow [Setup section](../../Ironwood_Microbenchmarks_readme.md#setup) to create a GKE cluster with one 2x2x1 nodepool.
11+
12+
## Run PCIe Transfer Microbenchmarks
13+
14+
To run the PCIe transfer microbenchmarks, apply the following Kubernetes configuration:
15+
```bash
16+
kubectl apply -f tpu7x-pcie-transfer-benchmark.yaml
17+
```
18+
19+
To extract the log of the microbenchmark, use `kubectl logs`:
20+
```bash
21+
kubectl logs tpu7x-pcie-transfer-benchmark
22+
```
23+
24+
Once the benchmark completes, you should see logs reporting bandwidth statistics (e.g., `H2D_Standard_bw (GiB/s)_p50`, `D2H_Standard_bw (GiB/s)_p50`) and latency.
25+
26+
To retrieve the complete results, including the trace and CSV output files, you must keep the pod running after the benchmark completes. To do this, add a `sleep` command to the `tpu7x-pcie-transfer-benchmark.yaml` file. You can then use `kubectl cp` to copy the output from the pod.
27+
28+
```bash
29+
kubectl cp tpu7x-2x2x1-pcie-transfer-microbenchmark:/microbenchmarks/pcie_transfer pcie_transfer
30+
```
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
apiVersion: v1
2+
kind: Pod
3+
metadata:
4+
name: tpu7x-pcie-transfer-benchmark
5+
spec:
6+
restartPolicy: Never
7+
nodeSelector:
8+
cloud.google.com/gke-tpu-accelerator: tpu7x
9+
cloud.google.com/gke-tpu-topology: 2x2x1
10+
containers:
11+
- name: tpu-job
12+
image: python:3.12
13+
ports:
14+
- containerPort: 8431
15+
securityContext:
16+
privileged: false
17+
command:
18+
- bash
19+
- -c
20+
- |
21+
set -ex
22+
23+
git clone https://github.com/AI-Hypercomputer/accelerator-microbenchmarks.git
24+
cd accelerator-microbenchmarks
25+
pip install -r requirements.txt
26+
27+
bash ./Ironwood/scripts/run_pcie_transfer_benchmark.sh
28+
29+
resources:
30+
requests:
31+
google.com/tpu: 4
32+
limits:
33+
google.com/tpu: 4
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
#!/bin/bash
2+
3+
# Default values
4+
CONFIG_DIR="Ironwood/configs/pcie_transfer"
5+
SPECIFIC_CONFIG=""
6+
INTERLEAVED=false
7+
8+
# Helper function for usage
9+
usage() {
10+
echo "Usage: $0 [OPTIONS]"
11+
echo "Options:"
12+
echo " --config <path> Path to specific config file (optional)"
13+
echo " --interleaved Run with numactl --interleave=all"
14+
echo " --help Show this help message"
15+
exit 1
16+
}
17+
18+
# Parse arguments
19+
while [[ "$#" -gt 0 ]]; do
20+
case $1 in
21+
--config) SPECIFIC_CONFIG="$2"; shift ;;
22+
--interleaved) INTERLEAVED=true ;;
23+
--help) usage ;;
24+
*) echo "Unknown parameter passed: $1"; usage ;;
25+
esac
26+
shift
27+
done
28+
29+
echo "--- Starting PCIe Transfer Benchmark (H2D/D2H) ---"
30+
echo "Note: This benchmark is work in progress"
31+
echo "Interleaved: $INTERLEAVED"
32+
33+
if [ -n "$SPECIFIC_CONFIG" ]; then
34+
CONFIGS=("$SPECIFIC_CONFIG")
35+
else
36+
# Use nullglob to handle case where no files match (though unlikely here)
37+
shopt -s nullglob
38+
CONFIGS=("$CONFIG_DIR"/*.yaml)
39+
shopt -u nullglob
40+
fi
41+
42+
if [ ${#CONFIGS[@]} -eq 0 ]; then
43+
echo "No configuration files found!"
44+
exit 1
45+
fi
46+
47+
for CONFIG_FILE in "${CONFIGS[@]}"; do
48+
echo "--- Running Config: $CONFIG_FILE ---"
49+
CMD="python Ironwood/src/run_benchmark.py --config=${CONFIG_FILE}"
50+
51+
if [ "$INTERLEAVED" = true ]; then
52+
if command -v numactl &> /dev/null; then
53+
echo "Running with numactl --interleave=all"
54+
numactl --interleave=all $CMD
55+
else
56+
echo "Warning: numactl not found. Running without interleaving."
57+
$CMD
58+
fi
59+
else
60+
$CMD
61+
fi
62+
echo "--- Finished Config: $CONFIG_FILE ---"
63+
echo ""
64+
done
65+
66+
echo "--- All Benchmarks Finished ---"

0 commit comments

Comments
 (0)