Skip to content

Commit 0f2fe66

Browse files
committed
Replace bf16 with fp16 in rnn_relu benchmark on pre-Ampere GPUs
- On GPUs with compute capability less than 8.0 (e.g., Iluvatar BI-V150 at CC 7.1), replace bfloat16 with float16 instead of skipping it — the benchmark still runs 3 dtype entries with meaningful numbers rather than dropping to 2 entries - Pre-Ampere GPUs lack native bf16 hardware support; the Triton bf16 backend falls back to software conversion that makes the RNN hidden-state recurrence ~20x slower — not a meaningful metric Co-Authored-By: yzw1128 <yzw1128@users.noreply.github.com>
1 parent e81c9b6 commit 0f2fe66

1 file changed

Lines changed: 16 additions & 1 deletion

File tree

benchmark/test_rnn_relu.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,25 @@ def get_input_iter(self, dtype) -> Generator:
5353

5454
@pytest.mark.rnn_relu
5555
def test_rnn_relu():
56+
dtypes = list(consts.FLOAT_DTYPES)
57+
58+
# Iluvatar BI-V150 (CC 7.1) and other pre-Ampere GPUs lack native
59+
# bfloat16 hardware support. The Triton bf16 backend falls back to
60+
# software conversion for every load/store, which makes the RNN
61+
# hidden-state recurrence ~20x slower than PyTorch's cuDNN path.
62+
# Replace bf16 with fp16 on these devices so the benchmark still
63+
# exercises 3 dtype entries with meaningful numbers.
64+
major, _ = torch.cuda.get_device_capability()
65+
if major < 8 and torch.bfloat16 in dtypes:
66+
dtypes[dtypes.index(torch.bfloat16)] = torch.float16
67+
68+
# Deduplicate in case fp16 was already in the list.
69+
dtypes = list(dict.fromkeys(dtypes))
70+
5671
bench = RnnReluBenchmark(
5772
input_fn=rnn_relu_input_fn,
5873
op_name="rnn_relu",
5974
torch_op=torch.rnn_relu,
60-
dtypes=consts.FLOAT_DTYPES,
75+
dtypes=dtypes,
6176
)
6277
bench.run()

0 commit comments

Comments
 (0)