Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfix - nvbandwidth benchmark need to handle N/A value #675

Open
wants to merge 14 commits into
base: main
Choose a base branch
from
2 changes: 1 addition & 1 deletion examples/benchmarks/nvbandwidth.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
if __name__ == '__main__':
context = BenchmarkRegistry.create_benchmark_context(
'nvbandwidth',
platform=Platform.CPU,
platform=Platform.CUDA,
parameters=(
'--buffer_size 128 '
'--test_cases 0,1,19,20 '
Expand Down
26 changes: 16 additions & 10 deletions superbench/benchmarks/micro_benchmarks/nvbandwidth.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,11 @@ def add_parser_arguments(self):

self._parser.add_argument(
'--test_cases',
nargs='+',
type=str,
default='',
default=[],
required=False,
help=(
'Specify the test case(s) to run, either by name or index. By default, all test cases are executed. '
'Example: --test_cases 0,1,2,19,20'
),
help='Specify the test case(s) to run, either by name or index. By default, all test cases are executed.',
polarG marked this conversation as resolved.
Show resolved Hide resolved
)

self._parser.add_argument(
Expand Down Expand Up @@ -92,7 +90,7 @@ def _preprocess(self):
command += f' --bufferSize {self._args.buffer_size}'

if self._args.test_cases:
command += ' --testcase ' + ' '.join([testcase.strip() for testcase in self._args.test_cases.split(',')])
command += ' --testcase ' + ' '.join(self._args.test_cases)

if self._args.skip_verification:
command += ' --skipVerification'
Expand Down Expand Up @@ -157,21 +155,29 @@ def _process_raw_line(self, line, parse_status):
if parse_status['test_name'] and parse_status['benchmark_type'] and matrix_row_pattern.match(line):
row_data = line.split()
row_index = row_data[0]

polarG marked this conversation as resolved.
Show resolved Hide resolved
for col_index, value in enumerate(row_data[1:], start=1):
# Skip 'N/A' values
polarG marked this conversation as resolved.
Show resolved Hide resolved
if value == 'N/A':
continue

col_header = parse_status['matrix_header'][col_index - 1]
test_name = parse_status['test_name']
benchmark_type = parse_status['benchmark_type']
metric_name = f'{test_name}_cpu{row_index}_gpu{col_header}_{benchmark_type}'
parse_status['results'][metric_name] = float(value)

polarG marked this conversation as resolved.
Show resolved Hide resolved
return

# Parse summary results
summary_match = summary_pattern.search(line)
if summary_match:
value = float(summary_match.group(2))
test_name = parse_status['test_name']
benchmark_type = parse_status['benchmark_type']
parse_status['results'][f'{test_name}_sum_{benchmark_type}'] = value
value = summary_match.group(2)
# Skip 'N/A' values
polarG marked this conversation as resolved.
Show resolved Hide resolved
if value != 'N/A':
test_name = parse_status['test_name']
benchmark_type = parse_status['benchmark_type']
parse_status['results'][f'{test_name}_sum_{benchmark_type}'] = float(value)

# Reset parsing state for next test
parse_status['test_name'] = ''
Expand Down
16 changes: 16 additions & 0 deletions superbench/config/default.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,22 @@ superbench:
copy_type:
- sm
- dma
nvbandwidth:
enable: true
modes:
- name: local
polarG marked this conversation as resolved.
Show resolved Hide resolved
parallel: no
parameters:
buffer_size: 128
test_cases:
- host_to_device_memcpy_ce
- device_to_host_memcpy_ce
- host_to_device_memcpy_sm
- device_to_host_memcpy_sm
num_loops: 6
skip_verification: false
disable_affinity: false
use_mean: false
kernel-launch:
<<: *default_local_mode
gemm-flops:
Expand Down
2 changes: 1 addition & 1 deletion tests/benchmarks/micro_benchmarks/test_nvbandwidth.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def test_nvbandwidth_preprocess(self):
# Test preprocess with specified parameters
parameters = (
'--buffer_size 256 '
'--test_cases 0,1,2,19,20 '
'--test_cases 0 1 2 19 20 '
polarG marked this conversation as resolved.
Show resolved Hide resolved
'--skip_verification '
'--disable_affinity '
'--use_mean '
Expand Down
Loading