Skip to main content

GTLS: GPU Transit Least Squares

PyPI License: MIT

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.

GTLS periodogram and phase-folded transit

Features

Version 2.2.4 aligns the final candidate's epoch fit and duration conversion with TLS2 2.0.4. The reported transit times and noise statistics now use those windows. This adds one CPU epoch fit after the GPU search; periodograms and the default 0.01 epoch-search margins are unchanged. Native template/depth selection remains on the GPU, so this does not promise bitwise equality of every output with TLS2.

Version 2.2.3 corrects the out-of-transit noise masks used by snr and snrPink: their duration is now expressed in days, matching the time array. Earlier versions passed a fractional duration, which could bias the reported signal-to-noise ratios. Period searches, periodograms, and the default 0.01 epoch-search margins are unchanged by this correction.

  • Drop-in replacement for the transitleastsquares search 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 GPUDeviceID or split one search across several with GPUDeviceIDs

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 / cuda13 extras install the headers from pip through CuPy's [ctk] extra. If you install CuPy yourself, use pip install "cupy-cuda12x[ctk]" (or cupy-cuda13x[ctk]), or point CUDA_PATH to a local CUDA Toolkit.
  • CUDA 11: cupy-cuda11x has no [ctk] extra (and stops at CuPy 13), so install the CUDA Toolkit and set CUDA_PATH if 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.01 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:

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.2.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for gputls 2.2.4
File Size Uploaded Provenance Actions
gputls-2.2.4.tar.gz 77.8 kB Without provenance Details for gputls-2.2.4.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for gputls 2.2.4
File Interpreter ABI Platform Actions
gputls-2.2.4-py3-none-any.whl Python 3 none any Details for gputls-2.2.4-py3-none-any.whl

Total release size: 135.8 kB

Release files / gputls-2.2.4.tar.gz

Download URL gputls-2.2.4.tar.gz
Size 77.8 kB
Tags Source
SHA-256 checksum
How to use checksums
ddc3d7574bace60b0c635a677506a25fbf863b94c9ec151f73e0aa6716c971e8
BLAKE2b-256 checksum
How to use checksums
ffec3884885958187ddbe957247fc9a31f809c128eeeeb27e38ad49ffa0a0348
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.2.4-py3-none-any.whl

Download URL gputls-2.2.4-py3-none-any.whl
Size 58.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
830f5e299ad3199f961ac2bf8d70991a2a12d8143ca18db9d0da9cb5a9f77684
BLAKE2b-256 checksum
How to use checksums
59d2ee4757f1c0824632fac90c3f41296d2ef53d3fa80c290079310a5da866b3
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.2.4

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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page