Skip to content

ci(rocm): run the capability-table conformance suite without a GPU - #287

Merged
demandal25 merged 2 commits into
amd-integrationfrom
ci-arch-caps-conformance
Aug 20, 2026
Merged

ci(rocm): run the capability-table conformance suite without a GPU#287
demandal25 merged 2 commits into
amd-integrationfrom
ci-arch-caps-conformance

Conversation

@demandal25

@demandal25 demandal25 commented Aug 20, 2026

Copy link
Copy Markdown
Collaborator

Summary

Makes the capability-table conformance suite run on every pull request, with no GPU and no ROCm toolchain.

Nothing in tests/rocm_tests/ runs at PR time today — it all needs an MI300X or MI355X. The capability table added in #285 is the one part that does not need hardware: it is pure data plus routing logic, and its suite already monkeypatches the architecture rather than querying one. The table is also the thing most likely to drift silently, since a wrong row does not crash — it just quietly grants or denies a backend.

What was in the way

Only the import. flashinfer/__init__.py:287 ends in:

raise RuntimeError("FlashInfer requires either CUDA or ROCm/HIP backend. Detected CPU-only PyTorch installation.")

so from flashinfer import arch_caps needs a GPU-capable torch build even though nothing in the file touches a tensor. I confirmed this against a real CPU-only install rather than assuming it — installing torch==2.13.0+cpu and importing the package raises exactly that error, which rules out the obvious "just install CPU torch in CI" approach.

The fix is to load arch_caps and hip_utils directly from their files, registered under a synthetic package so their relative imports (hip_utils:10 at module scope, arch_caps:354 inside _live_versions) still resolve. Two unrelated top-level modules would leave those unresolvable and silently degrade _live_versions to its except-branch, which would make TestVersionProbeIsCheap pass vacuously.

Why this is more than a convenience

Both modules must stay torch-free at module scope: hip_utils sits on the pre-HIP_VISIBLE_DEVICES path in tests/conftest.py, and arch_caps is imported by it. That contract was asserted in one subprocess test and otherwise held by convention. It is now structural — a module-scope import torch in either file breaks the CI job outright instead of regressing quietly.

test_module_does_not_import_torch accordingly becomes test_suite_loads_without_torch, covering both modules instead of arch_caps alone, and asserting the exact precondition the CI job depends on.

Test plan

All 53 tests, three environments:

environment result
pytest-only venv, no torch installed at all 53 passed in 0.43s
ROCm container, --noconftest 53 passed in 0.36s
ROCm container, conftest active, gfx950 GPU, torch 2.9.1+rocm7.2.0, aiter 0.1.10 53 passed in 0.59s
this job, on this PR, ubuntu-latest, no torch, no GPU 53 passed in 0.24s (run)
  • Negative control: the pre-change file cannot be collected in the first environment at all (ModuleNotFoundError: No module named 'flashinfer'), so the suite is not passing there for some unrelated reason.
  • The third row matters as much as the first — this file is part of the normal ROCm suite, and the loader must not disturb it. Note the loader gives each test session its own copy of the module, so test_detection_runs_once_per_process no longer clears the real _live_versions cache out from under the rest of the session.
  • pre-commit run on both changed files.

Notes

--noconftest is required and is not incidental: tests/conftest.py and tests/rocm_tests/conftest.py both import torch and flashinfer at module scope, so collection under tests/rocm_tests/ would fail long before reaching this file. The suite defines its own fixtures and needs nothing from either conftest; test_suite_loads_without_torch is what keeps that true.

Unrelated observation, not fixed here: .github/workflows/pre-commit.yml triggers on push: branches: [main], but this fork's default branch is amd-integration, so that trigger never fires. The pull_request trigger does, which is why pre-commit still runs on PRs.

Nothing in tests/rocm_tests/ runs on a pull request today -- it all needs an
MI300X or MI355X and a ROCm toolchain. The capability table is the one part
that does not: it is pure data plus routing logic, and its suite already
monkeypatches the architecture rather than querying one.

The only thing standing in the way was the import. flashinfer/__init__.py ends
in `raise RuntimeError("FlashInfer requires either CUDA or ROCm/HIP backend.
Detected CPU-only PyTorch installation.")`, so `from flashinfer import
arch_caps` needs a GPU-capable torch build even though nothing in the file
touches a tensor. Load arch_caps and hip_utils directly instead, under a
synthetic package so their relative imports still resolve, and the suite runs
with pytest as its only dependency.

That also makes an existing contract structural rather than aspirational. Both
modules must stay torch-free at module scope -- hip_utils sits on the
pre-HIP_VISIBLE_DEVICES path in tests/conftest.py -- and a module-scope
`import torch` now breaks the CI job outright instead of regressing quietly.
test_module_does_not_import_torch becomes test_suite_loads_without_torch and
covers both modules rather than arch_caps alone.

The job needs --noconftest: both conftests import torch and flashinfer at
module scope, so collection under tests/rocm_tests/ would fail long before
reaching this file.

Measured, all 53 tests:

  pytest-only venv, no torch installed at all   53 passed in 0.43s
  ROCm container, --noconftest                  53 passed in 0.36s
  ROCm container, conftest active, gfx950 GPU   53 passed in 0.59s

Negative control: the pre-change file cannot be collected in the first
environment at all.

Co-Authored-By: Claude <noreply@anthropic.com>
Copilot AI lite review requested due to automatic review settings August 20, 2026 04:08

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.

Pull request overview

This PR makes the ROCm capability-table conformance suite run in standard CI without requiring a GPU, ROCm toolchain, or even a Torch install, by avoiding flashinfer package import side effects during test collection.

Changes:

  • Updated tests/rocm_tests/test_arch_caps_hip.py to load arch_caps and hip_utils directly from source files under a synthetic package, preserving their relative imports while bypassing flashinfer/__init__.py.
  • Reworked the “no torch at module scope” assertion into a subprocess test that validates the entire suite loads and key symbols/constants are available without importing torch.
  • Added a new GitHub Actions workflow to run this single conformance file with pytest --noconftest on PRs (and pushes to amd-integration).

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
tests/rocm_tests/test_arch_caps_hip.py Adds a synthetic-package loader to import arch_caps/hip_utils without running flashinfer/__init__.py, enabling torch-less CI execution.
.github/workflows/arch-caps-conformance.yml New CI job that installs only pytest and runs the conformance suite with --noconftest on PRs.

💡 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 August 20, 2026 13:19

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.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.

@demandal25
demandal25 merged commit 4ccc4b3 into amd-integration Aug 20, 2026
3 checks passed
@demandal25
demandal25 deleted the ci-arch-caps-conformance branch August 20, 2026 13:33
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