Skip to content

Device and precision vocabulary (gpu:N, auto, single/double); release 2.4.0 - #6

Merged
jacotay7 merged 3 commits into
mainfrom
feat/device-precision-vocabulary
Oct 7, 2026
Merged

jacotay7 merged 3 commits into
mainfrom
feat/device-precision-vocabulary

Conversation

@jacotay7

@jacotay7 jacotay7 commented Oct 7, 2026 •

Copy link
Copy Markdown
Owner

Brings getframes in line with aocore CONVENTIONS section 8 and cuts 2.4.0.

Device (8.1)

  • Every device= (Camera, get_backend, CLI [camera] table) accepts "cpu", "gpu", "gpu:N" and "auto"; "numpy"/"cuda"/"cupy" aliases still work (case-insensitive).
  • "gpu:N" is validated against cupy.cuda.runtime.getDeviceCount() with a clear ValueError; unknown strings raise ValueError, non-strings TypeError.
  • "auto": GPU when CuPy imports and sees a device, else CPU.
  • A GPU camera is pinned to its card: fixed-pattern maps and the cuRAND RandomState streams are built inside that device's context, and every public generation method (including generator methods, per step) runs with the device current. with_config keeps the card.
  • New: Camera.device_id, ArrayBackend.device_id / .spec / .activate().

Precision (8.2)

  • precision="single"|"double" (aliases "float32"/"float64") on Camera, a new precision keyword on Scene.photon_rate_map/photoelectron_rate_map and on the noise functions with a float_dtype; conflicting dtype + precision raise. Public getframes.resolve_precision.
  • Camera.precision still reports "float32"/"float64" (backward compatible).
  • dataset.pairs(dtype=...) is a host storage type, not a working precision, so it is unchanged.

Fixed

  • dataset.pairs with a GPU camera failed on implicit CuPy→NumPy conversion; it now goes through to_numpy (as do the CLI writers).

aocore 0.1.3 conformance

  • tests/test_conformance.py switched from the dummy-OPD workaround to check_point_source_centring / check_point_source_flux, and adds check_edge_flux_loss for all five PSF models (worst edge ratios 0.500-0.504). The dev extra pins aocore>=0.1.3,<0.2; the runtime pin is unchanged.

Tests

  • tests/test_backend.py: parsing, invalid strings, out-of-range N (fake CuPy), RNG built on the selected device, auto fallback with CuPy hidden via sys.modules, precision aliases across Camera/Scene/noise.
  • tests/test_conformance.py: device and precision vocabulary, precision names matched against aocore.get_backend(...).real_dtype.
  • tests/test_gpu.py (-m gpu, run locally on a Quadro P620): gpu:0 maps/RNG/frames/series/binning on device 0, auto picks the GPU, out-of-range rejected.

No measurable overhead on the GPU hot path (80x80 CMOS: 310 us/frame vs 315 us/frame on main).

Release: version 2.4.0, CHANGELOG dated 2026-10-07.

🤖 Generated with Claude Code

jacotay7 and others added 3 commits October 6, 2026 19:07
Every device argument (Camera, get_backend, the CLI [camera] table) now
accepts "cpu", "gpu", "gpu:N" and "auto" (aocore CONVENTIONS 8.1), keeping
the "numpy"/"cuda"/"cupy" aliases. A GPU camera is pinned to its card: the
fixed-pattern maps and cuRAND streams are created there and every camera
method runs with that device current. "gpu:N" is validated against the
CuPy device count.

Working precision takes "single"/"double" with "float32"/"float64" as
aliases (8.2) on Camera, Scene.photon_rate_map/photoelectron_rate_map and
the noise functions that take a float_dtype; resolve_precision is public.

dataset.pairs and the CLI writers copy GPU frames to the host explicitly.
Tests cover parsing, out-of-range N, auto fallback with CuPy hidden, the
precision aliases, conformance with aocore's vocabulary, and gpu:0/auto on
a real GPU.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
tests/test_conformance.py now drives check_point_source_centring and
check_point_source_flux with render(shape) callables instead of the
dummy-OPD workaround, and runs check_edge_flux_loss for every PSF model.
The dev extra pins aocore>=0.1.3,<0.2; the runtime pin is unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@jacotay7
jacotay7 merged commit 7b01daf into main Oct 7, 2026
14 checks passed
@jacotay7
jacotay7 deleted the feat/device-precision-vocabulary branch October 7, 2026 05:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant