Skip to content

Commit

Permalink
address lint issues
Browse files Browse the repository at this point in the history
  • Loading branch information
yzygitzh committed Dec 7, 2023
1 parent 1f230dc commit d81d7af
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 9 deletions.
1 change: 1 addition & 0 deletions examples/benchmarks/dist_inference_cpp.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# Licensed under the MIT license.

"""Micro benchmark example for distributed inference (cpp implementation).
Commands to run:
mpirun -np 8 examples/benchmarks/dist_inference_cpp.py
"""
Expand Down
9 changes: 4 additions & 5 deletions superbench/benchmarks/micro_benchmarks/dist_inference_cpp.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,9 @@ def add_parser_arguments(self):
'--mnk_list',
type=str,
nargs='+',
default=['80,128,128'],
help=
'List of M,N,K tuples of sharded 2-layer-feed-forward block. K is input size, N is batch size, M is hidden size. E.g. {}.'
.format(' '.join(self._mnk_list)),
default=['128,80,128'],
help='List of M(input),N(batch),K(hidden) tuples of sharded 2-layer-feed-forward block. E.g. {}.'.format(
' '.join(self._mnk_list)),
)
self._parser.add_argument(
'--alpha',
Expand Down Expand Up @@ -95,7 +94,7 @@ def _preprocess(self):
m, n, k = [int(x) for x in mnk.split(',')]
args = '-m %d -n %d -k %d' % (m, n, k)
args += ' --alpha %g --beta %g' % (self._args.alpha, self._args.beta)
args += ' --num_layers %d --num_warmups --num_iters' % \
args += ' --num_layers %d --num_warmups %d --num_iters %d' % \
(self._args.num_layers, self._args.num_warmups, self._args.num_iters)
if self._args.use_cuda_graph:
args += ' --use_cuda_graph'
Expand Down
12 changes: 8 additions & 4 deletions tests/benchmarks/micro_benchmarks/test_dist_inference_cpp.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,9 @@ def _test_dist_inference_cpp_command_generation(self, platform):
num_layers = 9
num_warmups = 10
num_iters = 11
parameters = '--mnk_list %s --alpha %g --beta %g --num_layers %d --num_warmups %d --num_iters %d --use_cuda_graph' % \
(' '.join(mnk_list), alpha, beta, num_layers, num_warmups, num_iters)
wrapper_params_format_str = \
'--mnk_list %s --alpha %g --beta %g --num_layers %d --num_warmups %d --num_iters %d --use_cuda_graph'
parameters = wrapper_params_format_str % (' '.join(mnk_list), alpha, beta, num_layers, num_warmups, num_iters)
benchmark = benchmark_class(benchmark_name, parameters=parameters)

# Check basic information
Expand All @@ -58,8 +59,11 @@ def _test_dist_inference_cpp_command_generation(self, platform):
assert (len(mnk_list) == len(benchmark._commands))
for cmd in benchmark._commands:
m, n, k = [int(x) for x in mnk_list[0].split(',')]
assert (cmd == ('%s -m %d -n %d -k %d --alpha %g --beta %g --num_layers %d --num_warmups %d --num_iters %d --use_cuda_graph' % \
benchmark._DistInferenceCpp__bin_path, m, n, k, alpha, beta, num_layers, num_warmups, num_iters))
bench_params_format_str = \
'%s -m %d -n %d -k %d --alpha %g --beta %g ' + \
'--num_layers %d --num_warmups %d --num_iters %d --use_cuda_graph'
assert (cmd == (bench_params_format_str % (benchmark._DistInferenceCpp__bin_path,
m, n, k, alpha, beta, num_layers, num_warmups, num_iters)))

@decorator.cuda_test
def test_dist_inference_cpp_command_generation_cuda(self):
Expand Down

0 comments on commit d81d7af

Please sign in to comment.