pytest-gpu-proof 0.4.1__tar.gz → 0.5.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {pytest_gpu_proof-0.4.1 → pytest_gpu_proof-0.5.1}/.github/workflows/ci.yml +1 -1
- {pytest_gpu_proof-0.4.1 → pytest_gpu_proof-0.5.1}/CHANGELOG.md +22 -0
- {pytest_gpu_proof-0.4.1 → pytest_gpu_proof-0.5.1}/CONTRIBUTING.md +1 -1
- {pytest_gpu_proof-0.4.1 → pytest_gpu_proof-0.5.1}/PKG-INFO +8 -5
- {pytest_gpu_proof-0.4.1 → pytest_gpu_proof-0.5.1}/README.md +3 -3
- {pytest_gpu_proof-0.4.1 → pytest_gpu_proof-0.5.1}/docs/architecture.md +12 -1
- {pytest_gpu_proof-0.4.1 → pytest_gpu_proof-0.5.1}/docs/index.md +1 -1
- {pytest_gpu_proof-0.4.1 → pytest_gpu_proof-0.5.1}/pyproject.toml +5 -2
- pytest_gpu_proof-0.5.1/requirements.txt +3 -0
- pytest_gpu_proof-0.5.1/src/pytest_gpu_proof/__init__.py +1 -0
- {pytest_gpu_proof-0.4.1 → pytest_gpu_proof-0.5.1}/src/pytest_gpu_proof/config.py +4 -1
- {pytest_gpu_proof-0.4.1 → pytest_gpu_proof-0.5.1}/src/pytest_gpu_proof/merge.py +1 -1
- {pytest_gpu_proof-0.4.1 → pytest_gpu_proof-0.5.1}/src/pytest_gpu_proof/plugin.py +5 -3
- {pytest_gpu_proof-0.4.1 → pytest_gpu_proof-0.5.1}/src/pytest_gpu_proof/receipt.py +80 -3
- {pytest_gpu_proof-0.4.1 → pytest_gpu_proof-0.5.1}/src/pytest_gpu_proof/verify.py +4 -4
- {pytest_gpu_proof-0.4.1 → pytest_gpu_proof-0.5.1}/tests/conftest.py +13 -0
- {pytest_gpu_proof-0.4.1 → pytest_gpu_proof-0.5.1}/tests/test_cli.py +23 -4
- {pytest_gpu_proof-0.4.1 → pytest_gpu_proof-0.5.1}/tests/test_config.py +20 -0
- {pytest_gpu_proof-0.4.1 → pytest_gpu_proof-0.5.1}/tests/test_merge.py +22 -1
- {pytest_gpu_proof-0.4.1 → pytest_gpu_proof-0.5.1}/tests/test_plugin_capture.py +27 -0
- {pytest_gpu_proof-0.4.1 → pytest_gpu_proof-0.5.1}/tests/test_receipt.py +119 -0
- {pytest_gpu_proof-0.4.1 → pytest_gpu_proof-0.5.1}/tests/test_sharding.py +1 -1
- {pytest_gpu_proof-0.4.1 → pytest_gpu_proof-0.5.1}/tests/test_verifier.py +3 -3
- pytest_gpu_proof-0.4.1/requirements.txt +0 -2
- pytest_gpu_proof-0.4.1/src/pytest_gpu_proof/__init__.py +0 -1
- {pytest_gpu_proof-0.4.1 → pytest_gpu_proof-0.5.1}/.github/workflows/docs.yml +0 -0
- {pytest_gpu_proof-0.4.1 → pytest_gpu_proof-0.5.1}/.github/workflows/publish-testpypi.yml +0 -0
- {pytest_gpu_proof-0.4.1 → pytest_gpu_proof-0.5.1}/.github/workflows/publish.yml +0 -0
- {pytest_gpu_proof-0.4.1 → pytest_gpu_proof-0.5.1}/.gitignore +0 -0
- {pytest_gpu_proof-0.4.1 → pytest_gpu_proof-0.5.1}/AGENTS.md +0 -0
- {pytest_gpu_proof-0.4.1 → pytest_gpu_proof-0.5.1}/CLAUDE.md +0 -0
- {pytest_gpu_proof-0.4.1 → pytest_gpu_proof-0.5.1}/LICENSE +0 -0
- {pytest_gpu_proof-0.4.1 → pytest_gpu_proof-0.5.1}/RELEASING.md +0 -0
- {pytest_gpu_proof-0.4.1 → pytest_gpu_proof-0.5.1}/ROADMAP.md +0 -0
- {pytest_gpu_proof-0.4.1 → pytest_gpu_proof-0.5.1}/SECURITY.md +0 -0
- {pytest_gpu_proof-0.4.1 → pytest_gpu_proof-0.5.1}/docs/ci_gpu_mode.md +0 -0
- {pytest_gpu_proof-0.4.1 → pytest_gpu_proof-0.5.1}/docs/landscape.md +0 -0
- {pytest_gpu_proof-0.4.1 → pytest_gpu_proof-0.5.1}/docs/local_mode.md +0 -0
- {pytest_gpu_proof-0.4.1 → pytest_gpu_proof-0.5.1}/docs/policy.md +0 -0
- {pytest_gpu_proof-0.4.1 → pytest_gpu_proof-0.5.1}/docs/quickstart.md +0 -0
- {pytest_gpu_proof-0.4.1 → pytest_gpu_proof-0.5.1}/docs/security_model.md +0 -0
- {pytest_gpu_proof-0.4.1 → pytest_gpu_proof-0.5.1}/docs/sharding.md +0 -0
- {pytest_gpu_proof-0.4.1 → pytest_gpu_proof-0.5.1}/examples/cuda_ctypes_matmul/Makefile +0 -0
- {pytest_gpu_proof-0.4.1 → pytest_gpu_proof-0.5.1}/examples/cuda_ctypes_matmul/README.md +0 -0
- {pytest_gpu_proof-0.4.1 → pytest_gpu_proof-0.5.1}/examples/cuda_ctypes_matmul/cuda_ctypes_matmul.py +0 -0
- {pytest_gpu_proof-0.4.1 → pytest_gpu_proof-0.5.1}/examples/cuda_ctypes_matmul/matmul_kernel.cu +0 -0
- {pytest_gpu_proof-0.4.1 → pytest_gpu_proof-0.5.1}/examples/cuda_ctypes_matmul/test_cuda_ctypes_matmul.py +0 -0
- {pytest_gpu_proof-0.4.1 → pytest_gpu_proof-0.5.1}/examples/cuda_nanobind_matmul/CMakeLists.txt +0 -0
- {pytest_gpu_proof-0.4.1 → pytest_gpu_proof-0.5.1}/examples/cuda_nanobind_matmul/README.md +0 -0
- {pytest_gpu_proof-0.4.1 → pytest_gpu_proof-0.5.1}/examples/cuda_nanobind_matmul/src/bindings.cpp +0 -0
- {pytest_gpu_proof-0.4.1 → pytest_gpu_proof-0.5.1}/examples/cuda_nanobind_matmul/src/matmul_cuda.h +0 -0
- {pytest_gpu_proof-0.4.1 → pytest_gpu_proof-0.5.1}/examples/cuda_nanobind_matmul/src/matmul_kernel.cu +0 -0
- {pytest_gpu_proof-0.4.1 → pytest_gpu_proof-0.5.1}/examples/cuda_nanobind_matmul/test_cuda_nanobind_matmul.py +0 -0
- {pytest_gpu_proof-0.4.1 → pytest_gpu_proof-0.5.1}/examples/cuda_pybind11_matmul/CMakeLists.txt +0 -0
- {pytest_gpu_proof-0.4.1 → pytest_gpu_proof-0.5.1}/examples/cuda_pybind11_matmul/README.md +0 -0
- {pytest_gpu_proof-0.4.1 → pytest_gpu_proof-0.5.1}/examples/cuda_pybind11_matmul/src/bindings.cpp +0 -0
- {pytest_gpu_proof-0.4.1 → pytest_gpu_proof-0.5.1}/examples/cuda_pybind11_matmul/src/matmul_cuda.h +0 -0
- {pytest_gpu_proof-0.4.1 → pytest_gpu_proof-0.5.1}/examples/cuda_pybind11_matmul/src/matmul_kernel.cu +0 -0
- {pytest_gpu_proof-0.4.1 → pytest_gpu_proof-0.5.1}/examples/cuda_pybind11_matmul/test_cuda_pybind11_matmul.py +0 -0
- {pytest_gpu_proof-0.4.1 → pytest_gpu_proof-0.5.1}/examples/github_gpu_runner/.github/workflows/gpu-test.yml +0 -0
- {pytest_gpu_proof-0.4.1 → pytest_gpu_proof-0.5.1}/examples/jax_ffi_cuda_matmul/CMakeLists.txt +0 -0
- {pytest_gpu_proof-0.4.1 → pytest_gpu_proof-0.5.1}/examples/jax_ffi_cuda_matmul/README.md +0 -0
- {pytest_gpu_proof-0.4.1 → pytest_gpu_proof-0.5.1}/examples/jax_ffi_cuda_matmul/jax_ffi_matmul.py +0 -0
- {pytest_gpu_proof-0.4.1 → pytest_gpu_proof-0.5.1}/examples/jax_ffi_cuda_matmul/src/matmul_ffi.cu +0 -0
- {pytest_gpu_proof-0.4.1 → pytest_gpu_proof-0.5.1}/examples/jax_ffi_cuda_matmul/test_jax_ffi_cuda_matmul.py +0 -0
- {pytest_gpu_proof-0.4.1 → pytest_gpu_proof-0.5.1}/examples/local_receipt_verify/.github/workflows/verify.yml +0 -0
- {pytest_gpu_proof-0.4.1 → pytest_gpu_proof-0.5.1}/examples/minimal_python_only/conftest.py +0 -0
- {pytest_gpu_proof-0.4.1 → pytest_gpu_proof-0.5.1}/examples/minimal_python_only/test_minimal.py +0 -0
- {pytest_gpu_proof-0.4.1 → pytest_gpu_proof-0.5.1}/examples/wrapped_cuda_ctypes/fake_cuda_lib.py +0 -0
- {pytest_gpu_proof-0.4.1 → pytest_gpu_proof-0.5.1}/examples/wrapped_cuda_ctypes/test_cuda_wrapper.py +0 -0
- {pytest_gpu_proof-0.4.1 → pytest_gpu_proof-0.5.1}/install.sh +0 -0
- {pytest_gpu_proof-0.4.1 → pytest_gpu_proof-0.5.1}/mkdocs.yml +0 -0
- {pytest_gpu_proof-0.4.1 → pytest_gpu_proof-0.5.1}/requirements-dev.txt +0 -0
- {pytest_gpu_proof-0.4.1 → pytest_gpu_proof-0.5.1}/src/pytest_gpu_proof/__main__.py +0 -0
- {pytest_gpu_proof-0.4.1 → pytest_gpu_proof-0.5.1}/src/pytest_gpu_proof/cli.py +0 -0
- {pytest_gpu_proof-0.4.1 → pytest_gpu_proof-0.5.1}/src/pytest_gpu_proof/compare.py +0 -0
- {pytest_gpu_proof-0.4.1 → pytest_gpu_proof-0.5.1}/src/pytest_gpu_proof/fingerprint.py +0 -0
- {pytest_gpu_proof-0.4.1 → pytest_gpu_proof-0.5.1}/src/pytest_gpu_proof/gitutils.py +0 -0
- {pytest_gpu_proof-0.4.1 → pytest_gpu_proof-0.5.1}/src/pytest_gpu_proof/signers/__init__.py +0 -0
- {pytest_gpu_proof-0.4.1 → pytest_gpu_proof-0.5.1}/src/pytest_gpu_proof/signers/base.py +0 -0
- {pytest_gpu_proof-0.4.1 → pytest_gpu_proof-0.5.1}/src/pytest_gpu_proof/signers/ed25519.py +0 -0
- {pytest_gpu_proof-0.4.1 → pytest_gpu_proof-0.5.1}/tests/test_compare.py +0 -0
- {pytest_gpu_proof-0.4.1 → pytest_gpu_proof-0.5.1}/tests/test_fingerprint.py +0 -0
- {pytest_gpu_proof-0.4.1 → pytest_gpu_proof-0.5.1}/tests/test_gitutils.py +0 -0
- {pytest_gpu_proof-0.4.1 → pytest_gpu_proof-0.5.1}/tests/test_signing.py +0 -0
- {pytest_gpu_proof-0.4.1 → pytest_gpu_proof-0.5.1}/website/README.md +0 -0
- {pytest_gpu_proof-0.4.1 → pytest_gpu_proof-0.5.1}/website/build_site.py +0 -0
- {pytest_gpu_proof-0.4.1 → pytest_gpu_proof-0.5.1}/website/check_site.py +0 -0
- {pytest_gpu_proof-0.4.1 → pytest_gpu_proof-0.5.1}/website/favicon.svg +0 -0
- {pytest_gpu_proof-0.4.1 → pytest_gpu_proof-0.5.1}/website/index.html +0 -0
- {pytest_gpu_proof-0.4.1 → pytest_gpu_proof-0.5.1}/website/main.js +0 -0
- {pytest_gpu_proof-0.4.1 → pytest_gpu_proof-0.5.1}/website/overrides/main.html +0 -0
- {pytest_gpu_proof-0.4.1 → pytest_gpu_proof-0.5.1}/website/provenance.json +0 -0
- {pytest_gpu_proof-0.4.1 → pytest_gpu_proof-0.5.1}/website/requirements.txt +0 -0
- {pytest_gpu_proof-0.4.1 → pytest_gpu_proof-0.5.1}/website/style.css +0 -0
- {pytest_gpu_proof-0.4.1 → pytest_gpu_proof-0.5.1}/website/test_site.py +0 -0
- {pytest_gpu_proof-0.4.1 → pytest_gpu_proof-0.5.1}/website/workflow-mobile.svg +0 -0
- {pytest_gpu_proof-0.4.1 → pytest_gpu_proof-0.5.1}/website/workflow.svg +0 -0
|
@@ -4,6 +4,28 @@ All notable changes to pytest-gpu-proof are documented here. The format is
|
|
|
4
4
|
based on [Keep a Changelog](https://keepachangelog.com/); versions follow
|
|
5
5
|
[SemVer](https://semver.org/) (pre-1.0: minor bumps may break).
|
|
6
6
|
|
|
7
|
+
## [0.5.1] — 2026-11-03
|
|
8
|
+
|
|
9
|
+
### Added
|
|
10
|
+
|
|
11
|
+
- Python 3.9 support (the oldest Python on a JetPack 5 Jetson), with a CI test
|
|
12
|
+
lane. The code already avoided 3.10-only syntax; only the floor moved.
|
|
13
|
+
- `environment.gpu_info` and the `gpu_required` probe fall back to the CUDA
|
|
14
|
+
driver library (`libcuda` through `ctypes`) when neither `nvidia-smi` nor
|
|
15
|
+
PyTorch is available, as on Jetson boards before JetPack 7. The record names
|
|
16
|
+
its source (`nvidia-smi`, `torch`, or `libcuda`) and stays self-reported
|
|
17
|
+
metadata, not evidence of execution.
|
|
18
|
+
|
|
19
|
+
## [0.5.0] — 2026-10-28
|
|
20
|
+
|
|
21
|
+
### Added
|
|
22
|
+
|
|
23
|
+
- Python 3.10 support with a conditional `tomli` dependency and a CI test lane.
|
|
24
|
+
- Signed `environment.nvcc_version` records the stripped output of
|
|
25
|
+
`nvcc --version` from PATH, or null when unavailable. Fresh shard merges
|
|
26
|
+
require matching compiler metadata; existing receipts without the field
|
|
27
|
+
remain supported.
|
|
28
|
+
|
|
7
29
|
## [0.4.1] — 2026-10-12
|
|
8
30
|
|
|
9
31
|
### Fixed
|
|
@@ -19,7 +19,7 @@ python -m build
|
|
|
19
19
|
python -m twine check --strict dist/*
|
|
20
20
|
```
|
|
21
21
|
|
|
22
|
-
CI runs the test suite on Python 3.11, 3.12, and 3.13, independently enforces
|
|
22
|
+
CI runs the test suite on Python 3.9, 3.10, 3.11, 3.12, and 3.13, independently enforces
|
|
23
23
|
100% line and branch coverage, builds docs strictly, and smoke-tests the wheel.
|
|
24
24
|
|
|
25
25
|
## Change expectations
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: pytest-gpu-proof
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.5.1
|
|
4
4
|
Summary: pytest plugin for GPU equivalence testing with signed receipts verified via GitHub SSH keys
|
|
5
5
|
Project-URL: Homepage, https://a2r-lab.org/pytest-gpu-proof/
|
|
6
6
|
Project-URL: Documentation, https://a2r-lab.org/pytest-gpu-proof/docs/
|
|
@@ -16,14 +16,17 @@ Classifier: Intended Audience :: Developers
|
|
|
16
16
|
Classifier: License :: OSI Approved :: MIT License
|
|
17
17
|
Classifier: Operating System :: OS Independent
|
|
18
18
|
Classifier: Programming Language :: Python :: 3
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
19
21
|
Classifier: Programming Language :: Python :: 3.11
|
|
20
22
|
Classifier: Programming Language :: Python :: 3.12
|
|
21
23
|
Classifier: Programming Language :: Python :: 3.13
|
|
22
24
|
Classifier: Topic :: Security :: Cryptography
|
|
23
25
|
Classifier: Topic :: Software Development :: Testing
|
|
24
|
-
Requires-Python: >=3.
|
|
26
|
+
Requires-Python: >=3.9
|
|
25
27
|
Requires-Dist: cryptography>=41.0
|
|
26
28
|
Requires-Dist: pytest>=7.0
|
|
29
|
+
Requires-Dist: tomli>=2.0; python_version < '3.11'
|
|
27
30
|
Provides-Extra: dev
|
|
28
31
|
Requires-Dist: build>=1.2; extra == 'dev'
|
|
29
32
|
Requires-Dist: coverage[toml]>=7.6; extra == 'dev'
|
|
@@ -90,7 +93,7 @@ cd pytest-gpu-proof
|
|
|
90
93
|
python -m pip install -e ".[dev]"
|
|
91
94
|
```
|
|
92
95
|
|
|
93
|
-
Requirements: Python 3.
|
|
96
|
+
Requirements: Python 3.10+, pytest 7+, and `cryptography` 41+.
|
|
94
97
|
|
|
95
98
|
## Quick start
|
|
96
99
|
|
|
@@ -154,7 +157,7 @@ a map that shard bin-packers can calibrate from.
|
|
|
154
157
|
|---|---|
|
|
155
158
|
| `@pytest.mark.gpu_proof` | Include the test in the receipt |
|
|
156
159
|
| `@pytest.mark.gpu_equivalence` | Alias for `gpu_proof` |
|
|
157
|
-
| `@pytest.mark.gpu_required` | Skip when
|
|
160
|
+
| `@pytest.mark.gpu_required` | Skip when none of `nvidia-smi`, PyTorch, or the CUDA driver library (`libcuda` through `ctypes`) reports a GPU |
|
|
158
161
|
|
|
159
162
|
Skipped tests are recorded. Verification rejects them by default. Prefer an
|
|
160
163
|
exact `--expected-skips` baseline over the broad `--allow-skipped` escape
|
|
@@ -344,7 +347,7 @@ python -m build
|
|
|
344
347
|
python -m twine check --strict dist/*
|
|
345
348
|
```
|
|
346
349
|
|
|
347
|
-
CI tests Python 3.
|
|
350
|
+
CI tests Python 3.10–3.13 and enforces 100% line and branch coverage. See
|
|
348
351
|
[CONTRIBUTING.md](CONTRIBUTING.md), [SECURITY.md](SECURITY.md), and
|
|
349
352
|
[RELEASING.md](RELEASING.md).
|
|
350
353
|
|
|
@@ -52,7 +52,7 @@ cd pytest-gpu-proof
|
|
|
52
52
|
python -m pip install -e ".[dev]"
|
|
53
53
|
```
|
|
54
54
|
|
|
55
|
-
Requirements: Python 3.
|
|
55
|
+
Requirements: Python 3.10+, pytest 7+, and `cryptography` 41+.
|
|
56
56
|
|
|
57
57
|
## Quick start
|
|
58
58
|
|
|
@@ -116,7 +116,7 @@ a map that shard bin-packers can calibrate from.
|
|
|
116
116
|
|---|---|
|
|
117
117
|
| `@pytest.mark.gpu_proof` | Include the test in the receipt |
|
|
118
118
|
| `@pytest.mark.gpu_equivalence` | Alias for `gpu_proof` |
|
|
119
|
-
| `@pytest.mark.gpu_required` | Skip when
|
|
119
|
+
| `@pytest.mark.gpu_required` | Skip when none of `nvidia-smi`, PyTorch, or the CUDA driver library (`libcuda` through `ctypes`) reports a GPU |
|
|
120
120
|
|
|
121
121
|
Skipped tests are recorded. Verification rejects them by default. Prefer an
|
|
122
122
|
exact `--expected-skips` baseline over the broad `--allow-skipped` escape
|
|
@@ -306,7 +306,7 @@ python -m build
|
|
|
306
306
|
python -m twine check --strict dist/*
|
|
307
307
|
```
|
|
308
308
|
|
|
309
|
-
CI tests Python 3.
|
|
309
|
+
CI tests Python 3.10–3.13 and enforces 100% line and branch coverage. See
|
|
310
310
|
[CONTRIBUTING.md](CONTRIBUTING.md), [SECURITY.md](SECURITY.md), and
|
|
311
311
|
[RELEASING.md](RELEASING.md).
|
|
312
312
|
|
|
@@ -52,7 +52,9 @@ The top-level blocks are:
|
|
|
52
52
|
- `fingerprint`: manifest algorithm, tracked paths, extra paths, count, digest;
|
|
53
53
|
- `session`: start/end, pass/fail, exact node IDs, pytest arguments;
|
|
54
54
|
- `tests`: terminal outcome, phase, duration, and comparison checks;
|
|
55
|
-
- `environment`: Python, platform, pytest, plugin, and self-reported GPU data
|
|
55
|
+
- `environment`: Python, platform, pytest, plugin, and self-reported GPU data
|
|
56
|
+
(from `nvidia-smi`, else PyTorch, else the CUDA driver library through `ctypes`;
|
|
57
|
+
`gpu_info.source` names which);
|
|
56
58
|
- `shards`: optional narrow manifests and carry metadata;
|
|
57
59
|
- `signer`: signed username, algorithm, backend, and key fingerprint;
|
|
58
60
|
- `signature`: base64 signature value only.
|
|
@@ -69,6 +71,15 @@ canonical = json.dumps(
|
|
|
69
71
|
Putting signer metadata inside this payload prevents identity or algorithm
|
|
70
72
|
substitution after signing.
|
|
71
73
|
|
|
74
|
+
The optional `environment.nvcc_version` field records the stripped stdout of
|
|
75
|
+
`nvcc --version` resolved through PATH. It is null if the executable is missing,
|
|
76
|
+
cannot run, times out after ten seconds, fails, or returns empty/undecodable output.
|
|
77
|
+
This is self-reported compiler availability, not evidence that this compiler built
|
|
78
|
+
the tested code. It is independent of GPU detection and requires no GPU.
|
|
79
|
+
Existing schema-3 receipts without the field still verify. Fresh shard merges
|
|
80
|
+
require matching values (missing and null are equivalent); carried shards retain
|
|
81
|
+
their original environment metadata.
|
|
82
|
+
|
|
72
83
|
## Fingerprint manifest
|
|
73
84
|
|
|
74
85
|
`sha256-manifest-v2` enumerates stage-0 Git index entries. Regular files bind
|
|
@@ -36,5 +36,5 @@ or exact SSH key fingerprints.
|
|
|
36
36
|
- [Architecture](architecture.md): schema and data flow.
|
|
37
37
|
- [Security model](security_model.md): exact guarantees and limits.
|
|
38
38
|
|
|
39
|
-
Requirements: Python 3.
|
|
39
|
+
Requirements: Python 3.10+, pytest 7+, and an SSH private-key file whose public
|
|
40
40
|
key is registered on GitHub.
|
|
@@ -4,10 +4,10 @@ build-backend = "hatchling.build"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "pytest-gpu-proof"
|
|
7
|
-
version = "0.
|
|
7
|
+
version = "0.5.1"
|
|
8
8
|
description = "pytest plugin for GPU equivalence testing with signed receipts verified via GitHub SSH keys"
|
|
9
9
|
readme = "README.md"
|
|
10
|
-
requires-python = ">=3.
|
|
10
|
+
requires-python = ">=3.9"
|
|
11
11
|
license = { text = "MIT" }
|
|
12
12
|
keywords = ["pytest", "gpu", "cuda", "testing", "signing", "attestation"]
|
|
13
13
|
classifiers = [
|
|
@@ -17,6 +17,8 @@ classifiers = [
|
|
|
17
17
|
"License :: OSI Approved :: MIT License",
|
|
18
18
|
"Operating System :: OS Independent",
|
|
19
19
|
"Programming Language :: Python :: 3",
|
|
20
|
+
"Programming Language :: Python :: 3.9",
|
|
21
|
+
"Programming Language :: Python :: 3.10",
|
|
20
22
|
"Programming Language :: Python :: 3.11",
|
|
21
23
|
"Programming Language :: Python :: 3.12",
|
|
22
24
|
"Programming Language :: Python :: 3.13",
|
|
@@ -26,6 +28,7 @@ classifiers = [
|
|
|
26
28
|
dependencies = [
|
|
27
29
|
"pytest>=7.0",
|
|
28
30
|
"cryptography>=41.0",
|
|
31
|
+
"tomli>=2.0; python_version < '3.11'",
|
|
29
32
|
]
|
|
30
33
|
|
|
31
34
|
[project.urls]
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "0.5.1"
|
|
@@ -67,7 +67,7 @@ def merge_payloads(receipts: List[dict], sources: List[str]) -> dict:
|
|
|
67
67
|
"repo.commit_sha")
|
|
68
68
|
_require_identical(receipts, sources, lambda r: r.get("fingerprint"), "fingerprint")
|
|
69
69
|
_require_identical(receipts, sources, lambda r: r.get("mode"), "mode")
|
|
70
|
-
for key in ("python_version", "platform", "pytest_version", "plugin_version"):
|
|
70
|
+
for key in ("python_version", "platform", "pytest_version", "plugin_version", "nvcc_version"):
|
|
71
71
|
_require_identical(receipts, sources,
|
|
72
72
|
lambda r, k=key: r.get("environment", {}).get(k),
|
|
73
73
|
f"environment.{key}")
|
|
@@ -17,7 +17,7 @@ from .config import GpuProofConfig, load_config
|
|
|
17
17
|
|
|
18
18
|
|
|
19
19
|
def _utcnow() -> str:
|
|
20
|
-
return datetime.datetime.now(datetime.
|
|
20
|
+
return datetime.datetime.now(datetime.timezone.utc).strftime("%Y-%m-%dT%H:%M:%SZ")
|
|
21
21
|
|
|
22
22
|
|
|
23
23
|
def _has_gpu() -> bool:
|
|
@@ -30,10 +30,12 @@ def _has_gpu() -> bool:
|
|
|
30
30
|
pass
|
|
31
31
|
try:
|
|
32
32
|
import torch
|
|
33
|
-
|
|
33
|
+
if torch.cuda.is_available():
|
|
34
|
+
return True
|
|
34
35
|
except ImportError:
|
|
35
36
|
pass
|
|
36
|
-
|
|
37
|
+
from .receipt import _gpu_info_from_libcuda
|
|
38
|
+
return _gpu_info_from_libcuda(include_uuid=False) is not None
|
|
37
39
|
|
|
38
40
|
|
|
39
41
|
class GpuProofPlugin:
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
from __future__ import annotations
|
|
4
4
|
|
|
5
5
|
import base64
|
|
6
|
+
import ctypes
|
|
6
7
|
import datetime
|
|
7
8
|
import json
|
|
8
9
|
import os
|
|
@@ -10,6 +11,7 @@ import platform
|
|
|
10
11
|
import subprocess
|
|
11
12
|
import sys
|
|
12
13
|
import tempfile
|
|
14
|
+
import uuid
|
|
13
15
|
from pathlib import Path
|
|
14
16
|
from typing import Any, Dict, List, Optional
|
|
15
17
|
|
|
@@ -25,7 +27,7 @@ from .gitutils import (
|
|
|
25
27
|
|
|
26
28
|
|
|
27
29
|
def _utcnow() -> str:
|
|
28
|
-
return datetime.datetime.now(datetime.
|
|
30
|
+
return datetime.datetime.now(datetime.timezone.utc).strftime("%Y-%m-%dT%H:%M:%SZ")
|
|
29
31
|
|
|
30
32
|
|
|
31
33
|
def _gpu_info_from_torch() -> Optional[Dict[str, Any]]:
|
|
@@ -56,6 +58,67 @@ def _gpu_info_from_torch() -> Optional[Dict[str, Any]]:
|
|
|
56
58
|
"source": "torch"}
|
|
57
59
|
|
|
58
60
|
|
|
61
|
+
_CU_DEVICE_ATTRIBUTE_COMPUTE_CAPABILITY_MAJOR = 75
|
|
62
|
+
_CU_DEVICE_ATTRIBUTE_COMPUTE_CAPABILITY_MINOR = 76
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
def _gpu_info_from_libcuda(include_uuid: bool = True) -> Optional[Dict[str, Any]]:
|
|
66
|
+
"""nvidia-smi-free, torch-free fallback through the CUDA driver API: ctypes
|
|
67
|
+
on libcuda. Jetson boards before JetPack 7 ship no nvidia-smi, and a plain
|
|
68
|
+
pytest venv there has no torch, so without this a Jetson receipt records
|
|
69
|
+
`gpu_info: null` and fails `require_gpu` for the wrong reason. Still
|
|
70
|
+
self-reported metadata, like the other two sources."""
|
|
71
|
+
try:
|
|
72
|
+
cuda = ctypes.CDLL("libcuda.so.1")
|
|
73
|
+
except OSError:
|
|
74
|
+
return None
|
|
75
|
+
|
|
76
|
+
def call(name: str, *args: Any) -> None:
|
|
77
|
+
rc = getattr(cuda, name)(*args)
|
|
78
|
+
if rc != 0:
|
|
79
|
+
raise OSError(f"{name} returned CUresult {rc}")
|
|
80
|
+
|
|
81
|
+
try:
|
|
82
|
+
call("cuInit", 0)
|
|
83
|
+
count = ctypes.c_int()
|
|
84
|
+
call("cuDeviceGetCount", ctypes.byref(count))
|
|
85
|
+
driver = ctypes.c_int()
|
|
86
|
+
call("cuDriverGetVersion", ctypes.byref(driver))
|
|
87
|
+
driver_version = f"{driver.value // 1000}.{(driver.value % 1000) // 10}"
|
|
88
|
+
devices = []
|
|
89
|
+
for index in range(count.value):
|
|
90
|
+
device = ctypes.c_int()
|
|
91
|
+
call("cuDeviceGet", ctypes.byref(device), index)
|
|
92
|
+
name = ctypes.create_string_buffer(256)
|
|
93
|
+
call("cuDeviceGetName", name, 256, device)
|
|
94
|
+
major, minor = ctypes.c_int(), ctypes.c_int()
|
|
95
|
+
call("cuDeviceGetAttribute", ctypes.byref(major),
|
|
96
|
+
_CU_DEVICE_ATTRIBUTE_COMPUTE_CAPABILITY_MAJOR, device)
|
|
97
|
+
call("cuDeviceGetAttribute", ctypes.byref(minor),
|
|
98
|
+
_CU_DEVICE_ATTRIBUTE_COMPUTE_CAPABILITY_MINOR, device)
|
|
99
|
+
total = ctypes.c_size_t()
|
|
100
|
+
call("cuDeviceTotalMem_v2", ctypes.byref(total), device)
|
|
101
|
+
device_uuid = None
|
|
102
|
+
if include_uuid:
|
|
103
|
+
raw = ctypes.create_string_buffer(16)
|
|
104
|
+
call("cuDeviceGetUuid", raw, device)
|
|
105
|
+
device_uuid = f"GPU-{uuid.UUID(bytes=raw.raw)}"
|
|
106
|
+
devices.append({
|
|
107
|
+
"index": str(index),
|
|
108
|
+
"uuid": device_uuid,
|
|
109
|
+
"name": name.value.decode("utf-8", "replace"),
|
|
110
|
+
"driver_version": driver_version,
|
|
111
|
+
"memory": f"{total.value // (1024 * 1024)} MiB",
|
|
112
|
+
"compute_capability": f"{major.value}.{minor.value}",
|
|
113
|
+
})
|
|
114
|
+
except (AttributeError, OSError): # missing symbol, failed driver call
|
|
115
|
+
return None
|
|
116
|
+
if not devices:
|
|
117
|
+
return None
|
|
118
|
+
return {"devices": devices, "cuda_visible_devices": os.environ.get("CUDA_VISIBLE_DEVICES"),
|
|
119
|
+
"source": "libcuda"}
|
|
120
|
+
|
|
121
|
+
|
|
59
122
|
def _gpu_info(include_uuid: bool = True) -> Optional[Dict[str, Any]]:
|
|
60
123
|
try:
|
|
61
124
|
result = subprocess.run(
|
|
@@ -69,9 +132,9 @@ def _gpu_info(include_uuid: bool = True) -> Optional[Dict[str, Any]]:
|
|
|
69
132
|
timeout=10,
|
|
70
133
|
)
|
|
71
134
|
except (FileNotFoundError, subprocess.TimeoutExpired):
|
|
72
|
-
return _gpu_info_from_torch()
|
|
135
|
+
return _gpu_info_from_torch() or _gpu_info_from_libcuda(include_uuid)
|
|
73
136
|
if result.returncode != 0 or not result.stdout.strip():
|
|
74
|
-
return _gpu_info_from_torch()
|
|
137
|
+
return _gpu_info_from_torch() or _gpu_info_from_libcuda(include_uuid)
|
|
75
138
|
devices = []
|
|
76
139
|
for line in result.stdout.splitlines():
|
|
77
140
|
parts = [part.strip() for part in line.split(",")]
|
|
@@ -92,6 +155,19 @@ def _gpu_info(include_uuid: bool = True) -> Optional[Dict[str, Any]]:
|
|
|
92
155
|
}
|
|
93
156
|
|
|
94
157
|
|
|
158
|
+
def _nvcc_version() -> Optional[str]:
|
|
159
|
+
"""Record the compiler on PATH, independently of GPU availability."""
|
|
160
|
+
try:
|
|
161
|
+
result = subprocess.run(
|
|
162
|
+
["nvcc", "--version"], capture_output=True, text=True, timeout=10,
|
|
163
|
+
)
|
|
164
|
+
except (OSError, subprocess.TimeoutExpired, UnicodeError):
|
|
165
|
+
return None
|
|
166
|
+
if result.returncode != 0:
|
|
167
|
+
return None
|
|
168
|
+
return result.stdout.strip() or None
|
|
169
|
+
|
|
170
|
+
|
|
95
171
|
def _env_info(record_gpu_uuid: bool = True) -> Dict[str, Any]:
|
|
96
172
|
import pytest
|
|
97
173
|
|
|
@@ -102,6 +178,7 @@ def _env_info(record_gpu_uuid: bool = True) -> Dict[str, Any]:
|
|
|
102
178
|
"platform": platform.platform(),
|
|
103
179
|
"pytest_version": pytest.__version__,
|
|
104
180
|
"plugin_version": __version__,
|
|
181
|
+
"nvcc_version": _nvcc_version(),
|
|
105
182
|
"gpu_info": _gpu_info(include_uuid=record_gpu_uuid),
|
|
106
183
|
}
|
|
107
184
|
|
|
@@ -179,7 +179,7 @@ def _parse_time(value, field: str) -> datetime.datetime:
|
|
|
179
179
|
raise VerificationError(f"{field} is missing or is not a UTC timestamp")
|
|
180
180
|
try:
|
|
181
181
|
return datetime.datetime.strptime(value, "%Y-%m-%dT%H:%M:%SZ").replace(
|
|
182
|
-
tzinfo=datetime.
|
|
182
|
+
tzinfo=datetime.timezone.utc
|
|
183
183
|
)
|
|
184
184
|
except ValueError as exc:
|
|
185
185
|
raise VerificationError(f"{field} is not a valid UTC timestamp: {value!r}") from exc
|
|
@@ -498,7 +498,7 @@ def _verify(
|
|
|
498
498
|
raise VerificationError("repository policy requires recorded GPU information")
|
|
499
499
|
|
|
500
500
|
ended = _parse_time(session.get("ended_at"), "session.ended_at")
|
|
501
|
-
age = datetime.datetime.now(datetime.
|
|
501
|
+
age = datetime.datetime.now(datetime.timezone.utc) - ended
|
|
502
502
|
if age < datetime.timedelta(minutes=-5):
|
|
503
503
|
raise VerificationError("receipt timestamp is in the future")
|
|
504
504
|
if age > datetime.timedelta(days=max_days):
|
|
@@ -508,7 +508,7 @@ def _verify(
|
|
|
508
508
|
committed = get_commit_time(stored_sha, root)
|
|
509
509
|
if committed is not None:
|
|
510
510
|
started = _parse_time(session.get("started_at"), "session.started_at")
|
|
511
|
-
commit_dt = datetime.datetime.fromtimestamp(committed, datetime.
|
|
511
|
+
commit_dt = datetime.datetime.fromtimestamp(committed, datetime.timezone.utc)
|
|
512
512
|
if started < commit_dt - datetime.timedelta(minutes=5):
|
|
513
513
|
raise VerificationError(
|
|
514
514
|
"receipt session started before its commit existed "
|
|
@@ -577,7 +577,7 @@ def _verify_shards(receipt: dict, root: str, policy: dict, max_days: int = 30) -
|
|
|
577
577
|
raise VerificationError(
|
|
578
578
|
f"carried shard {name!r} was recorded with a dirty working tree")
|
|
579
579
|
original = _parse_time(carried.get("original_ended_at"), f"shard {name}.original_ended_at")
|
|
580
|
-
age = datetime.datetime.now(datetime.
|
|
580
|
+
age = datetime.datetime.now(datetime.timezone.utc) - original
|
|
581
581
|
# A carried shard's original run is never allowed to be older than
|
|
582
582
|
# the receipt itself may be, unless policy says so explicitly.
|
|
583
583
|
limit = policy.get("carried_max_age_days", min(30, max_days))
|
|
@@ -89,3 +89,16 @@ def tmp_git_repo(tmp_path):
|
|
|
89
89
|
"*.json\nid_*\nexpected_skips.txt\npyproject.toml\n"
|
|
90
90
|
)
|
|
91
91
|
return tmp_path
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
@pytest.fixture(autouse=True)
|
|
95
|
+
def _no_host_nvcc(monkeypatch):
|
|
96
|
+
"""Compiler metadata tests override this deterministic default explicitly."""
|
|
97
|
+
run = subprocess.run
|
|
98
|
+
|
|
99
|
+
def without_host_nvcc(args, *positional, **kwargs):
|
|
100
|
+
if args == ["nvcc", "--version"]:
|
|
101
|
+
return subprocess.CompletedProcess(args, 0, stdout="test nvcc version\n", stderr="")
|
|
102
|
+
return run(args, *positional, **kwargs)
|
|
103
|
+
|
|
104
|
+
monkeypatch.setattr(subprocess, "run", without_host_nvcc)
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import
|
|
1
|
+
import subprocess
|
|
2
|
+
from importlib.util import spec_from_file_location
|
|
3
|
+
from pathlib import Path
|
|
2
4
|
import sys
|
|
3
5
|
from types import SimpleNamespace
|
|
4
6
|
|
|
@@ -69,14 +71,31 @@ def test_merge_cli_success_and_error(monkeypatch, capsys):
|
|
|
69
71
|
def test_module_entrypoint(monkeypatch):
|
|
70
72
|
monkeypatch.setattr("pytest_gpu_proof.cli.main", lambda: (_ for _ in ()).throw(SystemExit(7)))
|
|
71
73
|
with pytest.raises(SystemExit) as exc:
|
|
72
|
-
|
|
74
|
+
path = Path(cli.__file__).with_name("__main__.py")
|
|
75
|
+
exec(compile(path.read_text(), str(path), "exec"),
|
|
76
|
+
{"__name__": "__main__", "__package__": "pytest_gpu_proof",
|
|
77
|
+
"__file__": str(path),
|
|
78
|
+
"__spec__": spec_from_file_location(f"pytest_gpu_proof.{path.stem}", path)})
|
|
73
79
|
assert exc.value.code == 7
|
|
74
80
|
|
|
75
81
|
|
|
76
|
-
@pytest.mark.filterwarnings("ignore:.*found in sys.modules.*:RuntimeWarning")
|
|
77
82
|
def test_cli_file_entrypoint(monkeypatch):
|
|
78
83
|
monkeypatch.setattr("pytest_gpu_proof.verify.verify_receipt", lambda **kwargs: True)
|
|
79
84
|
monkeypatch.setattr(sys, "argv", ["gpu-proof", "verify", "--receipt", "r.json"])
|
|
80
85
|
with pytest.raises(SystemExit) as exc:
|
|
81
|
-
|
|
86
|
+
path = Path(cli.__file__)
|
|
87
|
+
exec(compile(path.read_text(), str(path), "exec"),
|
|
88
|
+
{"__name__": "__main__", "__package__": "pytest_gpu_proof",
|
|
89
|
+
"__file__": str(path),
|
|
90
|
+
"__spec__": spec_from_file_location(f"pytest_gpu_proof.{path.stem}", path)})
|
|
82
91
|
assert exc.value.code == 0
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
@pytest.mark.parametrize("module", ["pytest_gpu_proof", "pytest_gpu_proof.cli"])
|
|
95
|
+
def test_module_cli_in_fresh_interpreter(module):
|
|
96
|
+
# Real -m invocation has no pytest assertion-rewriting loader. The in-process
|
|
97
|
+
# source-execution tests above retain coverage and mocks for exit/dispatch behavior.
|
|
98
|
+
result = subprocess.run([sys.executable, "-m", module, "--help"],
|
|
99
|
+
capture_output=True, text=True, timeout=10)
|
|
100
|
+
assert result.returncode == 0, result.stderr
|
|
101
|
+
assert "verify signed GPU test receipts" in result.stdout
|
|
@@ -121,3 +121,23 @@ def test_record_gpu_uuid_from_toml(tmp_path):
|
|
|
121
121
|
)
|
|
122
122
|
)
|
|
123
123
|
assert config.record_gpu_uuid is False
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
def test_tomli_fallback(monkeypatch, tmp_path):
|
|
127
|
+
import builtins
|
|
128
|
+
import runpy
|
|
129
|
+
import pytest_gpu_proof.config as config
|
|
130
|
+
|
|
131
|
+
original_import = builtins.__import__
|
|
132
|
+
|
|
133
|
+
def without_tomllib(name, *args, **kwargs):
|
|
134
|
+
if name == "tomllib":
|
|
135
|
+
raise ModuleNotFoundError("No module named 'tomllib'")
|
|
136
|
+
if name == "tomli":
|
|
137
|
+
return config.tomllib
|
|
138
|
+
return original_import(name, *args, **kwargs)
|
|
139
|
+
|
|
140
|
+
monkeypatch.setattr(builtins, "__import__", without_tomllib)
|
|
141
|
+
namespace = runpy.run_path(config.__file__)
|
|
142
|
+
(tmp_path / "pyproject.toml").write_text('[tool.gpu_proof]\nmode = "local"\n')
|
|
143
|
+
assert namespace["load_toml_defaults"](tmp_path) == {"mode": "local"}
|
|
@@ -30,7 +30,7 @@ def signer_with_key(tmp_path, ed25519_keypair):
|
|
|
30
30
|
|
|
31
31
|
|
|
32
32
|
def _utcstamp(minutes_ago: int = 0) -> str:
|
|
33
|
-
ts = datetime.datetime.now(datetime.
|
|
33
|
+
ts = datetime.datetime.now(datetime.timezone.utc) - datetime.timedelta(minutes=minutes_ago)
|
|
34
34
|
return ts.strftime("%Y-%m-%dT%H:%M:%SZ")
|
|
35
35
|
|
|
36
36
|
|
|
@@ -241,3 +241,24 @@ def test_schema1_merge_has_no_schema3_session_fields():
|
|
|
241
241
|
merged = merge_payloads([base], ["one.json"])
|
|
242
242
|
assert "outcome" not in merged["session"]
|
|
243
243
|
assert "shards" not in merged
|
|
244
|
+
|
|
245
|
+
|
|
246
|
+
@pytest.mark.parametrize("first, second", [("V13.2", "V12.8"), ("V13.2", None)])
|
|
247
|
+
def test_refuses_nvcc_mismatch(tmp_path, tmp_git_repo, signer_with_key, first, second):
|
|
248
|
+
signer, _, _ = signer_with_key
|
|
249
|
+
a = _shard(tmp_path, tmp_git_repo, signer, "a.json", [_result("t::a")],
|
|
250
|
+
mutate=lambda p: p["environment"].__setitem__("nvcc_version", first))
|
|
251
|
+
b = _shard(tmp_path, tmp_git_repo, signer, "b.json", [_result("t::b")],
|
|
252
|
+
mutate=lambda p: p["environment"].__setitem__("nvcc_version", second))
|
|
253
|
+
with pytest.raises(MergeError, match="environment.nvcc_version"):
|
|
254
|
+
merge_payloads([json.loads(a.read_text()), json.loads(b.read_text())], ["a", "b"])
|
|
255
|
+
|
|
256
|
+
|
|
257
|
+
def test_merge_old_receipt_without_nvcc(tmp_path, tmp_git_repo, signer_with_key):
|
|
258
|
+
signer, _, _ = signer_with_key
|
|
259
|
+
a = _shard(tmp_path, tmp_git_repo, signer, "a.json", [_result("t::a")],
|
|
260
|
+
mutate=lambda p: p["environment"].pop("nvcc_version", None))
|
|
261
|
+
b = _shard(tmp_path, tmp_git_repo, signer, "b.json", [_result("t::b")],
|
|
262
|
+
mutate=lambda p: p["environment"].__setitem__("nvcc_version", None))
|
|
263
|
+
merged = merge_payloads([json.loads(a.read_text()), json.loads(b.read_text())], ["a", "b"])
|
|
264
|
+
assert len(merged["tests"]) == 2
|
|
@@ -455,6 +455,31 @@ def test_has_gpu_fallbacks(monkeypatch):
|
|
|
455
455
|
raise ImportError
|
|
456
456
|
return real_import(name, *args, **kwargs)
|
|
457
457
|
monkeypatch.setattr(builtins, "__import__", no_torch)
|
|
458
|
+
monkeypatch.setattr("pytest_gpu_proof.receipt._gpu_info_from_libcuda",
|
|
459
|
+
lambda include_uuid=True: None)
|
|
460
|
+
assert plugin_module._has_gpu() is False
|
|
461
|
+
|
|
462
|
+
|
|
463
|
+
def test_has_gpu_falls_back_to_libcuda(monkeypatch):
|
|
464
|
+
"""2026-11-02: the marker probe and the receipt share the libcuda fallback,
|
|
465
|
+
so a Jetson without nvidia-smi or torch neither skips gpu_required tests
|
|
466
|
+
nor records gpu_info: null."""
|
|
467
|
+
import subprocess
|
|
468
|
+
from types import SimpleNamespace
|
|
469
|
+
|
|
470
|
+
monkeypatch.setattr(subprocess, "run", lambda *a, **k: subprocess.CompletedProcess([], 1))
|
|
471
|
+
monkeypatch.setitem(__import__("sys").modules, "torch",
|
|
472
|
+
SimpleNamespace(cuda=SimpleNamespace(is_available=lambda: False)))
|
|
473
|
+
seen = []
|
|
474
|
+
|
|
475
|
+
def probe(include_uuid=True):
|
|
476
|
+
seen.append(include_uuid)
|
|
477
|
+
return {"devices": [{"index": "0"}], "cuda_visible_devices": None, "source": "libcuda"}
|
|
478
|
+
monkeypatch.setattr("pytest_gpu_proof.receipt._gpu_info_from_libcuda", probe)
|
|
479
|
+
assert plugin_module._has_gpu() is True
|
|
480
|
+
assert seen == [False]
|
|
481
|
+
monkeypatch.setattr("pytest_gpu_proof.receipt._gpu_info_from_libcuda",
|
|
482
|
+
lambda include_uuid=True: None)
|
|
458
483
|
assert plugin_module._has_gpu() is False
|
|
459
484
|
|
|
460
485
|
|
|
@@ -517,6 +542,8 @@ def test_has_gpu_handles_nvidia_error(monkeypatch):
|
|
|
517
542
|
raise ImportError
|
|
518
543
|
return real_import(name, *args, **kwargs)
|
|
519
544
|
monkeypatch.setattr(builtins, "__import__", no_torch)
|
|
545
|
+
monkeypatch.setattr("pytest_gpu_proof.receipt._gpu_info_from_libcuda",
|
|
546
|
+
lambda include_uuid=True: None)
|
|
520
547
|
assert plugin_module._has_gpu() is False
|
|
521
548
|
|
|
522
549
|
|
|
@@ -110,6 +110,8 @@ def test_gpu_capture_unavailable(monkeypatch, behavior):
|
|
|
110
110
|
monkeypatch.setattr(
|
|
111
111
|
"pytest_gpu_proof.receipt.subprocess.run", lambda *a, **k: behavior()
|
|
112
112
|
)
|
|
113
|
+
monkeypatch.setattr("pytest_gpu_proof.receipt._gpu_info_from_libcuda",
|
|
114
|
+
lambda include_uuid=True: None)
|
|
113
115
|
assert _gpu_info() is None
|
|
114
116
|
|
|
115
117
|
|
|
@@ -313,6 +315,7 @@ def test_gpu_info_falls_back_to_torch_when_nvidia_smi_is_absent(monkeypatch):
|
|
|
313
315
|
def no_smi(*args, **kwargs):
|
|
314
316
|
raise FileNotFoundError("nvidia-smi")
|
|
315
317
|
monkeypatch.setattr(receipt_mod.subprocess, "run", no_smi)
|
|
318
|
+
monkeypatch.setattr(receipt_mod, "_gpu_info_from_libcuda", lambda include_uuid=True: None)
|
|
316
319
|
props = types.SimpleNamespace(name="Fake GPU", total_memory=8 * 1024 ** 3, major=12, minor=0)
|
|
317
320
|
fake_cuda = types.SimpleNamespace(is_available=lambda: True, device_count=lambda: 1,
|
|
318
321
|
get_device_properties=lambda i: props)
|
|
@@ -338,4 +341,120 @@ def test_gpu_info_falls_back_to_torch_on_nvidia_smi_failure(monkeypatch):
|
|
|
338
341
|
monkeypatch.setattr(receipt_mod.subprocess, "run",
|
|
339
342
|
lambda *a, **k: types.SimpleNamespace(returncode=1, stdout=""))
|
|
340
343
|
monkeypatch.setitem(sys.modules, "torch", None)
|
|
344
|
+
monkeypatch.setattr(receipt_mod, "_gpu_info_from_libcuda", lambda include_uuid=True: None)
|
|
341
345
|
assert receipt_mod._gpu_info() is None
|
|
346
|
+
|
|
347
|
+
|
|
348
|
+
class _FakeLibcuda:
|
|
349
|
+
"""Stand-in for ctypes.CDLL('libcuda.so.1'): every entry point writes the
|
|
350
|
+
canned answer into its ctypes out-argument and returns CUDA_SUCCESS, except
|
|
351
|
+
`fail`, which returns a nonzero CUresult, and `missing`, which is absent."""
|
|
352
|
+
|
|
353
|
+
def __init__(self, count=1, fail=None, missing=None):
|
|
354
|
+
self.count, self.fail, self.missing = count, fail, missing
|
|
355
|
+
|
|
356
|
+
def __getattr__(self, name):
|
|
357
|
+
if name == self.missing:
|
|
358
|
+
raise AttributeError(name)
|
|
359
|
+
|
|
360
|
+
def entry(*args):
|
|
361
|
+
if name == self.fail:
|
|
362
|
+
return 999
|
|
363
|
+
if name == "cuDeviceGetCount":
|
|
364
|
+
args[0]._obj.value = self.count
|
|
365
|
+
elif name == "cuDriverGetVersion":
|
|
366
|
+
args[0]._obj.value = 13020
|
|
367
|
+
elif name == "cuDeviceGet":
|
|
368
|
+
args[0]._obj.value = args[1]
|
|
369
|
+
elif name == "cuDeviceGetName":
|
|
370
|
+
args[0].value = b"Fake Orin"
|
|
371
|
+
elif name == "cuDeviceGetAttribute":
|
|
372
|
+
args[0]._obj.value = {75: 8, 76: 7}[args[1]]
|
|
373
|
+
elif name == "cuDeviceTotalMem_v2":
|
|
374
|
+
args[0]._obj.value = 62878 * 1024 * 1024
|
|
375
|
+
elif name == "cuDeviceGetUuid":
|
|
376
|
+
args[0].raw = bytes(range(16))
|
|
377
|
+
return 0
|
|
378
|
+
return entry
|
|
379
|
+
|
|
380
|
+
|
|
381
|
+
def _no_smi_no_torch(monkeypatch, receipt_mod):
|
|
382
|
+
import sys
|
|
383
|
+
|
|
384
|
+
def no_smi(*args, **kwargs):
|
|
385
|
+
raise FileNotFoundError("nvidia-smi")
|
|
386
|
+
monkeypatch.setattr(receipt_mod.subprocess, "run", no_smi)
|
|
387
|
+
monkeypatch.setitem(sys.modules, "torch", None)
|
|
388
|
+
|
|
389
|
+
|
|
390
|
+
def test_gpu_info_falls_back_to_libcuda(monkeypatch):
|
|
391
|
+
"""2026-11-02: a Jetson before JetPack 7 has no nvidia-smi and a plain venv
|
|
392
|
+
has no torch; the CUDA driver library still identifies the device."""
|
|
393
|
+
from pytest_gpu_proof import receipt as receipt_mod
|
|
394
|
+
_no_smi_no_torch(monkeypatch, receipt_mod)
|
|
395
|
+
monkeypatch.setattr(receipt_mod.ctypes, "CDLL", lambda name: _FakeLibcuda(count=2))
|
|
396
|
+
monkeypatch.setenv("CUDA_VISIBLE_DEVICES", "0")
|
|
397
|
+
info = receipt_mod._gpu_info()
|
|
398
|
+
assert info["source"] == "libcuda"
|
|
399
|
+
assert info["cuda_visible_devices"] == "0"
|
|
400
|
+
assert info["devices"][0] == {
|
|
401
|
+
"index": "0", "uuid": "GPU-00010203-0405-0607-0809-0a0b0c0d0e0f", "name": "Fake Orin",
|
|
402
|
+
"driver_version": "13.2", "memory": "62878 MiB", "compute_capability": "8.7"}
|
|
403
|
+
assert info["devices"][1]["index"] == "1"
|
|
404
|
+
anonymous = receipt_mod._gpu_info(include_uuid=False)
|
|
405
|
+
assert [d["uuid"] for d in anonymous["devices"]] == [None, None]
|
|
406
|
+
assert anonymous["devices"][0]["name"] == "Fake Orin"
|
|
407
|
+
|
|
408
|
+
|
|
409
|
+
@pytest.mark.parametrize("fake", [
|
|
410
|
+
None, # libcuda.so.1 not loadable
|
|
411
|
+
_FakeLibcuda(fail="cuInit"), # a driver call fails
|
|
412
|
+
_FakeLibcuda(fail="cuDeviceGetUuid"), # a per-device call fails
|
|
413
|
+
_FakeLibcuda(missing="cuDeviceGetName"), # symbol absent from the library
|
|
414
|
+
_FakeLibcuda(count=0), # driver loads, no device
|
|
415
|
+
])
|
|
416
|
+
def test_gpu_info_libcuda_fallback_fails_closed(monkeypatch, fake):
|
|
417
|
+
from pytest_gpu_proof import receipt as receipt_mod
|
|
418
|
+
_no_smi_no_torch(monkeypatch, receipt_mod)
|
|
419
|
+
|
|
420
|
+
def load(name):
|
|
421
|
+
if fake is None:
|
|
422
|
+
raise OSError(f"{name}: cannot open shared object file")
|
|
423
|
+
return fake
|
|
424
|
+
monkeypatch.setattr(receipt_mod.ctypes, "CDLL", load)
|
|
425
|
+
assert receipt_mod._gpu_info() is None
|
|
426
|
+
|
|
427
|
+
|
|
428
|
+
@pytest.mark.parametrize("code, output, expected", [
|
|
429
|
+
(0, "nvcc: NVIDIA (R) Cuda compiler driver\nCuda compilation tools, release 13.2, V13.2.51\n",
|
|
430
|
+
"nvcc: NVIDIA (R) Cuda compiler driver\nCuda compilation tools, release 13.2, V13.2.51"),
|
|
431
|
+
(0, " \n", None),
|
|
432
|
+
(1, "partial output", None),
|
|
433
|
+
])
|
|
434
|
+
def test_nvcc_version(monkeypatch, code, output, expected):
|
|
435
|
+
import subprocess
|
|
436
|
+
from pytest_gpu_proof.receipt import _nvcc_version
|
|
437
|
+
|
|
438
|
+
def run(args, **kwargs):
|
|
439
|
+
assert args == ["nvcc", "--version"]
|
|
440
|
+
assert kwargs == {"capture_output": True, "text": True, "timeout": 10}
|
|
441
|
+
return subprocess.CompletedProcess(args, code, stdout=output, stderr="ignored")
|
|
442
|
+
|
|
443
|
+
monkeypatch.setattr("pytest_gpu_proof.receipt.subprocess.run", run)
|
|
444
|
+
assert _nvcc_version() == expected
|
|
445
|
+
monkeypatch.setattr("pytest_gpu_proof.receipt._gpu_info", lambda **kw: None)
|
|
446
|
+
assert _env_info()["nvcc_version"] == expected
|
|
447
|
+
|
|
448
|
+
|
|
449
|
+
@pytest.mark.parametrize("error", [
|
|
450
|
+
FileNotFoundError(), PermissionError(),
|
|
451
|
+
__import__("subprocess").TimeoutExpired("nvcc", 10), UnicodeError(),
|
|
452
|
+
])
|
|
453
|
+
def test_nvcc_unavailable(monkeypatch, error):
|
|
454
|
+
from pytest_gpu_proof.receipt import _nvcc_version
|
|
455
|
+
|
|
456
|
+
def run(*args, **kwargs):
|
|
457
|
+
raise error
|
|
458
|
+
|
|
459
|
+
monkeypatch.setattr("pytest_gpu_proof.receipt.subprocess.run", run)
|
|
460
|
+
assert _nvcc_version() is None
|
|
@@ -37,7 +37,7 @@ def signer_with_key(tmp_path, ed25519_keypair):
|
|
|
37
37
|
|
|
38
38
|
|
|
39
39
|
def _utcstamp(days_ago: float = 0) -> str:
|
|
40
|
-
ts = datetime.datetime.now(datetime.
|
|
40
|
+
ts = datetime.datetime.now(datetime.timezone.utc) - datetime.timedelta(days=days_ago)
|
|
41
41
|
return ts.strftime("%Y-%m-%dT%H:%M:%SZ")
|
|
42
42
|
|
|
43
43
|
|
|
@@ -38,7 +38,7 @@ def signer_with_key(tmp_path, keypair):
|
|
|
38
38
|
|
|
39
39
|
|
|
40
40
|
def _utcstamp(days_ago: int = 0) -> str:
|
|
41
|
-
ts = datetime.datetime.now(datetime.
|
|
41
|
+
ts = datetime.datetime.now(datetime.timezone.utc) - datetime.timedelta(days=days_ago)
|
|
42
42
|
return ts.strftime("%Y-%m-%dT%H:%M:%SZ")
|
|
43
43
|
|
|
44
44
|
|
|
@@ -273,7 +273,7 @@ def test_verify_fails_on_failed_test(tmp_path, tmp_git_repo, signer_with_key):
|
|
|
273
273
|
}
|
|
274
274
|
]
|
|
275
275
|
import datetime
|
|
276
|
-
now = datetime.datetime.now(datetime.
|
|
276
|
+
now = datetime.datetime.now(datetime.timezone.utc).strftime("%Y-%m-%dT%H:%M:%SZ")
|
|
277
277
|
payload = build_receipt_payload(config, results, now, now)
|
|
278
278
|
receipt = finalize_receipt(payload, signer)
|
|
279
279
|
path = tmp_path / "gpu-proof.json"
|
|
@@ -571,7 +571,7 @@ def test_verifier_wrapper_reports_failure(tmp_path, tmp_git_repo, capsys):
|
|
|
571
571
|
|
|
572
572
|
def test_future_and_invalid_age_policy(tmp_path, tmp_git_repo, signer_with_key):
|
|
573
573
|
signer, public_key = signer_with_key
|
|
574
|
-
future = (datetime.datetime.now(datetime.
|
|
574
|
+
future = (datetime.datetime.now(datetime.timezone.utc) + datetime.timedelta(days=1)).strftime("%Y-%m-%dT%H:%M:%SZ")
|
|
575
575
|
path = _make_receipt(tmp_path, tmp_git_repo, signer, ended_at=future)
|
|
576
576
|
with _mock_github_keys(public_key), pytest.raises(VerificationError, match="future"):
|
|
577
577
|
_verify(str(path), None, str(tmp_git_repo), "testuser", None)
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
__version__ = "0.4.1"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{pytest_gpu_proof-0.4.1 → pytest_gpu_proof-0.5.1}/examples/cuda_ctypes_matmul/cuda_ctypes_matmul.py
RENAMED
|
File without changes
|
{pytest_gpu_proof-0.4.1 → pytest_gpu_proof-0.5.1}/examples/cuda_ctypes_matmul/matmul_kernel.cu
RENAMED
|
File without changes
|
|
File without changes
|
{pytest_gpu_proof-0.4.1 → pytest_gpu_proof-0.5.1}/examples/cuda_nanobind_matmul/CMakeLists.txt
RENAMED
|
File without changes
|
|
File without changes
|
{pytest_gpu_proof-0.4.1 → pytest_gpu_proof-0.5.1}/examples/cuda_nanobind_matmul/src/bindings.cpp
RENAMED
|
File without changes
|
{pytest_gpu_proof-0.4.1 → pytest_gpu_proof-0.5.1}/examples/cuda_nanobind_matmul/src/matmul_cuda.h
RENAMED
|
File without changes
|
{pytest_gpu_proof-0.4.1 → pytest_gpu_proof-0.5.1}/examples/cuda_nanobind_matmul/src/matmul_kernel.cu
RENAMED
|
File without changes
|
|
File without changes
|
{pytest_gpu_proof-0.4.1 → pytest_gpu_proof-0.5.1}/examples/cuda_pybind11_matmul/CMakeLists.txt
RENAMED
|
File without changes
|
|
File without changes
|
{pytest_gpu_proof-0.4.1 → pytest_gpu_proof-0.5.1}/examples/cuda_pybind11_matmul/src/bindings.cpp
RENAMED
|
File without changes
|
{pytest_gpu_proof-0.4.1 → pytest_gpu_proof-0.5.1}/examples/cuda_pybind11_matmul/src/matmul_cuda.h
RENAMED
|
File without changes
|
{pytest_gpu_proof-0.4.1 → pytest_gpu_proof-0.5.1}/examples/cuda_pybind11_matmul/src/matmul_kernel.cu
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{pytest_gpu_proof-0.4.1 → pytest_gpu_proof-0.5.1}/examples/jax_ffi_cuda_matmul/CMakeLists.txt
RENAMED
|
File without changes
|
|
File without changes
|
{pytest_gpu_proof-0.4.1 → pytest_gpu_proof-0.5.1}/examples/jax_ffi_cuda_matmul/jax_ffi_matmul.py
RENAMED
|
File without changes
|
{pytest_gpu_proof-0.4.1 → pytest_gpu_proof-0.5.1}/examples/jax_ffi_cuda_matmul/src/matmul_ffi.cu
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{pytest_gpu_proof-0.4.1 → pytest_gpu_proof-0.5.1}/examples/minimal_python_only/test_minimal.py
RENAMED
|
File without changes
|
{pytest_gpu_proof-0.4.1 → pytest_gpu_proof-0.5.1}/examples/wrapped_cuda_ctypes/fake_cuda_lib.py
RENAMED
|
File without changes
|
{pytest_gpu_proof-0.4.1 → pytest_gpu_proof-0.5.1}/examples/wrapped_cuda_ctypes/test_cuda_wrapper.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|