Repository navigation
add benchmark-qgpu script - #46
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR introduces a benchmark script for measuring the performance of Qdyn GPU simulations. The tooling enables comparative benchmarking between CPU-only and GPU-accelerated runs with varying levels of parallelism.
Key changes:
- Comprehensive resource monitoring (CPU RAM, GPU VRAM, GPU utilization)
- Parallel process execution with configurable concurrency
- HTML report generation with interactive charts for performance visualization
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 7 comments.
| File | Description |
|---|---|
| benchmark-qgpu/main.py | Entry point for the benchmark tool with argument parsing |
| benchmark-qgpu/benchmark_run.py | Core benchmarking logic including process execution, resource monitoring, and metrics collection |
| benchmark-qgpu/benchmark_report.py | Report generation module that aggregates metrics and renders HTML output |
| benchmark-qgpu/benchmark_report.html.j2 | Jinja2 template for HTML benchmark reports with embedded charts and summary tables |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| import subprocess | ||
| import time | ||
| import multiprocessing | ||
| import os |
There was a problem hiding this comment.
Lines 1-4 are redundant and duplicated by line 5. Remove lines 1-4 to eliminate duplicate imports.
| import subprocess | |
| import time | |
| import multiprocessing | |
| import os |
| import subprocess | ||
| import time | ||
| import multiprocessing | ||
| import os | ||
| import os, time, subprocess, multiprocessing, threading, shutil, json, sys | ||
| from datetime import datetime | ||
| import glob, csv | ||
| import psutil | ||
| import csv, glob | ||
| import os, csv, glob | ||
| from datetime import datetime |
There was a problem hiding this comment.
Imports csv, glob, os, and datetime are duplicated across lines 5-11. Consolidate all imports at the top without duplication.
| import subprocess | |
| import time | |
| import multiprocessing | |
| import os | |
| import os, time, subprocess, multiprocessing, threading, shutil, json, sys | |
| from datetime import datetime | |
| import glob, csv | |
| import psutil | |
| import csv, glob | |
| import os, csv, glob | |
| from datetime import datetime | |
| import os | |
| import time | |
| import subprocess | |
| import multiprocessing | |
| import threading | |
| import shutil | |
| import json | |
| import sys | |
| from datetime import datetime | |
| import glob | |
| import csv | |
| import psutil |
|
|
||
| def _sample_gpu_util_pct_nvsmi(): | ||
| """Fallback: query overall GPU util (%) via nvidia-smi; returns average across GPUs.""" | ||
| import shutil, subprocess |
There was a problem hiding this comment.
shutil and subprocess are already imported at the module level (line 5). Remove this redundant import statement.
| return None | ||
|
|
||
| def _sample_gpu_mem_util_pct_nvsmi(): | ||
| import shutil, subprocess |
There was a problem hiding this comment.
shutil and subprocess are already imported at the module level (line 5). Remove this redundant import statement.
| gpu_util_mean = None | ||
| gpu_util_peak = None | ||
| s = peaks_holder.get("gpu_util_samples", 0) | ||
| if s and s > 0: |
There was a problem hiding this comment.
The condition 's and s > 0' is redundant. A non-zero positive integer is already truthy, so simplify to 'if s > 0:'
| if s and s > 0: | |
| if s > 0: |
| @@ -0,0 +1,154 @@ | |||
| import os | |||
| import os | |||
There was a problem hiding this comment.
os is imported twice. Remove the duplicate import.
| import os |
| import os | ||
| from datetime import datetime | ||
| import glob, csv | ||
| import re, csv, statistics, glob | ||
| import os, csv, glob, re, math, statistics | ||
| from datetime import datetime |
There was a problem hiding this comment.
Multiple imports (csv, glob, os, re, statistics, datetime) are duplicated across lines 1-7. Consolidate all imports into a single block without repetition.
| import os | |
| from datetime import datetime | |
| import glob, csv | |
| import re, csv, statistics, glob | |
| import os, csv, glob, re, math, statistics | |
| from datetime import datetime | |
| import glob | |
| import csv | |
| import re | |
| import statistics | |
| import math | |
| from datetime import datetime |
There was a problem hiding this comment.
Pull Request Overview
Copilot reviewed 4 out of 4 changed files in this pull request and generated 6 comments.
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
|
|
||
|
|
There was a problem hiding this comment.
Remove extraneous trailing whitespace on line 3.
|
|
||
| TIME_STEP = 2 * 1e-6 # 2fs per step = 0.000002 ns per step | ||
|
|
||
|
|
There was a problem hiding this comment.
Remove extraneous trailing whitespace on line 17.
| vals = [] | ||
| for line in out.strip().splitlines(): | ||
| parts = [p.strip() for p in line.split(",")] | ||
| if len(parts) != 2: |
There was a problem hiding this comment.
Remove trailing whitespace after the colon on line 88.
| if len(parts) != 2: | |
| if len(parts) != 2: |
| peaks = {"peak_rss_bytes": 0, "peak_gpu_mem_mb": 0.0, | ||
| "gpu_util_peak_pct": 0.0, "gpu_util_sum_pct": 0.0, "gpu_util_samples": 0, | ||
| "gpu_mem_util_peak_pct": 0.0, "gpu_mem_util_sum_pct": 0.0, "gpu_mem_util_samples": 0} |
There was a problem hiding this comment.
Inconsistent indentation in the dictionary initialization. Lines 119-120 should align with line 118.
| peaks = {"peak_rss_bytes": 0, "peak_gpu_mem_mb": 0.0, | |
| "gpu_util_peak_pct": 0.0, "gpu_util_sum_pct": 0.0, "gpu_util_samples": 0, | |
| "gpu_mem_util_peak_pct": 0.0, "gpu_mem_util_sum_pct": 0.0, "gpu_mem_util_samples": 0} | |
| peaks = { | |
| "peak_rss_bytes": 0, | |
| "peak_gpu_mem_mb": 0.0, | |
| "gpu_util_peak_pct": 0.0, | |
| "gpu_util_sum_pct": 0.0, | |
| "gpu_util_samples": 0, | |
| "gpu_mem_util_peak_pct": 0.0, | |
| "gpu_mem_util_sum_pct": 0.0, | |
| "gpu_mem_util_samples": 0 | |
| } |
| "command": m.get("command"), | ||
| "timestamp": m.get("timestamp"), | ||
| "steps": m.get("steps"), | ||
| "ns_per_day": (m.get("steps") * TIME_STEP * 86400) / _get(m, "time.wall_seconds") if _get(m, "time.wall_seconds") else None, |
There was a problem hiding this comment.
Division by zero protection is insufficient. The check if _get(m, 'time.wall_seconds') will allow division by zero when wall_seconds is 0.0. Use if _get(m, 'time.wall_seconds') and _get(m, 'time.wall_seconds') > 0 instead.
| "ns_per_day": (m.get("steps") * TIME_STEP * 86400) / _get(m, "time.wall_seconds") if _get(m, "time.wall_seconds") else None, | |
| "ns_per_day": (m.get("steps") * TIME_STEP * 86400) / _get(m, "time.wall_seconds") if _get(m, "time.wall_seconds") and _get(m, "time.wall_seconds") > 0 else None, |
|
|
||
|
|
||
|
|
||
|
|
There was a problem hiding this comment.
Remove extraneous trailing whitespace on line 404.
No description provided.