cuPeriod
Optimized, GPU-accelerated periodograms for astronomy.
cuPeriod computes period-search statistics for variable stars and transiting systems with fast CPU backends and GPU-accelerated paths that scale from a single light curve to millions. The NVIDIA CUDA fast paths are joined by a portable PyTorch backend that also runs on AMD, Intel, and Apple GPUs (and a CPU-only path), so the accelerated code is no longer NVIDIA-only. One API, one CLI, and an optional desktop GUI cover every method, with frictionless column handling, multi-band support, raw-spectrum output, and an N-best-periods utility.
📖 Documentation: https://cuperiod.readthedocs.io — a 5-minute quickstart, a full user guide, and the complete API reference, including installation, backends, the GUI, and benchmarks pages.
Every implementation is validated against the standard reference (astropy
LombScargle / BoxLeastSquares) to floating-point round-off.
Why cuPeriod
- Validated, not just fast. GLS and BLS match astropy to floating-point round-off, and every other method is checked against an independent reference implementation (PyAstronomy, or a direct implementation of the published algorithm) on identical grids. CPU, CUDA, and the portable PyTorch backend agree to round-off and pick the identical best period on 126 real ASAS-SN light curves across six variability classes plus 12 confirmed Kepler transits — 88–96% harmonic-aware period recovery on this deliberately heterogeneous sample (a synthetic injection–recovery sweep further characterizes sensitivity vs. signal-to-noise) — see the full benchmark report and the benchmarks docs page.
- A fast CPU tier, no GPU required. The
[fast]extra's multicorenumbakernels makebackend="cpu"18x faster than astropy'sBoxLeastSquaresand 2106x faster than PyAstronomy's PDM on a representative light curve, while recovering the same periods. - GPU acceleration beyond NVIDIA. The portable PyTorch backend runs every method on AMD (ROCm), Intel (XPU), and Apple (MPS) GPUs, in addition to the NVIDIA CUDA fast paths — so the accelerated code isn't locked to one vendor.
- Built for catalogue scale.
batch_periodogramssustains up to 587 light curves/s (>2 million/hour) on a single GPU, with a resumable batch sink for runs spanning millions of curves. - Seven methods, one API. GLS, BLS, PDM, CE, String-Length, MHAOV, and TLS share one entry point, one CLI, and an optional desktop GUI, with frictionless column handling and multi-band support.
Status
Implemented now, each with optimized CPU and GPU backends:
| Method | What it's for | GPU | Multi-band |
|---|---|---|---|
| GLS | general variability (Lomb-Scargle) | yes | yes |
| BLS | eclipses / box-like transits | yes | yes |
| MHAOV | sharply non-sinusoidal signals (multiharmonic AOV) | yes | yes |
| TLS | limb-darkened transit matched filter | yes | — |
| PDM | non-sinusoidal folds (Stellingwerf) | yes | — |
| CE | sparse survey data (conditional entropy) | yes | — |
| String-Length | eclipsing / eccentric shapes | yes | — |
All seven methods have CPU and GPU backends, plus the full single/batch/CLI machinery.
Install
pip install cuperiod # CPU (numpy, scipy, astropy, finufft)
pip install "cuperiod[gpu]" # + CUDA 12 GPU backends (cupy, cufinufft)
pip install "cuperiod[torch]" # + portable PyTorch backend (AMD/Intel/Apple GPUs + CPU)
pip install "cuperiod[fast]" # + numba multicore CPU kernels (all 7 methods, 20-300x)
pip install "cuperiod[gui]" # + interactive desktop GUI (cuperiod-gui)
pip install "cuperiod[pandas]" # + pandas DataFrame ingestion
The [gpu] extra needs an NVIDIA GPU with the CUDA 12 runtime; it pulls in cupy-cuda12x,
cufinufft, and the CUDA runtime wheels. The [torch] extra adds a portable PyTorch
backend that reaches AMD (ROCm), Intel (XPU), and Apple-Silicon (MPS) GPUs — and a CPU path
everywhere — so the accelerated code runs beyond NVIDIA (install the wheel matching your
accelerator from pytorch.org; the default is
CPU-only). The [fast] extra adds multicore numba CPU kernels that become the default
"cpu"/"auto" backend for every method — BLS, PDM, CE, String-Length, MHAOV, and
TLS — one to two orders of magnitude faster than the fallback CPU paths and matching them
to floating point.
Not sure what will run where? cuperiod doctor reports every installed backend, the torch
devices it sees and the precision each uses, and what backend="auto" resolves to.
Quick start (Python)
The recommended import alias is cup:
import cuperiod as cup
# A single light curve, straight from arrays:
pg = cup.periodogram((time, mag, mag_err), "GLS")
print(pg.best_period())
for peak in pg.best_periods(10):
print(peak.period, peak.power, peak.extra.get("fap"))
# From a table with arbitrary column names (auto-detected, or pinned):
pg = cup.periodogram(df, "BLS",
columns=cup.ColumnMap(time="HJD", value="flux", error="flux_err"))
# Several methods at once:
res = cup.periodogram(lc, ["GLS", "BLS"]) # -> MultiResult
res["BLS"].best_periods(5, alias_diverse=True)
# Raw spectrum for your own analysis:
frequency, power = pg.frequency, pg.power
Method names are case-insensitive ("gls" == "GLS").
📓 New here? The
examples/cuperiod_tour.ipynbnotebook works through real light curves — a Cepheid, an RR Lyrae, an eclipsing binary, a Mira, and a Kepler exoplanet — showing each periodogram and phase-folded result.
Multi-band (one star, several filters)
GLS, BLS, and MHAOV jointly model two or more bands of the same star:
mb = cup.MultiBandLightCurve.from_light_curves({"g": lc_g, "r": lc_r})
pg = cup.periodogram(mb, "GLS") # VanderPlas & Ivezić shared-phase model
Backends
backend="auto" (default) uses the GPU when available and falls back to CPU. Force a path
with backend="cpu", backend="gpu", or a concrete name ("finufft", "cufinufft",
"numpy", "astropy", "cupy"). The portable PyTorch backend runs any method on any torch
device: backend="torch" (best device present) or "torch:cpu" / "torch:cuda" /
"torch:mps" / "torch:xpu". On Apple MPS (no float64) it uses float32; precision="auto"
keeps float64 everywhere else.
Batch processing (millions of light curves)
# CPU pool across cores, written to Parquet:
cup.batch_periodograms("lightcurves/*.parquet", ["GLS", "BLS"],
device="cpu", workers=8, sink="results/")
# GPU, with an auto-sized worker count:
cup.batch_periodograms(df_groups, "GLS", device="gpu",
workers=cup.suggest_gpu_workers("GLS"), sink="out.parquet")
Inputs can be an iterable of light curves, a glob, a directory, or a (DataFrame, group_column) pair. A directory sink is resumable — re-running skips chunks already
written. suggest_gpu_workers sizes the GPU pool from probed device memory.
Command line
cuperiod run star.csv --method GLS,BLS --n-best 10
cuperiod batch "lcs/*.csv" --method GLS --device gpu --out results/
cuperiod methods # list methods and backends
cuperiod gpu-info # device + suggested worker counts
cuperiod doctor # backends, torch devices, precision, auto-resolution
cuperiod grid-info star.fits -m GLS
run accepts --time/--value/--error/--band overrides and --domain magnitude|flux, and
can write JSON (--out) and the raw spectrum (--save-periodogram).
Desktop GUI
An interactive periodogram explorer ships with the [gui] extra — run any method with all
of its options, explore the full-resolution spectrum, and watch the phased light curve
update live as you drag across peaks. Single curves or a whole folder in batch mode,
multi-band overlays, and a dark/light theme remembered across launches.
pip install "cuperiod[gui]" # add [gpu] or [torch] for accelerated backends
cuperiod-gui # or: python -m cuperiod.gui
It opens with bundled demo light curves (a Kepler transit, six ASAS-SN variables, a synthetic multi-band curve), so there's something to explore on first launch.
Light-curve inputs
Time may be JD/HJD/BJD/MJD; values may be magnitude or flux; errors are optional. Column
names are auto-detected (case-insensitive) and can be pinned with ColumnMap. Box/transit
methods (BLS, TLS) work in flux — magnitudes are converted automatically.
Citing cuPeriod
If you use cuPeriod in your research, please cite it — see CITATION.cff
for the machine-readable record (also picked up by GitHub's "Cite this repository").
@software{jayasinghe_cuperiod,
author = {Jayasinghe, Tharindu},
title = {cuPeriod},
version = {1.1.0},
date = {2026-07-08},
url = {https://github.com/tjayasinghe/cuPeriod}
}
License
GPL-3.0-or-later.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file cuperiod-1.1.0.tar.gz.
File metadata
- Download URL: cuperiod-1.1.0.tar.gz
- Upload date:
- Size: 183.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b104d9f1f78a39644f5cd18ddb4281ebd75fd2ca72b4190840fda2e8cf4551bf
|
|
| MD5 |
4c68fcd598e4cd33b14fd39164002d00
|
|
| BLAKE2b-256 |
60e1651dbb0e0461e112ecad8900e628917320aca3960692fa1e373e98a69767
|
Provenance
The following attestation bundles were made for cuperiod-1.1.0.tar.gz:
Publisher:
release.yml on tjayasinghe/cuPeriod
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
cuperiod-1.1.0.tar.gz -
Subject digest:
b104d9f1f78a39644f5cd18ddb4281ebd75fd2ca72b4190840fda2e8cf4551bf - Sigstore transparency entry: 2129901355
- Sigstore integration time:
-
Permalink:
tjayasinghe/cuPeriod@3ded27a57cd1afd3fe62043e4d5d22746b239b4d -
Branch / Tag:
refs/tags/v1.1.0 - Owner: https://github.com/tjayasinghe
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@3ded27a57cd1afd3fe62043e4d5d22746b239b4d -
Trigger Event:
push
-
Statement type:
File details
Details for the file cuperiod-1.1.0-py3-none-any.whl.
File metadata
- Download URL: cuperiod-1.1.0-py3-none-any.whl
- Upload date:
- Size: 185.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
93c0aa733d80f55744e2765120657b0fd3aeeb46db549d1d945d4265bd608567
|
|
| MD5 |
bfea320c34107f072c7d006cc50bc062
|
|
| BLAKE2b-256 |
b33dc65bece1784e2d9a2a6a05a655fa14c8ed066aaf8d8849b48767cd4bce0a
|
Provenance
The following attestation bundles were made for cuperiod-1.1.0-py3-none-any.whl:
Publisher:
release.yml on tjayasinghe/cuPeriod
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
cuperiod-1.1.0-py3-none-any.whl -
Subject digest:
93c0aa733d80f55744e2765120657b0fd3aeeb46db549d1d945d4265bd608567 - Sigstore transparency entry: 2129901382
- Sigstore integration time:
-
Permalink:
tjayasinghe/cuPeriod@3ded27a57cd1afd3fe62043e4d5d22746b239b4d -
Branch / Tag:
refs/tags/v1.1.0 - Owner: https://github.com/tjayasinghe
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@3ded27a57cd1afd3fe62043e4d5d22746b239b4d -
Trigger Event:
push
-
Statement type: