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
27 changes: 27 additions & 0 deletions scripts/gpu_smoke_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
from __future__ import annotations

import argparse
import platform
import subprocess
import sys
import xml.etree.ElementTree as ET
from collections import OrderedDict
from pathlib import Path
Expand Down Expand Up @@ -64,6 +66,24 @@ def _get_git_commit() -> str:
return result.stdout.strip() or "unknown"


def _get_runtime_env() -> dict[str, str]:
env = {
"python": sys.version.split()[0],
"platform": platform.platform(),
}
try:
import torch

env["torch"] = torch.__version__
env["cuda_available"] = str(torch.cuda.is_available())
env["cuda_device_count"] = str(torch.cuda.device_count())
if torch.cuda.is_available() and torch.cuda.device_count() > 0:
env["cuda_device"] = torch.cuda.get_device_name(torch.cuda.current_device())
except Exception as exc:
env["torch"] = f"unavailable: {exc}"
return env


def parse_test_xml(path: str) -> list[dict[str, str]]:
tree = ET.parse(path)
results: list[dict[str, str]] = []
Expand Down Expand Up @@ -127,7 +147,14 @@ def generate_report(results: list[dict[str, str]], target: str) -> str:
f"| **Gpu-smoke Failures** | {len(failed_cases)} |",
f"| **Failures ops** | {failures_ops_str} |",
"",
"## Environment",
"",
"| Key | Value |",
"|:----|:------|",
]
for key, value in _get_runtime_env().items():
lines.append(f"| `{key}` | `{_escape_markdown_cell(value)}` |")
lines.append("")

if failed_cases:
lines.extend(
Expand Down
14 changes: 14 additions & 0 deletions tests/test_gpu_smoke_report_env.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
from scripts import gpu_smoke_report


def test_generate_report_includes_environment_section(monkeypatch):
monkeypatch.setattr(
gpu_smoke_report,
"_get_runtime_env",
lambda: {"python": "3.12.0", "cuda_available": "False"},
)

report = gpu_smoke_report.generate_report([], "quick")
assert "## Environment" in report
assert "| `python` | `3.12.0` |" in report
assert "| `cuda_available` | `False` |" in report
Loading