Benchmarks: Micro benchmark - add nvbench based kernel-launch, sleep-kernel & auto-throughput#750
Benchmarks: Micro benchmark - add nvbench based kernel-launch, sleep-kernel & auto-throughput#750WenqingLan1 wants to merge 50 commits into
Conversation
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #750 +/- ##
==========================================
+ Coverage 86.02% 86.35% +0.33%
==========================================
Files 103 107 +4
Lines 7950 8173 +223
==========================================
+ Hits 6839 7058 +219
- Misses 1111 1115 +4
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 25 out of 29 changed files in this pull request and generated 5 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 25 out of 29 changed files in this pull request and generated 4 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 25 out of 29 changed files in this pull request and generated 7 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 25 out of 29 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| cmake_minimum_required(VERSION 3.18) | ||
| project(nvbench_benchmarks LANGUAGES CUDA) | ||
|
|
||
| # Check if we have a recent enough CMake for nvbench (which requires 3.30.4) | ||
| if(CMAKE_VERSION VERSION_LESS "3.30.4") | ||
| message(STATUS "CMake version ${CMAKE_VERSION} is less than 3.30.4 (required by nvbench), skipping nvbench benchmarks") | ||
| return() | ||
| endif() |
There was a problem hiding this comment.
This CMakeLists declares project(... LANGUAGES CUDA) before checking the CMake version / CUDA availability. If this directory is configured on a machine without a CUDA toolchain (or when CMake < 3.30.4), configuration can fail before reaching the intended “skip” logic. Consider moving the CMake version guard above project() and using project(... LANGUAGES CXX) + include(cuda_common.cmake)/enable_language(CUDA) only inside the CUDAToolkit_FOUND branch.
| cd ./nvbandwidth && git apply ../nvbandwidth.patch && cp ../nvbandwidth_testcases_patched.h ./testcases_patched.h && cmake . && make && cd .. | ||
| cp -v ./nvbandwidth/nvbandwidth $(SB_MICRO_PATH)/bin | ||
|
|
||
| # Build nvbench |
There was a problem hiding this comment.
New cuda_nvbench target isn’t listed in the Makefile’s .PHONY targets. If a file/directory named cuda_nvbench exists, make cuda_nvbench may become a no-op. Add cuda_nvbench to the .PHONY list to ensure the recipe always runs.
| # Build nvbench | |
| # Build nvbench | |
| .PHONY: cuda_nvbench |
| def parse_time_to_us(raw: str) -> float: | ||
| """Parse a time string like '123.45 us' or '1.5 s' to float microseconds.""" | ||
| raw = raw.strip() | ||
| m = re.match(r'^([\d.]+)\s*([mun]?s)?$', raw) | ||
| if not m: | ||
| raise ValueError(f'Invalid time string: {raw!r}') | ||
| val, unit = float(m.group(1)), (m.group(2) or 'us') | ||
| if unit == 's': | ||
| return val * 1e6 |
| 'BlasLtBaseBenchmark', 'ComputationCommunicationOverlap', 'CpuMemBwLatencyBenchmark', 'CpuHplBenchmark', | ||
| 'CpuStreamBenchmark', 'CublasBenchmark', 'CublasLtBenchmark', 'CudaGemmFlopsBenchmark', 'CudaMemBwBenchmark', | ||
| 'CudaNcclBwBenchmark', 'CudnnBenchmark', 'DiskBenchmark', 'DistInference', 'HipBlasLtBenchmark', 'GPCNetBenchmark', | ||
| 'GemmFlopsBenchmark', 'GpuBurnBenchmark', 'GpuCopyBwBenchmark', 'GpuStreamBenchmark', 'IBBenchmark', | ||
| 'IBLoopbackBenchmark', 'KernelLaunch', 'MemBwBenchmark', 'MicroBenchmark', 'MicroBenchmarkWithInvoke', | ||
| 'ORTInferenceBenchmark', 'RocmGemmFlopsBenchmark', 'RocmMemBwBenchmark', 'ShardingMatmul', | ||
| 'TCPConnectivityBenchmark', 'TensorRTInferenceBenchmark', 'DirectXGPUEncodingLatency', 'DirectXGPUCopyBw', | ||
| 'DirectXGPUMemBw', 'DirectXGPUCoreFlops', 'NvBandwidthBenchmark', 'NvbenchKernelLaunch', 'NvbenchSleepKernel', | ||
| 'NvbenchAutoThroughput' |
| find_package(CUDAToolkit QUIET) | ||
| if (CUDAToolkit_FOUND) | ||
| include(../cuda_common.cmake) | ||
|
|
||
| # Try to find nvbench, but don't require it | ||
| find_package(nvbench CONFIG QUIET) | ||
|
|
||
| if (nvbench_FOUND) | ||
| message(STATUS "Found nvbench, building nvbench benchmarks") |
| uses: lukka/get-cmake@latest | ||
| with: | ||
| cmakeVersion: '3.20.0' |
| def parse_time_to_us(raw: str) -> float: | ||
| """Parse a time string like '123.45 us' or '1.5 s' to float microseconds.""" | ||
| raw = raw.strip() | ||
| m = re.match(r'^([\d.]+)\s*([mun]?s)?$', raw) |
There was a problem hiding this comment.
[SHOULD-FIX] parse_time_to_us does not accept the μ (micro sign) unit that callers' regexes expect
m = re.match(r'^([\d.]+)\s*([mun]?s)?$', raw)The row-matching regexes in nvbench_kernel_launch.py, nvbench_sleep_kernel.py, and nvbench_auto_throughput.py all explicitly anticipate a μ (U+03BC MICRO SIGN) unit prefix, e.g.:
r'([\d.]+\s*[μmun]?s)\s*\|\s*' # CPU Time (μs, ns, ms, us, s)but this helper's unit character class ([mun]?s) does not include μ. If the row regex ever captures a value like "123.45 μs", passing it here raises ValueError('Invalid time string: ...'). That exception propagates out of the per-row parsing loop in each caller's _process_raw_result, is caught by the outer except BaseException, and triggers _handle_parsing_error() — marking the entire result as MICROBENCHMARK_RESULT_PARSING_FAILURE and discarding any rows already parsed in that call.
Recommendation: extend the regex to accept μ and normalize it before comparing, e.g.:
m = re.match(r'^([\d.]+)\s*([μmun]?s)?$', raw)
...
unit = (m.group(2) or 'us').replace('μ', 'u')| DEBIAN_FRONTEND=noninteractive apt-get install -y ffmpeg libavcodec-dev libavformat-dev libavutil-dev libswresample-dev sudo | ||
| DEBIAN_FRONTEND=noninteractive apt-get install -y ffmpeg libavcodec-dev libavformat-dev libavutil-dev libswresample-dev sudo build-essential | ||
| - name: Setup CMake | ||
| uses: lukka/get-cmake@latest |
There was a problem hiding this comment.
[SHOULD-FIX] Third-party Action pinned to the floating @latest tag
uses: lukka/get-cmake@latest@latest is a mutable ref — whoever controls lukka/get-cmake (or anyone who compromises that repo/release pipeline) can change what code runs in this CI job on every subsequent run, with no PR diff or review gate on this repo's side. This is a supply-chain compromise vector for the CodeQL analysis workflow, which typically runs with elevated permissions/secrets.
Recommendation: pin to an immutable commit SHA (preferred) or at minimum a specific release tag, e.g. lukka/get-cmake@<full-commit-sha> or lukka/get-cmake@v3.30.5.
| *) CMAKE_ARCH="x86_64" ;; \ | ||
| esac && \ | ||
| echo "Detected architecture: ${ARCH}, using CMAKE_ARCH: ${CMAKE_ARCH}" && \ | ||
| wget -q https://github.com/Kitware/CMake/releases/download/v3.30.4/cmake-3.30.4-linux-${CMAKE_ARCH}.tar.gz && \ |
There was a problem hiding this comment.
[SHOULD-FIX] CMake release tarball downloaded and executed without integrity verification
wget -q https://github.com/Kitware/CMake/releases/download/v3.30.4/cmake-3.30.4-linux-${CMAKE_ARCH}.tar.gz && \
tar -xzf cmake-3.30.4-linux-${CMAKE_ARCH}.tar.gz && \
mv cmake-3.30.4-linux-${CMAKE_ARCH} /opt/cmake && \
ln -sf /opt/cmake/bin/* /usr/local/bin/ && \The tarball is fetched over HTTPS but its checksum/signature is never verified before being extracted and symlinked onto PATH, where it's trusted for the rest of the image build (including compiling nvbench). A compromised release asset, mirror substitution, or interception on the download path would let arbitrary code execute during the image build with no detection (OWASP A08:2021 — Software and Data Integrity Failures).
Recommendation: verify a pinned SHA-256 checksum before extracting, e.g.:
echo "<expected-sha256> cmake-3.30.4-linux-${CMAKE_ARCH}.tar.gz" | sha256sum -c - && \
tar -xzf cmake-3.30.4-linux-${CMAKE_ARCH}.tar.gz && \(Kitware publishes cmake-3.30.4-SHA-256.txt alongside each release.) This same block is duplicated in dockerfile/cuda12.9.dockerfile and needs the same fix there.
| *) CMAKE_ARCH="x86_64" ;; \ | ||
| esac && \ | ||
| echo "Detected architecture: ${ARCH}, using CMAKE_ARCH: ${CMAKE_ARCH}" && \ | ||
| wget -q https://github.com/Kitware/CMake/releases/download/v3.30.4/cmake-3.30.4-linux-${CMAKE_ARCH}.tar.gz && \ |
There was a problem hiding this comment.
[SHOULD-FIX] CMake release tarball downloaded and executed without integrity verification
Same issue as dockerfile/cuda12.8.dockerfile: the CMake tarball is downloaded over HTTPS but never checksum-verified before being extracted and symlinked onto PATH. See the comment on cuda12.8.dockerfile for the recommended sha256sum -c fix.
[NON-BLOCKING] Also: this ~20-line CMake-install block is duplicated verbatim in both Dockerfiles. Any future version bump or fix (like the checksum verification above) has to be applied in two places and can silently drift. Consider factoring it into a shared script (e.g. dockerfile/scripts/install-cmake.sh) that both Dockerfiles invoke.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 25 out of 29 changed files in this pull request and generated no new comments.
Comments suppressed due to low confidence (2)
superbench/benchmarks/micro_benchmarks/nvbench_base.py:19
- parse_time_to_us() doesn't handle the microsecond symbols "μs" / "µs" even though the NVBench parsers' regexes accept them. If NVBench emits "μs" in table output, parsing will fail with ValueError and the benchmark will report MICROBENCHMARK_RESULT_PARSING_FAILURE. Consider normalizing "μ"/"µ" to "u" before unit handling.
raw = raw.strip()
m = re.match(r'^([\d.]+)\s*([mun]?s)?$', raw)
if not m:
raise ValueError(f'Invalid time string: {raw!r}')
val, unit = float(m.group(1)), (m.group(2) or 'us')
.github/workflows/codeql-analysis.yml:59
- The workflow uses
lukka/get-cmake@latest, which is not version-pinned and can change behavior over time (supply-chain/reproducibility risk). Pin to a specific tag or commit SHA so CodeQL runs remain deterministic.
- name: Setup CMake
uses: lukka/get-cmake@latest
with:
cmakeVersion: '3.20.0'
This pull request adds support for NVBench-based GPU micro-benchmarks to SuperBench.
nvbench-sleep-kernelnvbench-kernel-launchnvbench-auto-throughputExample config: