Multi-vendor GPU (PR4): cuperiod doctor + PyTorch install/backend docs - #12
Merged
Merged
Conversation
tjayasinghe
commented
Jun 30, 2026
Owner
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
changed the base branch from
feat/torch-bonus-methods
to
dev/multi-vendor-gpu
June 30, 2026 21:56
This was referenced Jun 30, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.