Python overview

The survivalgpu Python package performs survival analysis on GPU-accelerated hardware, with PyTorch. Currently, two models are implemented, with an API loosely based on scikit-learn: build the estimator, call .fit(), then read the results off the fitted object’s attributes (all of which end with an underscore).

  • CoxPHSurvivalAnalysis — Cox Proportional Hazards, on (start, stop] intervals with fixed or time-varying covariates, with the Efron or Breslow handling of ties. Only requires PyTorch, and works on Linux, macOS and Windows.

  • WCESurvivalAnalysis — Weighted Cumulative Exposure (WCE), which models the cumulative effect of a time-varying exposure with B-splines. It also relies on KeOps (the pykeops package), which is not available natively on Windows: use it through WSL2 instead (see Installation).

Both support bootstrap resampling, processed in parallel batches on the device: this is where a GPU pays off most. For WCE models, the number of knots of the splines can be selected by AIC or BIC among several candidates, again in every bootstrap replicate. Both models also run on CPU if no CUDA-capable GPU is available (see use_cuda()).

The package also provides simulation tools, such as simulate_dataset(), to generate datasets with known effects for constant, time-dependent and WCE covariates.

This is the same implementation that the survivalGPU R package calls through reticulate, so both interfaces give the same results. coxphGPU_bootstrap Where to go next: