Skip to content

Point the Gemma benchmark routines at a capability that exists - #369

Merged
demandal25 merged 2 commits into
amd-integrationfrom
rocm-bench-followups
Sep 13, 2026
Merged

Point the Gemma benchmark routines at a capability that exists#369
demandal25 merged 2 commits into
amd-integrationfrom
rocm-bench-followups

Conversation

@demandal25

Copy link
Copy Markdown
Collaborator

Follow-up to #364, addressing the three review comments that were still open when it merged.

Summary

#364 claimed to make 23 benchmark routines runnable on ROCm. It made 21: both Gemma routines were mapped to a capability op that arch_caps.py no longer declares, so they filtered to no backends and produced no rows. This fixes that, adds the guard that would have caught it, and clears two smaller items from the same review.

What changed

  • benchmarks/routines/rocm/support.pygemma_rmsnorm and gemma_fused_add_rmsnorm now reference the capability op gemma_rmsnorm; they referenced layernorm, which was removed from arch_caps.py once it turned out to have no ROCm kernel behind it.
  • tests/rocm/test_arch_caps.pytest_benchmark_registry_ops_are_declared, asserting every op the registry references has a hip row. It lives here because arch-caps-conformance.yml runs this file on every PR with no GPU; the registry is parsed with ast because that lane has no torch.
  • benchmarks/rocm/bench_block_sparse_attention.py — record --seed with the other case parameters, and actually seed the global RNG: --seed reached only the block mask, while every q/k/v came from the unseeded generator, so recording it alone would have overstated what a row pins.
  • benchmarks/rocm/testlist_rocm.txt — the norm heading claimed "bf16 and fp16"; all 7 of its commands pass bfloat16.

Architecture / design notes

The missing thing was a CI lane, not a test. test_filter_only_offers_backends_the_cli_accepts already fails on this defect for both Gemma routines — verified by restoring the key. But tests/rocm/test_benchmark_harness.py is skipif(not IS_HIP) and no workflow references it, so the suite that catches this runs only on a maintainer's ROCm box. That is how the layernorm removal merged. The new guard therefore goes in the one lane that runs everywhere, and the on-hardware test keeps its stronger check (a row can exist and still be gated UNSUPPORTED on an arch, which a declaration scan cannot see).

Why ast and not the regex scan already in that file. support.py passes op as a variable to capability_available, so the op strings live in a dict literal and never appear at a call site for test_every_op_the_library_asks_for_is_declared to match.

Heading corrected rather than adding fp16 cases. vec_size is gcd(16/sizeof(T), d) and fp16 and bf16 are both 2-byte, so fp16 cases would exercise the same code path and differ only in numerical noise — coverage in name only, paid for on every testlist run.

Benchmark results

No performance change: this makes two routines run that previously exited before timing anything, and adds a column to a CSV. For the record, on gfx942 at c333f2003 both now measure (batch 989, hidden 4096, bf16):

routine median achieved
gemma_rmsnorm 0.007 ms 2.35 TB/s
gemma_fused_add_rmsnorm 0.019 ms 1.69 TB/s

Test plan

  • A/B on the new guard, run exactly as CI does (pytest --noconftest tests/rocm/test_arch_caps.py): with the layernorm key restored it fails naming layernorm; with the fix the file's 85 cases pass.
  • A/B end to end through the real runner, gfx942: with the old key [ERROR] No backends to test. Exiting.; with the fix, a [PERF] row for both Gemma routines.
  • tests/rocm/test_benchmark_harness.py — exit 0 on gfx942 after removing the duplicate guard. With the bug restored it fails on test_filter_only_offers_backends_the_cli_accepts[gemma_rmsnorm] and [gemma_fused_add_rmsnorm], which is the evidence that the pre-existing test already covered this.
  • --csv output carries a seed column, verified by parsing the written file.
  • pre-commit run on the changelist — clean, nothing reformatted.
  • /code-review xhigh (the level review-level.sh computes for this changelist).

Measured on gfx942 only. The fix is a capability-table lookup and a CSV field, neither of which is architecture-dependent, and the guard test does not touch a GPU.

benchmarks/routines/rocm/support.py mapped gemma_rmsnorm and
gemma_fused_add_rmsnorm to the capability op "layernorm", which
arch_caps.py no longer declares -- it was removed once it turned out to
have no ROCm kernel behind it. capability_available() therefore answered
False and both routines filtered to no backends, so #364 shipped 21 of
the 23 routines it claimed. Measured on gfx942 at c333f20:

  capability_available(d, "layernorm", "hip")     -> False
  capability_available(d, "gemma_rmsnorm", "hip") -> True
  rocm_supported_backends("gemma_rmsnorm", d)     -> []

and through the runner, "[ERROR] No backends to test. Exiting." against a
[PERF] row after the fix.

Neither change was wrong alone and git merged both cleanly, because they
touch different files. What is missing is not a test:
test_filter_only_offers_backends_the_cli_accepts already fails on this,
for both routines -- verified by restoring the key. It is a *lane*.
tests/rocm/test_benchmark_harness.py is skipif(not IS_HIP) and no
workflow references it, so the suite that catches this runs only on a
maintainer's ROCm box, which is how the removal merged.

So the guard goes in tests/rocm/test_arch_caps.py, which
arch-caps-conformance.yml runs on every pull request with no GPU. That
lane has no torch, and support.py reaches flashinfer, so the registry is
parsed with ast rather than imported. The regex scan already in that file
cannot cover it either: support.py passes `op` as a variable, so the
strings sit in a dict literal and never appear at a call site.

Two smaller review items from the same PR:

bench_block_sparse_attention.py recorded kind, seq_len, head counts,
density and num_blocks per row but not --seed. Recording it alone would
have overstated what it pins: --seed reached only _block_mask's local
generator, while every q/k/v came from the unseeded global RNG, so
--accuracy could not be reproduced from a row. main() now seeds the
global RNG too.

testlist_rocm.txt's norm section was headed "bf16 and fp16" while all 7
of its commands pass --input_dtype bfloat16. Corrected the heading rather
than adding fp16 cases, and recorded why in the file: vec_size is
gcd(16/sizeof(T), d) and both are 2-byte, so fp16 would re-run the same
path for numerical noise alone.

Co-Authored-By: Claude <noreply@anthropic.com>
Copilot AI balanced review requested due to automatic review settings September 13, 2026 05:11

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟢 Approval recommended

The capability fix, regression guard, seed handling, and documentation update are consistent and complete.

Pull request overview

Fixes ROCm Gemma benchmark capability routing and improves benchmark validation and reproducibility.

Changes:

  • Maps Gemma routines to the declared capability.
  • Adds a GPU-free registry conformance test.
  • Records and applies benchmark seeds; corrects norm documentation.
File summaries
File Description
tests/rocm/test_arch_caps.py Validates registry capability references.
benchmarks/routines/rocm/support.py Corrects Gemma capability mappings.
benchmarks/rocm/testlist_rocm.txt Clarifies BF16-only coverage.
benchmarks/rocm/bench_block_sparse_attention.py Seeds inputs and records the seed.
Review details
  • Files reviewed: 4/4 changed files
  • Comments generated: 0
  • Review effort level: Balanced

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Copilot AI review requested due to automatic review settings September 13, 2026 19:14

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟢 Approval recommended

The focused fixes are consistent with the capability table and include an appropriate CI regression guard.

Review details
  • Files reviewed: 4/4 changed files
  • Comments generated: 0 new
  • Review effort level: Balanced

@demandal25
demandal25 merged commit 38ac4d0 into amd-integration Sep 13, 2026
3 checks passed
@demandal25
demandal25 deleted the rocm-bench-followups branch September 13, 2026 19:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants