Skip to content

add benchmark-qgpu script - #46

Merged
goodstudyqaq merged 2 commits into
feature/qgpufrom
feature/qgpu-benchmark-script
Oct 23, 2025
Merged

goodstudyqaq merged 2 commits into
feature/qgpufrom
feature/qgpu-benchmark-script

Conversation

@goodstudyqaq

Copy link
Copy Markdown
Collaborator

No description provided.

@goodstudyqaq goodstudyqaq changed the title add genchmark-qgpu script add benchmark-qgpu script Oct 22, 2025
@goodstudyqaq
goodstudyqaq requested a review from Copilot October 22, 2025 09:20

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread benchmark-qgpu/benchmark_run.py Outdated
Comment on lines +1 to +4
import subprocess
import time
import multiprocessing
import os

Copilot AI Oct 22, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lines 1-4 are redundant and duplicated by line 5. Remove lines 1-4 to eliminate duplicate imports.

Suggested change
import subprocess
import time
import multiprocessing
import os

Copilot uses AI. Check for mistakes.
Comment thread benchmark-qgpu/benchmark_run.py Outdated
Comment on lines +1 to +11
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

Copilot AI Oct 22, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Imports csv, glob, os, and datetime are duplicated across lines 5-11. Consolidate all imports at the top without duplication.

Suggested change
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

Copilot uses AI. Check for mistakes.
Comment thread benchmark-qgpu/benchmark_run.py Outdated

def _sample_gpu_util_pct_nvsmi():
"""Fallback: query overall GPU util (%) via nvidia-smi; returns average across GPUs."""
import shutil, subprocess

Copilot AI Oct 22, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shutil and subprocess are already imported at the module level (line 5). Remove this redundant import statement.

Copilot uses AI. Check for mistakes.
Comment thread benchmark-qgpu/benchmark_run.py Outdated
return None

def _sample_gpu_mem_util_pct_nvsmi():
import shutil, subprocess

Copilot AI Oct 22, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shutil and subprocess are already imported at the module level (line 5). Remove this redundant import statement.

Copilot uses AI. Check for mistakes.
Comment thread benchmark-qgpu/benchmark_run.py Outdated
gpu_util_mean = None
gpu_util_peak = None
s = peaks_holder.get("gpu_util_samples", 0)
if s and s > 0:

Copilot AI Oct 22, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The condition 's and s > 0' is redundant. A non-zero positive integer is already truthy, so simplify to 'if s > 0:'

Suggested change
if s and s > 0:
if s > 0:

Copilot uses AI. Check for mistakes.
Comment thread benchmark-qgpu/benchmark_report.py Outdated
@@ -0,0 +1,154 @@
import os
import os

Copilot AI Oct 22, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

os is imported twice. Remove the duplicate import.

Suggested change
import os

Copilot uses AI. Check for mistakes.
Comment thread benchmark-qgpu/benchmark_report.py Outdated
Comment on lines +2 to +7
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

Copilot AI Oct 22, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Multiple imports (csv, glob, os, re, statistics, datetime) are duplicated across lines 1-7. Consolidate all imports into a single block without repetition.

Suggested change
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

Copilot uses AI. Check for mistakes.
@goodstudyqaq
goodstudyqaq requested a review from Copilot October 22, 2025 13:19

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread benchmark-qgpu/main.py
Comment on lines +3 to +4


Copilot AI Oct 22, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove extraneous trailing whitespace on line 3.

Suggested change

Copilot uses AI. Check for mistakes.

TIME_STEP = 2 * 1e-6 # 2fs per step = 0.000002 ns per step


Copilot AI Oct 22, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove extraneous trailing whitespace on line 17.

Suggested change

Copilot uses AI. Check for mistakes.
vals = []
for line in out.strip().splitlines():
parts = [p.strip() for p in line.split(",")]
if len(parts) != 2:

Copilot AI Oct 22, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove trailing whitespace after the colon on line 88.

Suggested change
if len(parts) != 2:
if len(parts) != 2:

Copilot uses AI. Check for mistakes.
Comment on lines +118 to +120
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}

Copilot AI Oct 22, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inconsistent indentation in the dictionary initialization. Lines 119-120 should align with line 118.

Suggested change
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
}

Copilot uses AI. Check for mistakes.
"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,

Copilot AI Oct 22, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
"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,

Copilot uses AI. Check for mistakes.




Copilot AI Oct 22, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove extraneous trailing whitespace on line 404.

Suggested change

Copilot uses AI. Check for mistakes.
@goodstudyqaq
goodstudyqaq merged commit b8122ad into feature/qgpu Oct 23, 2025
@ChielJespers
ChielJespers deleted the feature/qgpu-benchmark-script branch March 2, 2026 08:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants