Skip to content

Commit f257102

Browse files
Chris Thifacebook-github-bot
Chris Thi
authored andcommitted
Allow multiple group sizes to be passed in quantize_bench (#4137)
Summary: Pull Request resolved: #4137 X-link: facebookresearch/FBGEMM#1219 This is useful when testing grouped gemm and needing to test multiple group sizes, e.g. G=128,16. Reviewed By: jiawenliu64 Differential Revision: D74850104 fbshipit-source-id: a63daa020324cbd6999b36278eedc7b0e3e14753
1 parent 5a3a298 commit f257102

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

fbgemm_gpu/experimental/gen_ai/bench/quantize_bench.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -446,21 +446,22 @@ def main(args: Any):
446446
MNK = list(itertools.product(B, M, N, K))
447447
# When groups is provided transform shapes into grouped format.
448448
if args.groups:
449-
groups = int(args.groups)
449+
groups = [int(g) for g in args.groups.strip().split(",")]
450450
if args.total_M:
451-
M = generate_group_tensor(groups, int(args.total_M))
452451
MNK = [
453452
[
454-
[b] * groups,
455-
generate_group_tensor(groups, int(args.total_M)),
456-
[n] * groups,
457-
[k] * groups,
453+
[b] * g,
454+
generate_group_tensor(g, int(args.total_M)),
455+
[n] * g,
456+
[k] * g,
458457
]
458+
for g in groups
459459
for b, _, n, k in MNK
460460
]
461461
else:
462462
MNK = [
463-
[[b] * groups, [m] * groups, [n] * groups, [k] * groups]
463+
[[b] * g, [m] * g, [n] * g, [k] * g]
464+
for g in groups
464465
for b, m, n, k in MNK
465466
]
466467

@@ -558,7 +559,7 @@ def invoke_main() -> None:
558559
parser.add_argument(
559560
"--groups",
560561
default=None,
561-
help="If set with grouped mode, repeat input shapes this many times.",
562+
help="If set with grouped mode, repeat input shapes this many times. Comma separated list of groups to benchmark",
562563
)
563564
parser.add_argument(
564565
"--total_M",

0 commit comments

Comments
 (0)