test(unit): report hardware-gated tests as skipped instead of passed (#421) - #428
Open
jamesburton wants to merge 1 commit into
Open
test(unit): report hardware-gated tests as skipped instead of passed (#421)#428jamesburton wants to merge 1 commit into
jamesburton wants to merge 1 commit into
Conversation
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>
There was a problem hiding this comment.
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]withSkip.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
KvQuantizeTestsby addingusing System.Runtime.Intrinsics.X86;and switching toAvx2.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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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/:Cpu/Kernels/MatMulTests.csCpu/Kernels/MatMulKQuantTests.csCpu/Kernels/MatMulQ8_1Tests.csCpu/Kernels/MatMulR4VnniTests.csCpu/Kernels/DequantizeKQuantTests.csCpu/Kernels/KvQuantizeTests.csCpu/Kernels/RoPETests.csCpu/Kernels/MatMulQ5_0Tests.csCpu/Kernels/OuterProductGemmTests.csKvQuantizeTestsgainedusing System.Runtime.Intrinsics.X86;so the three fully-qualifiedSystem.Runtime.Intrinsics.X86.Avx2.IsSupportedgates read like every other one.What was deliberately left alone (7 sites, each now carrying a comment saying why)
Four CUDA fixture constructors —
CudaGemmTest,CudaKernelTests,CudaKernelComparisonTests,CudaTensorTests. The early return is in a constructor, not a test: it lets construction succeedon 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 whosescalar/dispatch assertions run everywhere —
DequantizeTests.Q8_0_ScalarMatchesSimd_RandomBlocks,DequantizeTests.Q5_0_ScalarVsAvx2_MatchOnPseudoRandomBlocks, and the AVX-512 tail ofMatMulTests.VecDotQ8_0_OddBlockCount. Making these[SkippableFact]would throw away the scalarcoverage that runs on every machine, which is the distinction called out in the issue.
After this change, the only
IsSupportedreferences left intests/DotLLM.Tests.Unitoutside aSkip.IfNotare those three commented inner gates plus theVnniAvailablehelper 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):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=0→KvQuantizeTestsgoes from7 passed, 0 skippedto4 passed, 3 skipped. Before this PR the same run reported 7 passed.DOTNET_EnableAVX512=0→MatMulR4VnniTestsreports 38 skipped, naming eachVecDotQ8_0Vnni_4RowsR4_*case in the log.FullyQualifiedName~Tests.Unit.Cuda→ 3 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