Skip to content

Commit 1a8356d

Browse files
mawad-amdclaudegithub-actions[bot]
authored
Add environment version reporting to CI workflows (#538)
Co-authored-by: Claude Opus 4 <noreply@anthropic.com> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
1 parent 0c3be44 commit 1a8356d

6 files changed

Lines changed: 157 additions & 0 deletions

File tree

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
#!/usr/bin/env python3
2+
# SPDX-License-Identifier: MIT
3+
# Copyright (c) 2025 Advanced Micro Devices, Inc. All rights reserved.
4+
"""Collect environment versions and emit JSON to stdout.
5+
6+
Runs inside the CI container. The calling shell script handles
7+
$GITHUB_STEP_SUMMARY and stdout formatting on the host side.
8+
"""
9+
10+
import json
11+
import os
12+
import subprocess
13+
import sys
14+
15+
16+
def collect():
17+
info = {}
18+
19+
# Driver + ROCm via amd-smi version --json
20+
try:
21+
raw = subprocess.check_output(
22+
["amd-smi", "version", "--json"],
23+
stderr=subprocess.DEVNULL,
24+
timeout=10,
25+
)
26+
smi = json.loads(raw)
27+
if isinstance(smi, list):
28+
smi = smi[0]
29+
info["driver"] = smi.get("amdgpu_version", "")
30+
info["rocm"] = smi.get("rocm_version", "")
31+
except Exception:
32+
pass
33+
34+
# ROCm fallback from filesystem
35+
if not info.get("rocm"):
36+
for p in ["/opt/rocm/.info/version", "/opt/rocm/lib/rocm_version"]:
37+
if os.path.isfile(p):
38+
info["rocm"] = open(p).read().strip()
39+
break
40+
41+
# Python
42+
v = sys.version_info
43+
info["python"] = f"{v.major}.{v.minor}.{v.micro}"
44+
45+
# PyTorch, HIP, GPU
46+
try:
47+
import torch
48+
49+
info["torch"] = torch.__version__
50+
info["hip"] = getattr(torch.version, "hip", None) or getattr(torch.version, "cuda", None) or ""
51+
info["gpu_count"] = torch.cuda.device_count()
52+
if torch.cuda.device_count() > 0:
53+
props = torch.cuda.get_device_properties(0)
54+
info["gpu_name"] = props.name
55+
info["gpu_arch"] = getattr(props, "gcnArchName", "N/A")
56+
except Exception:
57+
pass
58+
59+
# Triton
60+
try:
61+
import triton
62+
63+
info["triton"] = triton.__version__
64+
except Exception:
65+
pass
66+
67+
# Kernel
68+
try:
69+
info["kernel"] = os.uname().release
70+
except Exception:
71+
pass
72+
73+
return info
74+
75+
76+
if __name__ == "__main__":
77+
print(json.dumps(collect()))

.github/scripts/report_versions.sh

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
#!/bin/bash
2+
# SPDX-License-Identifier: MIT
3+
# Copyright (c) 2025 Advanced Micro Devices, Inc. All rights reserved.
4+
#
5+
# Collect environment versions from inside the container and write
6+
# a GitHub Actions job summary table. Version collection logic lives
7+
# in collect_versions.py; this script handles container exec + summary.
8+
9+
set -e
10+
11+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
12+
13+
GPU_ARG=""
14+
if [ -n "$GPU_DEVICES" ]; then
15+
GPU_ARG="--gpus $GPU_DEVICES"
16+
fi
17+
18+
# Run collect_versions.py inside the container, extract JSON line
19+
# shellcheck disable=SC2086
20+
RAW=$("$SCRIPT_DIR/container_exec.sh" $GPU_ARG "python3 /iris_workspace/.github/scripts/collect_versions.py")
21+
VERSION_JSON=$(echo "$RAW" | grep '^{' | tail -1)
22+
23+
if [ -z "$VERSION_JSON" ]; then
24+
echo "[WARN] Failed to collect version info"
25+
exit 0
26+
fi
27+
28+
# Format and print with Python on the host (available on all runners)
29+
python3 -c "
30+
import json, sys, os
31+
32+
d = json.loads(sys.argv[1])
33+
34+
def g(k):
35+
return str(d.get(k, 'unknown'))
36+
37+
gpu = f\"{g('gpu_name')} ({g('gpu_arch')}) x {g('gpu_count')}\"
38+
39+
print('============================================')
40+
print(' Iris CI - Environment Report')
41+
print('============================================')
42+
for label, key in [('Driver', 'driver'), ('ROCm', 'rocm'), ('Python', 'python'),
43+
('PyTorch', 'torch'), ('HIP', 'hip'), ('Triton', 'triton')]:
44+
print(f' {label:9s} {g(key)}')
45+
print(f' {\"GPU\":9s} {gpu}')
46+
print(f' {\"Kernel\":9s} {g(\"kernel\")}')
47+
print('============================================')
48+
49+
summary_path = os.environ.get('GITHUB_STEP_SUMMARY')
50+
if summary_path:
51+
with open(summary_path, 'a') as f:
52+
f.write('### Environment\n\n')
53+
f.write('| Component | Version |\n')
54+
f.write('|-----------|--------|\n')
55+
for label, key in [('Driver', 'driver'), ('ROCm', 'rocm'), ('Python', 'python'),
56+
('PyTorch', 'torch'), ('HIP', 'hip'), ('Triton', 'triton')]:
57+
f.write(f'| {label} | {g(key)} |\n')
58+
f.write(f'| GPU | {gpu} |\n')
59+
f.write(f'| Kernel | {g(\"kernel\")} |\n\n')
60+
" "$VERSION_JSON"

.github/workflows/iris-external-validation-test.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,10 @@ jobs:
4343
run: |
4444
bash .github/scripts/acquire_gpus.sh 2
4545
46+
- name: Report environment versions
47+
run: |
48+
bash .github/scripts/report_versions.sh
49+
4650
- name: Run External Validation Test
4751
run: |
4852
set -e
@@ -92,6 +96,10 @@ jobs:
9296
run: |
9397
bash .github/scripts/acquire_gpus.sh 2
9498
99+
- name: Report environment versions
100+
run: |
101+
bash .github/scripts/report_versions.sh
102+
95103
- name: Run External Gluon Validation Test
96104
run: |
97105
set -e

.github/workflows/iris-nightly-triton-test.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,10 @@ jobs:
105105
run: |
106106
bash .github/scripts/acquire_gpus.sh "${{ matrix.num_ranks }}"
107107
108+
- name: Report environment versions
109+
run: |
110+
bash .github/scripts/report_versions.sh
111+
108112
- name: Run ${{ matrix.test_dir }} tests with ${{ matrix.num_ranks }} ranks (nightly Triton)
109113
run: |
110114
set -e

.github/workflows/iris-performance-regression-test.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,10 @@ jobs:
6767
run: |
6868
bash .github/scripts/acquire_gpus.sh 8
6969
70+
- name: Report environment versions
71+
run: |
72+
bash .github/scripts/report_versions.sh
73+
7074
- name: Run ${{ matrix.example_name }} Benchmark (8 ranks)
7175
run: |
7276
set -e

.github/workflows/iris-tests.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,10 @@ jobs:
8888
run: |
8989
bash .github/scripts/acquire_gpus.sh "${{ matrix.num_ranks }}"
9090
91+
- name: Report environment versions
92+
run: |
93+
bash .github/scripts/report_versions.sh
94+
9195
- name: Run ${{ matrix.test_dir }} tests with ${{ matrix.num_ranks }} ranks (git install)
9296
env:
9397
GITHUB_REPOSITORY: ${{ github.repository }}

0 commit comments

Comments
 (0)