#!/usr/bin/env python3 """Minimal DTK/PyTorch smoke test used before the full BW1000 suite.""" import json import torch try: import torch_dcu # noqa: F401 except ImportError: pass def main() -> None: count = torch.cuda.device_count() if not torch.cuda.is_available() or count < 1: raise SystemExit("DTK PyTorch reports no available accelerator") devices = [] for index in range(count): props = torch.cuda.get_device_properties(index) devices.append({ "index": index, "name": torch.cuda.get_device_name(index), "memory_gib": round(props.total_memory / 1024**3, 2), }) a = torch.randn(2048, 2048, device="cuda:0", dtype=torch.bfloat16) b = torch.randn(2048, 2048, device="cuda:0", dtype=torch.bfloat16) c = a @ b torch.cuda.synchronize() if not torch.isfinite(c).all().item(): raise SystemExit("BF16 matmul produced non-finite output") print(json.dumps({ "torch_version": torch.__version__, "cuda_api_available": torch.cuda.is_available(), "device_count": count, "devices": devices, "bf16_matmul": "PASS", "checksum": round(float(c.float().mean().item()), 6), }, indent=2)) if __name__ == "__main__": main()