GTLS: GPU Transit Least Squares
GTLS is a CUDA implementation of the Transit Least Squares (TLS) algorithm for detecting periodic exoplanet transits in light curves. It keeps the TLS interface and transit model, and evaluates all trial periods, durations and epochs in parallel on an NVIDIA GPU, which makes it several times faster than CPU TLS.
Features
- Drop-in replacement for the
transitleastsquaressearch API - Limb-darkened transit templates (default, grazing and box-shaped)
- Batches trial periods automatically to fit the free GPU memory
- Refines the strongest peaks and their period aliases (P/2, 2P, 2P/3, 3P/2) with a finer epoch search, and fits the best period at every cadence
- Supports multi-GPU machines: pick a device with
GPUDeviceIDor split one search across several withGPUDeviceIDs
Requirements
- An NVIDIA GPU with CUDA
- Python >= 3.8
- CuPy matching your CUDA version
Installation
CuPy wheels depend on the local CUDA version, so CuPy is not a hard dependency. Install CuPy following the official guide, then install GTLS:
pip install gputls
Or let pip pick a CuPy build for you:
pip install "gputls[cuda13]" # CUDA 13.x, installs cupy-cuda13x[ctk]
pip install "gputls[cuda12]" # CUDA 12.x, installs cupy-cuda12x[ctk]
pip install "gputls[cuda11]" # CUDA 11.x, installs cupy-cuda11x (needs a local CUDA Toolkit)
GTLS compiles its CUDA kernels at runtime, so CuPy must be able to find the CUDA
headers, otherwise the search fails with Failed to find CUDA headers:
- CUDA 12 / 13: the
cuda12/cuda13extras install the headers from pip through CuPy's[ctk]extra. If you install CuPy yourself, usepip install "cupy-cuda12x[ctk]"(orcupy-cuda13x[ctk]), or pointCUDA_PATHto a local CUDA Toolkit. - CUDA 11:
cupy-cuda11xhas no[ctk]extra (and stops at CuPy 13), so install the CUDA Toolkit and setCUDA_PATHif it is not in the default location (e.g.export CUDA_PATH=/usr/local/cuda-11.8).
To install from source:
git clone https://github.com/Farthing-0/GTLS.git
cd GTLS
pip install .
Quick start
from gputls import gtls
# time in days, flux normalized to 1, optional flux uncertainties dy
model = gtls(time, flux, dy)
result = model.power()
print(result.period, result.T0, result.duration, result.depth, result.SDE)
power() accepts the same keyword arguments as TLS. Commonly used ones:
| Argument | Default | Description |
|---|---|---|
period_min, period_max |
0, inf |
Limits of the automatic period grid (days) |
periods |
[] |
Custom array of trial periods; overrides the automatic grid |
R_star, M_star |
1.0, 1.0 |
Stellar radius and mass (solar units) used for the period grid |
R_star_min, R_star_max |
0.13, 3.5 |
Stellar radius limits (solar units) of the plausible transit durations |
M_star_min, M_star_max |
0.1, 1.0 |
Stellar mass limits (solar units) of the plausible transit durations. Paired with the radius limits as in TLS 2: (R_star_min, high mass) for the shortest and (R_star_max, low mass) for the longest duration |
oversampling_factor |
3 |
Period grid oversampling |
duration_grid_step |
1.1 |
Multiplicative step of the duration grid |
transit_depth_min |
1e-5 |
Minimum depth of a trial transit |
transit_template |
"default" |
"default", "grazing" or "box" |
T0_fit_margin |
0.125 |
Epoch step of the coarse search as a fraction of the duration (0 to 0.125; 0 tests every cadence) |
T0_refine_margin |
0.01 |
Epoch step when the strongest peaks are re-searched, as a fraction of the duration (0 to 0.125; 0 tests every cadence). 0.01 is the T0 resolution of TLS |
GPUDeviceID |
0 |
CUDA device to run on |
GPUDeviceIDs |
None |
List of CUDA devices to split the search across (e.g. [0, 1]); overrides GPUDeviceID. Results are identical to a single-GPU run |
bar_location |
0 |
Position of the progress bar, useful when running several searches in parallel |
fast |
False |
Return only (periods, power), skipping the refinement and transit statistics |
Results
power() returns a gtlsResult object with the following attributes:
| Attribute | Description |
|---|---|
period |
Best period (days) |
T0 |
Mid-transit time of the first transit (days) |
duration |
Transit duration (days) |
depth |
Fractional transit depth (1 - in-transit flux). Note: TLS reports the in-transit flux level instead |
SDE |
Signal Detection Efficiency of the best period |
snr, snrPink |
Signal-to-noise ratio with white and pink (correlated) noise |
snrFit, snrFitPink |
Signal-to-noise ratio from the fitted transit depth |
transitTimes |
Mid-transit times within the light curve |
periods, power |
Periodogram: trial periods and SDE power |
chi2 |
Minimum chi² of each period after refinement |
raw_chi2, raw_power |
Minimum chi² and power of the coarse search, before refinement |
possiblePeriods, possiblePeriodsIndices |
Periods that were refined, and their indices in periods |
rawDuration, rawDurations, durationPoints |
Best duration as a fraction of the period, the duration grid, and the best duration in data points |
Examples
The examples/ folder contains Jupyter notebooks comparing GTLS with TLS:
tess_tutorial.ipynb: a TESS targetkepler_tutorial.ipynb: a Kepler target downloaded withlightkurve
The notebooks also need matplotlib, astropy, transitleastsquares, lightkurve and wotan.
Testing
The test suite runs end-to-end searches on the GPU: injection-recovery on a synthetic
light curve, the fast mode, a real Kepler light curve stored in
tests/data/, release of GPU memory after a search, and (on machines with
at least two GPUs) bitwise agreement between single- and multi-GPU searches. It needs astropy in addition to the runtime dependencies.
One-click build, install and test (inside an environment where CuPy is installed):
./run_tests.sh # GPU 0
./run_tests.sh 1 # GPU 1
PYTHON=/path/to/python ./run_tests.sh
The script reinstalls only gputls itself (--no-deps) and then runs
tests/test_gtls.py. The tests can also be run with pytest tests; select the GPU with
the GTLS_GPU_DEVICE environment variable.
Comparison with TLS 1.x and TLS 2.x
tests/tls_compare/ benchmarks GTLS against the last TLS 1.x
release (1.32) and TLS 2.x (2.0.4). All engines search the same mock Kepler and
TESS-SPOC pipeline products, which are read and detrended with lightkurve. The
benchmark reports runtimes, recovery of the injected transits and cross-engine agreement.
Both TLS versions are installed automatically into isolated directories. The benchmark
needs lightkurve (pip install "gputls[test]"):
python tests/compare_tls.py # standard suite: report.md + report.json
python tests/compare_tls.py --suite full --plot
python tests/compare_tls.py --suite long --timeout 3600 --repeat-limit 60 # whole Kepler mission, short cadence
pytest tests/test_tls_compare.py # injection recovery and agreement checks
Project structure
GTLS/
├── src/gputls/ # Python package
│ ├── main.py # gtls class (public API)
│ ├── core.py # GPU search driver
│ ├── kernels.cu # CUDA kernels, compiled at runtime by CuPy
│ ├── grid.py # period and duration grids
│ ├── transit.py # transit templates (batman)
│ ├── stats.py # periodogram and SNR statistics
│ ├── validate.py # input and argument validation
│ ├── constants.py # default parameters
│ └── ...
├── tests/ # GPU test suite, TLS comparison framework (tls_compare/) and test data
├── examples/ # Jupyter notebooks
├── docs/images/ # Figures used in the documentation
├── run_tests.sh # One-click build and test
└── pyproject.toml
Acknowledgements and license
GTLS is adapted from TLS by Michael Hippke and René Heller. If you use GTLS, please also cite the TLS paper: Hippke, M. & Heller, R. (2019), Optimized transit detection algorithm to search for periodic transits of small planets, A&A 623, A39.
Both TLS and GTLS are released under the MIT License.
Metadata
Release files for gputls 2.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| gputls-2.1.1.tar.gz | 40.1 kB | Without provenance | Details for gputls-2.1.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| gputls-2.1.1-py3-none-any.whl | Python 3 | none | any | Details for gputls-2.1.1-py3-none-any.whl |
Total release size: 74.9 kB
Release files / gputls-2.1.1.tar.gz
| Download URL | gputls-2.1.1.tar.gz |
|---|---|
| Size | 40.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
753164b1b19196a8a618fd97ee2a38485146b7edefaf8847686f33545ac9e1fd
|
|
BLAKE2b-256 checksum How to use checksums |
f079fc946ade697d4dd54a36c4c2ffe2b06cfd48fc8ad7330c109859fc93f414
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.3
|
Release files / gputls-2.1.1-py3-none-any.whl
| Download URL | gputls-2.1.1-py3-none-any.whl |
|---|---|
| Size | 34.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
595e0122293c8343774f86642e9e1edefca584fd91e0d6f4694a4717492b0d95
|
|
BLAKE2b-256 checksum How to use checksums |
0b83db33d74598c004af376b992e6449db25c41ce8fb7ad877a861545c8c03bc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.3
|
Security for gputls 2.1.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.