Skip to content

test: add a property-based kernel test with CPU and GPU backends#4142

Merged
TaiSakuma merged 1 commit into
scikit-hep:mainfrom
TaiSakuma:test/hypothesis-kernels
Jun 19, 2026
Merged

test: add a property-based kernel test with CPU and GPU backends#4142
TaiSakuma merged 1 commit into
scikit-hep:mainfrom
TaiSakuma:test/hypothesis-kernels

Conversation

@TaiSakuma

@TaiSakuma TaiSakuma commented Jun 15, 2026

Copy link
Copy Markdown
Member

Summary

As discussed in the awkward–uproot meeting, this is a pilot for property-based testing of the compiled kernels. Instead of the frozen samples in kernel-test-data.json, inputs are Hypothesis-generated and the kernel is checked against its pure-Python reference implementation in kernel-specification.yml (the single source of truth).

This starts with one kernel, awkward_BitMaskedArray_to_ByteMaskedArray, plus the CPU/GPU infrastructure. If the approach works well, it will be extended to the remaining kernels.

What's here

  • tests/properties/kernels/test_BitMaskedArray_to_ByteMaskedArray.py — parametrized over backends:

    • cpu: compiled kernel via awkward_cpp.cpu_kernels (ctypes), always run.
    • cuda: compiled kernel via the CuPy backend, added only when a GPU is present and marked @pytest.mark.cuda.

    The reference implementation is loaded from kernel-specification.yml, so the test does not depend on the generated awkward-cpp/tests-spec/kernels.py.

  • pyproject.toml — registers the cuda marker (--strict-markers).

  • reusable-test.yml — new GPU step pytest tests/properties -m cuda, gated on run-gpu-kernel-tests.

  • reusable-change-detection.ymltests/properties/** added to the GPU change filter, so property-test changes trigger the GPU job.

  • requirementshypothesis-awkward + PyYAML in requirements-test-gpu.txt; PyYAML in requirements-test-full.txt.

Dependency on #4128

This test intentionally carries no @settings (no max_examples, no deadline). The example budget and per-example deadline are expected to come from the central Hypothesis profile in #4128. Until that lands, the GPU run uses Hypothesis defaults (200 ms deadline), which GPU launch latency can exceed; #4128 is the intended source of a GPU-appropriate profile.

Test plan

  • pytest tests/properties/kernelscpu param passes.
  • pytest tests/properties/kernels -m cuda deselects cleanly with no GPU; cuda marker registered.
  • pre-commit on changed files: ruff, codespell, workflow validation, zizmor.
  • GPU job on this PR (self-hosted runner) runs the CuPy kernel against the spec's reference implementation. (Validated in CI; see ci: run property-based tests nightly with a large max_examples #4128 note re: deadline.)

🤖 Generated with Claude Code

@github-actions github-actions Bot added the type/test PR title type: test (set automatically) label Jun 15, 2026
Check awkward_BitMaskedArray_to_ByteMaskedArray against its pure-Python
reference implementation from kernel-specification.yml over
Hypothesis-generated inputs, on the CPU kernel and (with `-m cuda`) the
CUDA kernel. Example budget and deadline come from the central profile
in scikit-hep#4128.

This is a pilot on a single kernel; if it works well, the approach will
be extended to the remaining kernels.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@TaiSakuma
TaiSakuma force-pushed the test/hypothesis-kernels branch from 4f9717b to 6fc4e22 Compare June 18, 2026 18:19
@codecov

codecov Bot commented Jun 18, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 85.42%. Comparing base (95fcb30) to head (6fc4e22).

Additional details and impacted files

see 1 file with indirect coverage changes

@TaiSakuma

Copy link
Copy Markdown
Member Author

After #4128 was merged, all tests in this PR passed.

@ianna ianna left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@TaiSakuma -,this is great! Thank you. Please go ahead and merge it if you are done with it. Thanks

@TaiSakuma
TaiSakuma merged commit e583001 into scikit-hep:main Jun 19, 2026
38 checks passed
@TaiSakuma
TaiSakuma deleted the test/hypothesis-kernels branch July 21, 2026 21:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type/test PR title type: test (set automatically)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants