pytest-gpu-proof 0.5.0__tar.gz → 0.5.2__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.
Files changed (97) hide show
  1. {pytest_gpu_proof-0.5.0 → pytest_gpu_proof-0.5.2}/.github/workflows/ci.yml +3 -2
  2. {pytest_gpu_proof-0.5.0 → pytest_gpu_proof-0.5.2}/CHANGELOG.md +17 -0
  3. {pytest_gpu_proof-0.5.0 → pytest_gpu_proof-0.5.2}/CONTRIBUTING.md +1 -1
  4. {pytest_gpu_proof-0.5.0 → pytest_gpu_proof-0.5.2}/PKG-INFO +4 -3
  5. {pytest_gpu_proof-0.5.0 → pytest_gpu_proof-0.5.2}/README.md +1 -1
  6. {pytest_gpu_proof-0.5.0 → pytest_gpu_proof-0.5.2}/docs/architecture.md +3 -1
  7. {pytest_gpu_proof-0.5.0 → pytest_gpu_proof-0.5.2}/docs/policy.md +1 -0
  8. {pytest_gpu_proof-0.5.0 → pytest_gpu_proof-0.5.2}/docs/security_model.md +1 -1
  9. {pytest_gpu_proof-0.5.0 → pytest_gpu_proof-0.5.2}/pyproject.toml +3 -2
  10. pytest_gpu_proof-0.5.2/src/pytest_gpu_proof/__init__.py +1 -0
  11. {pytest_gpu_proof-0.5.0 → pytest_gpu_proof-0.5.2}/src/pytest_gpu_proof/plugin.py +4 -2
  12. {pytest_gpu_proof-0.5.0 → pytest_gpu_proof-0.5.2}/src/pytest_gpu_proof/receipt.py +65 -2
  13. {pytest_gpu_proof-0.5.0 → pytest_gpu_proof-0.5.2}/src/pytest_gpu_proof/verify.py +13 -4
  14. {pytest_gpu_proof-0.5.0 → pytest_gpu_proof-0.5.2}/tests/test_plugin_capture.py +27 -0
  15. {pytest_gpu_proof-0.5.0 → pytest_gpu_proof-0.5.2}/tests/test_receipt.py +84 -0
  16. {pytest_gpu_proof-0.5.0 → pytest_gpu_proof-0.5.2}/tests/test_sharding.py +7 -1
  17. {pytest_gpu_proof-0.5.0 → pytest_gpu_proof-0.5.2}/tests/test_verifier.py +8 -1
  18. pytest_gpu_proof-0.5.0/src/pytest_gpu_proof/__init__.py +0 -1
  19. {pytest_gpu_proof-0.5.0 → pytest_gpu_proof-0.5.2}/.github/workflows/docs.yml +0 -0
  20. {pytest_gpu_proof-0.5.0 → pytest_gpu_proof-0.5.2}/.github/workflows/publish-testpypi.yml +0 -0
  21. {pytest_gpu_proof-0.5.0 → pytest_gpu_proof-0.5.2}/.github/workflows/publish.yml +0 -0
  22. {pytest_gpu_proof-0.5.0 → pytest_gpu_proof-0.5.2}/.gitignore +0 -0
  23. {pytest_gpu_proof-0.5.0 → pytest_gpu_proof-0.5.2}/AGENTS.md +0 -0
  24. {pytest_gpu_proof-0.5.0 → pytest_gpu_proof-0.5.2}/CLAUDE.md +0 -0
  25. {pytest_gpu_proof-0.5.0 → pytest_gpu_proof-0.5.2}/LICENSE +0 -0
  26. {pytest_gpu_proof-0.5.0 → pytest_gpu_proof-0.5.2}/RELEASING.md +0 -0
  27. {pytest_gpu_proof-0.5.0 → pytest_gpu_proof-0.5.2}/ROADMAP.md +0 -0
  28. {pytest_gpu_proof-0.5.0 → pytest_gpu_proof-0.5.2}/SECURITY.md +0 -0
  29. {pytest_gpu_proof-0.5.0 → pytest_gpu_proof-0.5.2}/docs/ci_gpu_mode.md +0 -0
  30. {pytest_gpu_proof-0.5.0 → pytest_gpu_proof-0.5.2}/docs/index.md +0 -0
  31. {pytest_gpu_proof-0.5.0 → pytest_gpu_proof-0.5.2}/docs/landscape.md +0 -0
  32. {pytest_gpu_proof-0.5.0 → pytest_gpu_proof-0.5.2}/docs/local_mode.md +0 -0
  33. {pytest_gpu_proof-0.5.0 → pytest_gpu_proof-0.5.2}/docs/quickstart.md +0 -0
  34. {pytest_gpu_proof-0.5.0 → pytest_gpu_proof-0.5.2}/docs/sharding.md +0 -0
  35. {pytest_gpu_proof-0.5.0 → pytest_gpu_proof-0.5.2}/examples/cuda_ctypes_matmul/Makefile +0 -0
  36. {pytest_gpu_proof-0.5.0 → pytest_gpu_proof-0.5.2}/examples/cuda_ctypes_matmul/README.md +0 -0
  37. {pytest_gpu_proof-0.5.0 → pytest_gpu_proof-0.5.2}/examples/cuda_ctypes_matmul/cuda_ctypes_matmul.py +0 -0
  38. {pytest_gpu_proof-0.5.0 → pytest_gpu_proof-0.5.2}/examples/cuda_ctypes_matmul/matmul_kernel.cu +0 -0
  39. {pytest_gpu_proof-0.5.0 → pytest_gpu_proof-0.5.2}/examples/cuda_ctypes_matmul/test_cuda_ctypes_matmul.py +0 -0
  40. {pytest_gpu_proof-0.5.0 → pytest_gpu_proof-0.5.2}/examples/cuda_nanobind_matmul/CMakeLists.txt +0 -0
  41. {pytest_gpu_proof-0.5.0 → pytest_gpu_proof-0.5.2}/examples/cuda_nanobind_matmul/README.md +0 -0
  42. {pytest_gpu_proof-0.5.0 → pytest_gpu_proof-0.5.2}/examples/cuda_nanobind_matmul/src/bindings.cpp +0 -0
  43. {pytest_gpu_proof-0.5.0 → pytest_gpu_proof-0.5.2}/examples/cuda_nanobind_matmul/src/matmul_cuda.h +0 -0
  44. {pytest_gpu_proof-0.5.0 → pytest_gpu_proof-0.5.2}/examples/cuda_nanobind_matmul/src/matmul_kernel.cu +0 -0
  45. {pytest_gpu_proof-0.5.0 → pytest_gpu_proof-0.5.2}/examples/cuda_nanobind_matmul/test_cuda_nanobind_matmul.py +0 -0
  46. {pytest_gpu_proof-0.5.0 → pytest_gpu_proof-0.5.2}/examples/cuda_pybind11_matmul/CMakeLists.txt +0 -0
  47. {pytest_gpu_proof-0.5.0 → pytest_gpu_proof-0.5.2}/examples/cuda_pybind11_matmul/README.md +0 -0
  48. {pytest_gpu_proof-0.5.0 → pytest_gpu_proof-0.5.2}/examples/cuda_pybind11_matmul/src/bindings.cpp +0 -0
  49. {pytest_gpu_proof-0.5.0 → pytest_gpu_proof-0.5.2}/examples/cuda_pybind11_matmul/src/matmul_cuda.h +0 -0
  50. {pytest_gpu_proof-0.5.0 → pytest_gpu_proof-0.5.2}/examples/cuda_pybind11_matmul/src/matmul_kernel.cu +0 -0
  51. {pytest_gpu_proof-0.5.0 → pytest_gpu_proof-0.5.2}/examples/cuda_pybind11_matmul/test_cuda_pybind11_matmul.py +0 -0
  52. {pytest_gpu_proof-0.5.0 → pytest_gpu_proof-0.5.2}/examples/github_gpu_runner/.github/workflows/gpu-test.yml +0 -0
  53. {pytest_gpu_proof-0.5.0 → pytest_gpu_proof-0.5.2}/examples/jax_ffi_cuda_matmul/CMakeLists.txt +0 -0
  54. {pytest_gpu_proof-0.5.0 → pytest_gpu_proof-0.5.2}/examples/jax_ffi_cuda_matmul/README.md +0 -0
  55. {pytest_gpu_proof-0.5.0 → pytest_gpu_proof-0.5.2}/examples/jax_ffi_cuda_matmul/jax_ffi_matmul.py +0 -0
  56. {pytest_gpu_proof-0.5.0 → pytest_gpu_proof-0.5.2}/examples/jax_ffi_cuda_matmul/src/matmul_ffi.cu +0 -0
  57. {pytest_gpu_proof-0.5.0 → pytest_gpu_proof-0.5.2}/examples/jax_ffi_cuda_matmul/test_jax_ffi_cuda_matmul.py +0 -0
  58. {pytest_gpu_proof-0.5.0 → pytest_gpu_proof-0.5.2}/examples/local_receipt_verify/.github/workflows/verify.yml +0 -0
  59. {pytest_gpu_proof-0.5.0 → pytest_gpu_proof-0.5.2}/examples/minimal_python_only/conftest.py +0 -0
  60. {pytest_gpu_proof-0.5.0 → pytest_gpu_proof-0.5.2}/examples/minimal_python_only/test_minimal.py +0 -0
  61. {pytest_gpu_proof-0.5.0 → pytest_gpu_proof-0.5.2}/examples/wrapped_cuda_ctypes/fake_cuda_lib.py +0 -0
  62. {pytest_gpu_proof-0.5.0 → pytest_gpu_proof-0.5.2}/examples/wrapped_cuda_ctypes/test_cuda_wrapper.py +0 -0
  63. {pytest_gpu_proof-0.5.0 → pytest_gpu_proof-0.5.2}/install.sh +0 -0
  64. {pytest_gpu_proof-0.5.0 → pytest_gpu_proof-0.5.2}/mkdocs.yml +0 -0
  65. {pytest_gpu_proof-0.5.0 → pytest_gpu_proof-0.5.2}/requirements-dev.txt +0 -0
  66. {pytest_gpu_proof-0.5.0 → pytest_gpu_proof-0.5.2}/requirements.txt +0 -0
  67. {pytest_gpu_proof-0.5.0 → pytest_gpu_proof-0.5.2}/src/pytest_gpu_proof/__main__.py +0 -0
  68. {pytest_gpu_proof-0.5.0 → pytest_gpu_proof-0.5.2}/src/pytest_gpu_proof/cli.py +0 -0
  69. {pytest_gpu_proof-0.5.0 → pytest_gpu_proof-0.5.2}/src/pytest_gpu_proof/compare.py +0 -0
  70. {pytest_gpu_proof-0.5.0 → pytest_gpu_proof-0.5.2}/src/pytest_gpu_proof/config.py +0 -0
  71. {pytest_gpu_proof-0.5.0 → pytest_gpu_proof-0.5.2}/src/pytest_gpu_proof/fingerprint.py +0 -0
  72. {pytest_gpu_proof-0.5.0 → pytest_gpu_proof-0.5.2}/src/pytest_gpu_proof/gitutils.py +0 -0
  73. {pytest_gpu_proof-0.5.0 → pytest_gpu_proof-0.5.2}/src/pytest_gpu_proof/merge.py +0 -0
  74. {pytest_gpu_proof-0.5.0 → pytest_gpu_proof-0.5.2}/src/pytest_gpu_proof/signers/__init__.py +0 -0
  75. {pytest_gpu_proof-0.5.0 → pytest_gpu_proof-0.5.2}/src/pytest_gpu_proof/signers/base.py +0 -0
  76. {pytest_gpu_proof-0.5.0 → pytest_gpu_proof-0.5.2}/src/pytest_gpu_proof/signers/ed25519.py +0 -0
  77. {pytest_gpu_proof-0.5.0 → pytest_gpu_proof-0.5.2}/tests/conftest.py +0 -0
  78. {pytest_gpu_proof-0.5.0 → pytest_gpu_proof-0.5.2}/tests/test_cli.py +0 -0
  79. {pytest_gpu_proof-0.5.0 → pytest_gpu_proof-0.5.2}/tests/test_compare.py +0 -0
  80. {pytest_gpu_proof-0.5.0 → pytest_gpu_proof-0.5.2}/tests/test_config.py +0 -0
  81. {pytest_gpu_proof-0.5.0 → pytest_gpu_proof-0.5.2}/tests/test_fingerprint.py +0 -0
  82. {pytest_gpu_proof-0.5.0 → pytest_gpu_proof-0.5.2}/tests/test_gitutils.py +0 -0
  83. {pytest_gpu_proof-0.5.0 → pytest_gpu_proof-0.5.2}/tests/test_merge.py +0 -0
  84. {pytest_gpu_proof-0.5.0 → pytest_gpu_proof-0.5.2}/tests/test_signing.py +0 -0
  85. {pytest_gpu_proof-0.5.0 → pytest_gpu_proof-0.5.2}/website/README.md +0 -0
  86. {pytest_gpu_proof-0.5.0 → pytest_gpu_proof-0.5.2}/website/build_site.py +0 -0
  87. {pytest_gpu_proof-0.5.0 → pytest_gpu_proof-0.5.2}/website/check_site.py +0 -0
  88. {pytest_gpu_proof-0.5.0 → pytest_gpu_proof-0.5.2}/website/favicon.svg +0 -0
  89. {pytest_gpu_proof-0.5.0 → pytest_gpu_proof-0.5.2}/website/index.html +0 -0
  90. {pytest_gpu_proof-0.5.0 → pytest_gpu_proof-0.5.2}/website/main.js +0 -0
  91. {pytest_gpu_proof-0.5.0 → pytest_gpu_proof-0.5.2}/website/overrides/main.html +0 -0
  92. {pytest_gpu_proof-0.5.0 → pytest_gpu_proof-0.5.2}/website/provenance.json +0 -0
  93. {pytest_gpu_proof-0.5.0 → pytest_gpu_proof-0.5.2}/website/requirements.txt +0 -0
  94. {pytest_gpu_proof-0.5.0 → pytest_gpu_proof-0.5.2}/website/style.css +0 -0
  95. {pytest_gpu_proof-0.5.0 → pytest_gpu_proof-0.5.2}/website/test_site.py +0 -0
  96. {pytest_gpu_proof-0.5.0 → pytest_gpu_proof-0.5.2}/website/workflow-mobile.svg +0 -0
  97. {pytest_gpu_proof-0.5.0 → pytest_gpu_proof-0.5.2}/website/workflow.svg +0 -0
@@ -7,11 +7,12 @@ on:
7
7
 
8
8
  jobs:
9
9
  test:
10
- runs-on: ubuntu-latest
10
+ # setup-python still provides the supported Python 3.9 build on 24.04.
11
+ runs-on: ubuntu-24.04
11
12
  strategy:
12
13
  fail-fast: false
13
14
  matrix:
14
- python-version: ["3.10", "3.11", "3.12", "3.13"]
15
+ python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
15
16
 
16
17
  steps:
17
18
  - uses: actions/checkout@v4
@@ -4,6 +4,23 @@ 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.2] — 2026-12-02
8
+
9
+ - Verifier policy can opt into `warn_on_age: true` for historical evidence.
10
+ Strict expiry remains the default. No receipt schema or signing change.
11
+
12
+ ## [0.5.1] — 2026-11-03
13
+
14
+ ### Added
15
+
16
+ - Python 3.9 support (the oldest Python on a JetPack 5 Jetson), with a CI test
17
+ lane. The code already avoided 3.10-only syntax; only the floor moved.
18
+ - `environment.gpu_info` and the `gpu_required` probe fall back to the CUDA
19
+ driver library (`libcuda` through `ctypes`) when neither `nvidia-smi` nor
20
+ PyTorch is available, as on Jetson boards before JetPack 7. The record names
21
+ its source (`nvidia-smi`, `torch`, or `libcuda`) and stays self-reported
22
+ metadata, not evidence of execution.
23
+
7
24
  ## [0.5.0] — 2026-10-28
8
25
 
9
26
  ### Added
@@ -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.10, 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.5.0
3
+ Version: 0.5.2
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,13 +16,14 @@ 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
19
20
  Classifier: Programming Language :: Python :: 3.10
20
21
  Classifier: Programming Language :: Python :: 3.11
21
22
  Classifier: Programming Language :: Python :: 3.12
22
23
  Classifier: Programming Language :: Python :: 3.13
23
24
  Classifier: Topic :: Security :: Cryptography
24
25
  Classifier: Topic :: Software Development :: Testing
25
- Requires-Python: >=3.10
26
+ Requires-Python: >=3.9
26
27
  Requires-Dist: cryptography>=41.0
27
28
  Requires-Dist: pytest>=7.0
28
29
  Requires-Dist: tomli>=2.0; python_version < '3.11'
@@ -156,7 +157,7 @@ a map that shard bin-packers can calibrate from.
156
157
  |---|---|
157
158
  | `@pytest.mark.gpu_proof` | Include the test in the receipt |
158
159
  | `@pytest.mark.gpu_equivalence` | Alias for `gpu_proof` |
159
- | `@pytest.mark.gpu_required` | Skip when neither `nvidia-smi` nor PyTorch reports a GPU |
160
+ | `@pytest.mark.gpu_required` | Skip when none of `nvidia-smi`, PyTorch, or the CUDA driver library (`libcuda` through `ctypes`) reports a GPU |
160
161
 
161
162
  Skipped tests are recorded. Verification rejects them by default. Prefer an
162
163
  exact `--expected-skips` baseline over the broad `--allow-skipped` escape
@@ -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 neither `nvidia-smi` nor PyTorch reports a GPU |
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
@@ -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.
@@ -53,6 +53,7 @@ schema 3. Repositories that have finished migrating should pin
53
53
  | `allowed_key_fingerprints` | SSH SHA-256 fingerprints accepted in restricted mode |
54
54
  | `min_schema` | Minimum acceptable receipt schema version (1, 2, or 3) |
55
55
  | `max_age_days` | Maximum age of the merged/session receipt |
56
+ | `warn_on_age` | Boolean, default false. Report an exceeded session or carried-shard age limit on stderr instead of failing. Future timestamps and all other verification errors remain fatal. |
56
57
  | `require_mode` | Required receipt mode: `local` or `ci-gpu` (a `ci-gpu` receipt additionally requires `allowed_key_fingerprints` and must be signed by a listed key) |
57
58
  | `allow_dirty` | Permit dirty recording or verification trees |
58
59
  | `required_fingerprint_paths` | Exact tracked path list |
@@ -36,7 +36,7 @@ Many GPU projects otherwise rely on an unaudited statement that someone ran
36
36
  tests locally. The receipt makes that workflow explicit and machine-checkable:
37
37
 
38
38
  - code drift invalidates the manifest;
39
- - stale receipts fail freshness policy;
39
+ - stale receipts fail freshness policy by default; opting into advisory age accepts historical evidence, not evidence of current toolchain compatibility;
40
40
  - incomplete collections and setup/teardown failures are visible;
41
41
  - signer identity and key fingerprint are signed;
42
42
  - contributor receipts can be reviewed in open mode;
@@ -4,10 +4,10 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "pytest-gpu-proof"
7
- version = "0.5.0"
7
+ version = "0.5.2"
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"
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,7 @@ 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",
20
21
  "Programming Language :: Python :: 3.10",
21
22
  "Programming Language :: Python :: 3.11",
22
23
  "Programming Language :: Python :: 3.12",
@@ -0,0 +1 @@
1
+ __version__ = "0.5.2"
@@ -30,10 +30,12 @@ def _has_gpu() -> bool:
30
30
  pass
31
31
  try:
32
32
  import torch
33
- return torch.cuda.is_available()
33
+ if torch.cuda.is_available():
34
+ return True
34
35
  except ImportError:
35
36
  pass
36
- return False
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
 
@@ -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(",")]
@@ -39,6 +39,7 @@ _POLICY_KEYS = {
39
39
  "required_shard_fingerprints",
40
40
  "required_test_manifest",
41
41
  "signer_mode",
42
+ "warn_on_age",
42
43
  }
43
44
 
44
45
 
@@ -87,7 +88,7 @@ def _load_policy(policy_path: Optional[str]) -> dict:
87
88
  "required_fingerprint_paths",
88
89
  ):
89
90
  string_list(name)
90
- for name in ("allow_carried", "allow_dirty"):
91
+ for name in ("allow_carried", "allow_dirty", "warn_on_age"):
91
92
  if name in policy and type(policy[name]) is not bool:
92
93
  raise VerificationError(f"policy field {name!r} must be a boolean")
93
94
  for name in ("carried_max_age_days", "max_age_days"):
@@ -502,7 +503,7 @@ def _verify(
502
503
  if age < datetime.timedelta(minutes=-5):
503
504
  raise VerificationError("receipt timestamp is in the future")
504
505
  if age > datetime.timedelta(days=max_days):
505
- raise VerificationError(f"receipt is older than the {max_days}-day policy")
506
+ _over_age(policy, f"receipt is older than the {max_days}-day policy")
506
507
  # A session cannot have started before the commit it attests to existed
507
508
  # (5 min of clock skew allowed). Cheap replay/forgery guard without a nonce.
508
509
  committed = get_commit_time(stored_sha, root)
@@ -517,6 +518,12 @@ def _verify(
517
518
  print("[gpu-proof] Receipt verified successfully.")
518
519
 
519
520
 
521
+ def _over_age(policy: dict, message: str) -> None:
522
+ if not policy.get("warn_on_age", False):
523
+ raise VerificationError(message)
524
+ print(f"[gpu-proof] WARNING: {message}", file=sys.stderr)
525
+
526
+
520
527
  def _verify_shards(receipt: dict, root: str, policy: dict, max_days: int = 30) -> None:
521
528
  shards = receipt.get("shards")
522
529
  if not isinstance(shards, list) or not shards:
@@ -583,8 +590,10 @@ def _verify_shards(receipt: dict, root: str, policy: dict, max_days: int = 30) -
583
590
  limit = policy.get("carried_max_age_days", min(30, max_days))
584
591
  if type(limit) is not int or limit < 0:
585
592
  raise VerificationError("carried_max_age_days must be a non-negative integer")
586
- if age < datetime.timedelta(minutes=-5) or age > datetime.timedelta(days=limit):
587
- raise VerificationError(f"carried shard {name!r} is outside its age policy")
593
+ if age < datetime.timedelta(minutes=-5):
594
+ raise VerificationError(f"carried shard {name!r} timestamp is in the future")
595
+ if age > datetime.timedelta(days=limit):
596
+ _over_age(policy, f"carried shard {name!r} is outside its age policy ({limit} days)")
588
597
  if claimed != test_ids:
589
598
  raise VerificationError("shard membership does not exactly partition tests[]")
590
599
  if required and set(required) != names:
@@ -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,6 +341,87 @@ 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)
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)
341
425
  assert receipt_mod._gpu_info() is None
342
426
 
343
427
 
@@ -248,7 +248,7 @@ def test_carry_refuses_non_ancestor(tmp_path, tmp_git_repo, signer_with_key):
248
248
  "old.json", repo_root=str(tmp_git_repo))
249
249
 
250
250
 
251
- def test_verify_rejects_stale_carried_shard(tmp_path, tmp_git_repo, signer_with_key):
251
+ def test_verify_rejects_stale_carried_shard(tmp_path, tmp_git_repo, signer_with_key, capsys):
252
252
  signer, public_key, key_path = signer_with_key
253
253
  old, fresh = _carry_setup(tmp_path, tmp_git_repo, signer, old_days_ago=40.0)
254
254
  out = tmp_path / "merged.json"
@@ -261,6 +261,9 @@ def test_verify_rejects_stale_carried_shard(tmp_path, tmp_git_repo, signer_with_
261
261
  carried_max_age_days=30),
262
262
  str(tmp_git_repo), "testuser", None)
263
263
  # a permissive age window accepts the same receipt
264
+ _verify(str(out), _policy(tmp_path, allow_carried=True, warn_on_age=True),
265
+ str(tmp_git_repo), "testuser", None)
266
+ assert "WARNING: carried shard" in capsys.readouterr().err
264
267
  _verify(str(out), _policy(tmp_path, allow_carried=True,
265
268
  carried_max_age_days=60),
266
269
  str(tmp_git_repo), "testuser", None)
@@ -467,6 +470,9 @@ def test_direct_shard_validation_rejects_bad_carried_limit(
467
470
  )
468
471
  receipt = json.loads(path.read_text())
469
472
  receipt["shards"][0]["carried"] = {"original_ended_at": _utcstamp()}
473
+ receipt["shards"][0]["carried"]["original_ended_at"] = _utcstamp(days_ago=-1)
474
+ with pytest.raises(VerificationError, match="in the future"):
475
+ _verify_shards(receipt, str(tmp_git_repo), {"allow_carried": True, "warn_on_age": True})
470
476
  with pytest.raises(VerificationError, match="non-negative integer"):
471
477
  _verify_shards(
472
478
  receipt,
@@ -142,7 +142,7 @@ def test_verify_fails_on_modified_receipt(good_receipt, tmp_git_repo):
142
142
  _verify(str(path), None, str(tmp_git_repo), "testuser", None)
143
143
 
144
144
 
145
- def test_verify_fails_on_stale_receipt(tmp_path, tmp_git_repo, signer_with_key):
145
+ def test_verify_fails_on_stale_receipt(tmp_path, tmp_git_repo, signer_with_key, capsys):
146
146
  signer, public_key = signer_with_key
147
147
  # Genuinely-signed receipt whose ended_at is far in the past: every check
148
148
  # up to freshness must pass, and freshness must be the one that fails.
@@ -152,6 +152,12 @@ def test_verify_fails_on_stale_receipt(tmp_path, tmp_git_repo, signer_with_key):
152
152
  with _mock_github_keys(public_key):
153
153
  with pytest.raises(VerificationError, match=r"older than the 30-day policy"):
154
154
  _verify(str(path), None, str(tmp_git_repo), "testuser", 30)
155
+ policy = _policy(tmp_path, {"warn_on_age": True})
156
+ with pytest.raises(VerificationError, match="before its commit existed"):
157
+ _verify(str(path), policy, str(tmp_git_repo), "testuser", 30)
158
+ with patch("pytest_gpu_proof.verify.get_commit_time", return_value=1500000000):
159
+ _verify(str(path), policy, str(tmp_git_repo), "testuser", 30)
160
+ assert "WARNING: receipt is older" in capsys.readouterr().err
155
161
 
156
162
 
157
163
  def test_verify_max_age_zero_is_respected(tmp_path, tmp_git_repo, signer_with_key):
@@ -428,6 +434,7 @@ def test_policy_validation_errors(tmp_path, content, message):
428
434
  ({"allowed_signers": [""]}, "list of strings"),
429
435
  ({"allow_dirty": "yes"}, "boolean"),
430
436
  ({"allow_carried": 1}, "boolean"),
437
+ ({"warn_on_age": "true"}, "boolean"),
431
438
  ({"max_age_days": True}, "non-negative integer"),
432
439
  ({"carried_max_age_days": -1}, "non-negative integer"),
433
440
  ({"require_mode": "remote"}, "local.*ci-gpu"),
@@ -1 +0,0 @@
1
- __version__ = "0.5.0"