Skip to content

Multi-vendor GPU (PR4): cuperiod doctor + PyTorch install/backend docs - #12

Merged
tjayasinghe merged 3 commits into
dev/multi-vendor-gpufrom
feat/torch-install-ux
Jun 30, 2026
Merged

Multi-vendor GPU (PR4): cuperiod doctor + PyTorch install/backend docs#12
tjayasinghe merged 3 commits into
dev/multi-vendor-gpufrom
feat/torch-install-ux

Conversation

@tjayasinghe

Copy link
Copy Markdown
Owner

tjayasinghe and others added 3 commits June 30, 2026 12:40
PR4 of the multi-vendor GPU effort — the install UX for the torch backend.

- cli: new `cuperiod doctor` command — reports installed backends, the NVIDIA
  CUDA fast paths, the portable torch backend and each device it sees
  (CUDA/ROCm/MPS/XPU/CPU) with the precision each uses, and what `backend="auto"`
  resolves to per method. It sets KMP_DUPLICATE_LIB_OK for its own read-only
  device probe only (it does no numerics), so it can't OMP-abort on Windows; the
  library still never sets it for compute paths.
- docs/installation: `[torch]` extra, per-accelerator PyTorch wheel guidance
  (the plain wheel is CPU-only), the Apple-MPS float32 note, and a Windows
  OpenMP-clash warning with the KMP_DUPLICATE_LIB_OK workaround.
- docs/guide/backends: torch in the selector table; a "portable PyTorch backend"
  section covering devices, the device/precision settings, and the
  fast-on-NVIDIA / portable-everywhere split.
- docs/guide/cli: document `doctor`.

Verified: `cuperiod doctor` runs clean on a CPU-only Windows box without any
external env (torch:cpu -> float64; auto -> finufft/numba/numpy). Docs build with
`-W`. 161 passed, 8 skipped; ruff + mypy clean.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
The PR5 local adversarial review surfaced three float32-only bugs in the
portable torch backend, all masked because every torch test ran float64-on-CPU:

- BLS cast absolute BJD time to float32 *before* subtracting t_min, destroying
  sub-0.25-day timing on real light curves (silent wrong periodogram; this is
  the default path on Apple MPS). Subtract the origin in float64 before the
  device cast and restore the absolute transit_time on the host (mirrors
  gls._prep).
- MHAOV multiband dropped `precision`, silently ignoring it (and, on MPS,
  downcasting to float32 instead of raising). Forward precision to
  aov_multiband_power.
- MHAOV's fixed 1e-10 diagonal ridge underflowed the ~N Gram diagonal in
  float32, so linalg.solve raised on a singular matrix at degenerate
  frequencies. Scale the ridge by eps(dtype)*n_points.

Add float32 regression tests (three proven to fail pre-fix) and the
requires_torch_gpu marker. Document the remaining hardware-gated limitations
(XPU fp64 probe, torch-GPU VRAM auto-sizing, GPU argmax tie-breaks of extras)
in the changelog. NVIDIA fast paths verified unchanged; 165 passed, ruff+mypy
clean.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
The portable String-Length body sorted folded phases with whichever argsort the
backend namespace provided: the numpy path used raw numpy.argsort (quicksort,
unstable) while the torch path used the array-API argsort (stable). On
exactly-tied phases the two ordered points differently, so the string length
diverged — and because quicksort's tie order is platform-dependent, the
numpy-vs-torch parity test passed locally but failed in CI across OS/Python.

Route the numpy and cupy paths through the array-API namespace too, so every
backend uses the standard stable sort and ties keep a backend- and
platform-independent order. Add a regression test that forces heavy phase ties
(deterministically failing pre-fix). Surfaced by the PR5 review (the argsort
tie divergence) and confirmed by CI.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@tjayasinghe
tjayasinghe changed the base branch from feat/torch-bonus-methods to dev/multi-vendor-gpu June 30, 2026 21:56
@tjayasinghe
tjayasinghe merged commit 2979b66 into dev/multi-vendor-gpu Jun 30, 2026
6 checks passed
@tjayasinghe
tjayasinghe deleted the feat/torch-install-ux branch August 14, 2026 23:37
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