Skip to content

Benchmarks: Micro benchmark - add nvbench based kernel-launch, sleep-kernel & auto-throughput - #750

Open
WenqingLan1 wants to merge 57 commits into
microsoft:mainfrom
WenqingLan1:feat/third_party/nvbench
Open

Benchmarks: Micro benchmark - add nvbench based kernel-launch, sleep-kernel & auto-throughput#750
WenqingLan1 wants to merge 57 commits into
microsoft:mainfrom
WenqingLan1:feat/third_party/nvbench

Conversation

@WenqingLan1

@WenqingLan1 WenqingLan1 commented Oct 9, 2025

Copy link
Copy Markdown
Contributor

This pull request adds support for NVBench-based GPU micro-benchmarks to SuperBench.

  • Integrated the NVBench submodule
  • Implemented three benchmarks
    • nvbench-sleep-kernel
    • nvbench-kernel-launch
    • nvbench-auto-throughput
  • updated documentation and added example scripts

Example config:

version: v0.12
superbench:
  enable:
  # nvbench benchmarks
  - nvbench-sleep-kernel:single
  - nvbench-sleep-kernel:list
  - nvbench-sleep-kernel:range
  - nvbench-sleep-kernel:range-step
  - nvbench-kernel-launch
  - nvbench-auto-throughput
  - nvbench-auto-throughput:stride-list
  - nvbench-auto-throughput:stride-range
  var:
    default_local_mode: &default_local_mode
      modes:
      - name: local
        proc_num: 4
        prefix: CUDA_VISIBLE_DEVICES={proc_rank}
        parallel: yes
  benchmarks:
    nvbench-sleep-kernel:single:
      <<: *default_local_mode
      timeout: 300
      parameters:
        duration_us: "50"                   # Single value format
        timeout: 30
    nvbench-sleep-kernel:list:
      <<: *default_local_mode
      timeout: 300
      parameters:
        duration_us: "[25,50,75]"         # List format - no spaces after commas
        timeout: 30
    nvbench-sleep-kernel:range:
      <<: *default_local_mode
      timeout: 300
      parameters:
        duration_us: "[0:5]"           # Range format
        timeout: 30
    nvbench-sleep-kernel:range-step:
      <<: *default_local_mode
      timeout: 300
      parameters:
        duration_us: "[0:50:10]"         # Range with step format
        timeout: 30
    nvbench-kernel-launch:
      <<: *default_local_mode
      timeout: 300
    nvbench-auto-throughput:
      <<: *default_local_mode
      timeout: 600
      parameters:
        stride: "[1,2,4,8]"              # List format for stride
        block_size: "[128,256,512,1024]"  # List format for block size
    nvbench-auto-throughput:stride-list:
      <<: *default_local_mode
      timeout: 600
      parameters:
        stride: "[1,2,4,8]"              # List format
        block_size: "[256,512]"
    nvbench-auto-throughput:stride-range:
      <<: *default_local_mode
      timeout: 600
      parameters:
        stride: "[1:8:2]"                # Range with step format
        block_size: "256"                 # Single value format

@WenqingLan1
WenqingLan1 requested a review from a team as a code owner October 9, 2025 23:12
@WenqingLan1 WenqingLan1 added benchmarks SuperBench Benchmarks micro-benchmarks Micro Benchmark Test for SuperBench Benchmarks labels Oct 9, 2025
@codecov

codecov Bot commented Oct 10, 2025

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 94.18182% with 16 lines in your changes missing coverage. Please review.
✅ Project coverage is 86.29%. Comparing base (67298ae) to head (cecba76).

Files with missing lines Patch % Lines
...rbench/benchmarks/micro_benchmarks/nvbench_base.py 93.33% 11 Missing ⚠️
...hmarks/micro_benchmarks/nvbench_auto_throughput.py 95.55% 2 Missing ⚠️
...enchmarks/micro_benchmarks/nvbench_sleep_kernel.py 94.44% 2 Missing ⚠️
...nchmarks/micro_benchmarks/nvbench_kernel_launch.py 96.15% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #750      +/-   ##
==========================================
+ Coverage   86.02%   86.29%   +0.27%     
==========================================
  Files         103      107       +4     
  Lines        7950     8225     +275     
==========================================
+ Hits         6839     7098     +259     
- Misses       1111     1127      +16     
Flag Coverage Δ
cpu-python3.10-unit-test 71.65% <94.09%> (+0.77%) ⬆️
cpu-python3.12-unit-test 71.65% <94.09%> (+0.77%) ⬆️
cpu-python3.7-unit-test 71.11% <94.13%> (+0.80%) ⬆️
cuda-unit-test 84.29% <94.09%> (+0.33%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 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'

Copilot AI review requested due to automatic review settings August 19, 2026 23:44

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 27 out of 28 changed files in this pull request and generated no new comments.

Suppressed comments (1)

.github/workflows/codeql-analysis.yml:59

  • The CodeQL C++ job pins CMake to 3.20.0, but the new nvbench micro-benchmarks explicitly skip configuration/build when CMake < 3.30.4 (see superbench/benchmarks/micro_benchmarks/nvbench/CMakeLists.txt). As a result, the new CUDA/C++ nvbench sources won't be built (and therefore won't be included in CodeQL analysis) in this workflow. Also, lukka/get-cmake@latest is not pinned, which is brittle and a supply-chain risk for CI.
      - name: Setup CMake
        uses: lukka/get-cmake@latest
        with:
          cmakeVersion: '3.20.0'

Copilot AI review requested due to automatic review settings August 20, 2026 18:28

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 27 out of 28 changed files in this pull request and generated 1 comment.

Suppressed comments (2)

superbench/benchmarks/micro_benchmarks/init.py:55

  • This change reformats the entire __all__ list into a few very long lines, creating avoidable diff churn and making future edits harder. Keep the previous one-item-per-line style (and just append the new NVBench exports).
__all__ = [
    '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'

superbench/benchmarks/micro_benchmarks/nvbench_base.py:265

  • NVBench JSON output paths are appended to the command without shell-quoting. Since run_command executes with shell=True by default, a user-supplied --output_dir (or even paths with spaces) can break the command or be used for command injection. Shell-quote the computed json_path before appending.
        for idx, command in enumerate(commands):
            json_path = os.path.join(base_dir, f'{self._bin_name}_{idx}.json')
            self._json_paths.append(json_path)
            finalized.append(f'{command} --json {json_path}')
        return finalized

Comment thread superbench/benchmarks/micro_benchmarks/nvbench_base.py
Copilot AI review requested due to automatic review settings August 20, 2026 18:52

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 27 out of 28 changed files in this pull request and generated no new comments.

Copilot AI review requested due to automatic review settings August 20, 2026 19:42

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 27 out of 28 changed files in this pull request and generated 3 comments.

Comment thread superbench/benchmarks/micro_benchmarks/nvbench_sleep_kernel.py
Comment thread superbench/benchmarks/micro_benchmarks/nvbench_auto_throughput.py
Comment thread superbench/benchmarks/micro_benchmarks/nvbench_base.py Outdated
Copilot AI review requested due to automatic review settings August 20, 2026 20:38

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 27 out of 28 changed files in this pull request and generated no new comments.

return val


_NVBENCH_INT_VALUES_PATTERN = re.compile(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

To pass the lint check, pls use 1 line here.

Copilot AI review requested due to automatic review settings August 20, 2026 21:08

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 27 out of 28 changed files in this pull request and generated no new comments.

Suppressed comments (3)

superbench/benchmarks/micro_benchmarks/nvbench_auto_throughput.py:41

  • --block_size uses parse_nvbench_int_values, which also accepts NVBench range formats (e.g. [128:1024] / [128:1024:128]), but the help text only documents single-value and list formats. Please either document the supported range formats or restrict parsing for this argument.
        self._parser.add_argument(
            '--block_size',
            type=parse_nvbench_int_values,
            default='[128,256,512,1024]',
            help='Block size (threads per block). Supports: "256" (single), "[128,256,512,1024]" (list).',

superbench/benchmarks/micro_benchmarks/nvbench_base.py:23

  • parse_time_to_us allows multiple dots in the numeric portion via ([\d.]+), so inputs like "1..2 us" match the regex but then fail with a generic float() conversion error. Tightening the regex and normalizing the error makes invalid inputs fail consistently with Invalid time string: ....
    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')

superbench/benchmarks/micro_benchmarks/nvbench_sleep_kernel.py:52

  • The _process_raw_result docstring says self._result.add_raw_data() needs to be called, but raw JSON is already recorded by NvbenchBase._load_result_json(). This is misleading for anyone implementing new NVBench benchmarks based on this example.
        """Function to parse raw results and save the summarized results.

        self._result.add_raw_data() and self._result.add_result() need to be called to save the results.

Copilot AI review requested due to automatic review settings August 21, 2026 16:49

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 28 out of 29 changed files in this pull request and generated no new comments.

Suppressed comments (2)

Previously missed (2) — in code that hasn't changed since the last review.

superbench/benchmarks/micro_benchmarks/nvbench_base.py:44

  • parse_nvbench_int_values currently accepts whitespace inside bracketed list/range forms (e.g. "[0, 1]") and returns the value unchanged. That can later produce invalid CLI tokens (especially for --devices) if spaces are present, and also makes it easier to accidentally generate commands that won’t parse as intended. Consider normalizing by stripping all whitespace after validation and returning the normalized value.
def parse_nvbench_int_values(value):
    """Validate an NVBench integer value specification."""
    # Accepted formats: '0', '[0,1,2]', '[0:4]', and '[0:4:2]' (range with step).
    if not _NVBENCH_INT_VALUES_PATTERN.fullmatch(value):
        raise ValueError(
            'Invalid NVBench integer values. Use a single value like "0", '
            'a list like "[0,1,2]", or a range like "[0:4]" or "[0:4:2]".'
        )
    return value

superbench/benchmarks/micro_benchmarks/nvbench_base.py:184

  • --devices values like "[0,1,2]" / "[0:4]" contain shell glob metacharacters ([ and ]). Since commands are executed with shell=True (see run_command), passing these unquoted can trigger glob expansion based on the working directory contents, producing unexpected arguments. Quoting/escaping the --devices value when building the command would make behavior deterministic.
    def _add_device_args(self, parts):
        """Add device configuration arguments to command parts."""
        if hasattr(self._args, 'devices') and self._args.devices is not None:
            if self._args.devices == 'all':
                parts.extend(['--devices', 'all'])
            else:
                parts.extend(['--devices', self._args.devices])

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

benchmarks SuperBench Benchmarks micro-benchmarks Micro Benchmark Test for SuperBench Benchmarks

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants