Skip to content

test(unit): report hardware-gated tests as skipped instead of passed (#421) - #428

Open
jamesburton wants to merge 1 commit into
kkokosa:mainfrom
jamesburton:issue/421-skippable-hardware-tests
Open

test(unit): report hardware-gated tests as skipped instead of passed (#421)#428
jamesburton wants to merge 1 commit into
kkokosa:mainfrom
jamesburton:issue/421-skippable-hardware-tests

Conversation

@jamesburton

Copy link
Copy Markdown

A test that returns early on an ISA check without asserting is reported as passed. This converts
those sites so the gap shows up as a skip instead.

What changed

31 sites converted to [SkippableFact]/[SkippableTheory] + Skip.IfNot(..., "reason"),
following the convention already established in tests/DotLLM.Tests.Unit/Cuda/:

File Sites Gate
Cpu/Kernels/MatMulTests.cs 9 AVX2 ×7, AVX-512BW ×1, AVX-512BW+AVX-VNNI ×1
Cpu/Kernels/MatMulKQuantTests.cs 4 AVX2
Cpu/Kernels/MatMulQ8_1Tests.cs 4 AVX2
Cpu/Kernels/MatMulR4VnniTests.cs 4 AVX-512BW+AVX-VNNI ×3, AVX2 ×1
Cpu/Kernels/DequantizeKQuantTests.cs 3 AVX2
Cpu/Kernels/KvQuantizeTests.cs 3 AVX2
Cpu/Kernels/RoPETests.cs 2 AVX2
Cpu/Kernels/MatMulQ5_0Tests.cs 1 AVX2
Cpu/Kernels/OuterProductGemmTests.cs 1 AVX2

KvQuantizeTests gained using System.Runtime.Intrinsics.X86; so the three fully-qualified
System.Runtime.Intrinsics.X86.Avx2.IsSupported gates read like every other one.

What was deliberately left alone (7 sites, each now carrying a comment saying why)

Four CUDA fixture constructorsCudaGemmTest, CudaKernelTests, CudaKernelComparisonTests,
CudaTensorTests. The early return is in a constructor, not a test: it lets construction succeed
on a GPU-less machine so that each test can then report itself as skipped through its own
Skip.IfNot(CudaDevice.IsAvailable(), ...). Converting these would be wrong.

Three inner if (ISA.IsSupported) blocks that gate only the vector half of a test whose
scalar/dispatch assertions run everywhere — DequantizeTests.Q8_0_ScalarMatchesSimd_RandomBlocks,
DequantizeTests.Q5_0_ScalarVsAvx2_MatchOnPseudoRandomBlocks, and the AVX-512 tail of
MatMulTests.VecDotQ8_0_OddBlockCount. Making these [SkippableFact] would throw away the scalar
coverage that runs on every machine, which is the distinction called out in the issue.

After this change, the only IsSupported references left in tests/DotLLM.Tests.Unit outside a
Skip.IfNot are those three commented inner gates plus the VnniAvailable helper property.

Verification

Test machine: AMD Strix Halo (Zen 5) — has AVX2, AVX-512BW and AVX-VNNI, no NVIDIA GPU.

Baseline runs (all touched classes, --no-build):

Cpu.Kernels.MatMulTests               57 passed,  0 skipped
Cpu.Kernels.MatMulR4VnniTests         38 passed,  0 skipped
Cpu.Kernels.OuterProductGemmTests     34 passed,  0 skipped
Cpu.Kernels.MatMulQ8_1Tests           18 passed,  0 skipped
Cpu.Kernels.MatMulKQuantTests         17 passed,  0 skipped
Cpu.Kernels.DequantizeTests           16 passed,  0 skipped
Cpu.Kernels.DequantizeKQuantTests     15 passed,  0 skipped
Cpu.Kernels.RoPETests                 12 passed,  0 skipped
Cpu.Kernels.KvQuantizeTests            7 passed,  0 skipped
Cpu.Kernels.MatMulQ5_0Tests            7 passed,  0 skipped

0 failures anywhere, and the pass counts match the pre-change counts — the ISA is present, so
nothing skips and nothing stopped asserting.

Skip path actually observed, not merely assumed:

  • DOTNET_EnableAVX2=0KvQuantizeTests goes from 7 passed, 0 skipped to
    4 passed, 3 skipped. Before this PR the same run reported 7 passed.
  • DOTNET_EnableAVX512=0MatMulR4VnniTests reports 38 skipped, naming each
    VecDotQ8_0Vnni_4RowsR4_* case in the log.
  • FullyQualifiedName~Tests.Unit.Cuda3 passed, 36 skipped (no NVIDIA GPU on this box);
    this path was already correct and is unchanged, included as the reference behaviour.

I could not independently verify the skip path for AVX2/AVX-512 by absence of the hardware — this
machine has both — so the two ISA cases above were verified by disabling the ISA through the runtime
knob instead.

Closes #421

31 tests in `tests/DotLLM.Tests.Unit/Cpu/Kernels` returned early on an ISA
capability check without asserting anything, so on hardware lacking the ISA
they were reported as PASSED and the coverage silently evaporated.

Convert them to `[SkippableFact]`/`[SkippableTheory]` + `Skip.IfNot(...)` with
an explicit reason, following the convention already used in
`tests/DotLLM.Tests.Unit/Cuda`.

Sites deliberately left as-is, now carrying a comment saying why:
- Four CUDA fixture constructors — the early return is in a constructor, not a
  test; each test already declares its own `Skip.IfNot(CudaDevice.IsAvailable())`.
- Two `if (Avx2.IsSupported)` blocks in `DequantizeTests` and one
  `if (Avx512BW.IsSupported)` block in `MatMulTests` — these gate only the
  vector half of a test whose scalar/dispatch assertions run everywhere, so
  converting the whole test would discard coverage.

No assertion that ran before runs any less now: on fully-capable hardware the
pass counts are unchanged.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings July 31, 2026 10:44

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 improves the reliability of the unit test suite by ensuring hardware-gated tests are reported as skipped (not silently passed) when the required ISA/GPU capability is unavailable. It applies the existing SkippableFact/SkippableTheory + Skip.IfNot(...) convention consistently across CPU kernel parity/accuracy tests, while documenting the few cases where an early return is intentional (CUDA fixture constructors, and inner ISA gates that preserve scalar coverage).

Changes:

  • Converted hardware-gated test early-returns to [SkippableFact]/[SkippableTheory] with Skip.IfNot(...) across the listed CPU kernel test classes.
  • Added explicit explanatory comments on CUDA fixture constructors where an early return is intentional and required for correct per-test skipping behavior.
  • Simplified AVX2 gating in KvQuantizeTests by adding using System.Runtime.Intrinsics.X86; and switching to Avx2.IsSupported.

Reviewed changes

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

Show a summary per file
File Description
tests/DotLLM.Tests.Unit/Cuda/CudaTensorTests.cs Documents intentional constructor-level GPU gating so per-test skips still work.
tests/DotLLM.Tests.Unit/Cuda/CudaKernelTests.cs Documents intentional constructor early return for GPU-less environments.
tests/DotLLM.Tests.Unit/Cuda/CudaKernelComparisonTests.cs Documents intentional constructor early return so tests can skip individually.
tests/DotLLM.Tests.Unit/Cuda/CudaGemmTest.cs Documents intentional constructor early return for correct skip reporting.
tests/DotLLM.Tests.Unit/Cpu/Kernels/RoPETests.cs Converts AVX2-gated parity tests to skippable tests with explicit skip reasons.
tests/DotLLM.Tests.Unit/Cpu/Kernels/OuterProductGemmTests.cs Converts AVX2-gated theory to skippable theory to avoid silent pass on non-AVX2.
tests/DotLLM.Tests.Unit/Cpu/Kernels/MatMulTests.cs Converts multiple ISA-gated tests to skippable variants; preserves inner AVX-512-only extra assertion.
tests/DotLLM.Tests.Unit/Cpu/Kernels/MatMulR4VnniTests.cs Converts VNNI/AVX2-gated theories to skippable theories with clear reasons.
tests/DotLLM.Tests.Unit/Cpu/Kernels/MatMulQ8_1Tests.cs Converts AVX2-gated theories/facts to skippable variants with explicit skip reasons.
tests/DotLLM.Tests.Unit/Cpu/Kernels/MatMulQ5_0Tests.cs Converts AVX2-gated theory to skippable theory with explicit skip reason.
tests/DotLLM.Tests.Unit/Cpu/Kernels/MatMulKQuantTests.cs Converts AVX2-gated facts to skippable facts with explicit skip reasons.
tests/DotLLM.Tests.Unit/Cpu/Kernels/KvQuantizeTests.cs Adds System.Runtime.Intrinsics.X86 using and converts AVX2-gated facts to skippable facts.
tests/DotLLM.Tests.Unit/Cpu/Kernels/DequantizeTests.cs Adds comments explaining intentional inner ISA gating to preserve scalar/dispatch assertions everywhere.
tests/DotLLM.Tests.Unit/Cpu/Kernels/DequantizeKQuantTests.cs Converts AVX2-gated facts to skippable facts with explicit skip reasons.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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.

test(unit): ~26 hardware-gated tests report as passed instead of skipped

2 participants