This release is a pre-release and may not be stable for production use.
survjax
Survival analysis in JAX
survjax is a lightweight, extensible JAX library for survival likelihoods,
predictions, and evaluation. Use it to build objectives for classical,
neural-network, and Bayesian survival models, or to run simulation studies
with JAX's automatic differentiation, compilation, and batching.
The library provides survival-data containers, distributions, and metrics. Fitting routines, neural-network architectures, and priors belong to external libraries such as Optimistix, Optax, Equinox, and NumPyro.
Current scope
survjax is an alpha pre-release. Its first built-in distributions are
Exponential and Weibull, and its first evaluation metric is Harrell's
concordance_index. More distribution families and metrics will follow.
Currently available:
- Survival data:
SurvivalDatarepresents mixtures of exact, right-, left-, and interval-censored observations, with left and/or right truncation. - Likelihoods:
model.log_likelihood(data)returns per-observation log likelihoods for exact and right-censored observations without truncation. Left/interval censoring and truncation are representable but their likelihoods are not yet implemented; unsupported rows return NaN. - Survival and hazard calculations: survival probabilities, log survival, log density, log CDF, hazard, log hazard, and cumulative hazard, with grid methods for evaluation across times.
- Proportional hazards:
ProportionalHazardswraps a baseline with a caller-computed log hazard ratio; see the PH guide for broadcasting, likelihoods and derivative limits. - Evaluation: Harrell's concordance for exact and right-censored data without truncation.
- Custom distributions: register a family with parameter declarations,
log_survival(t), andreference_time(); the base supplies derived methods, including an autodiff-based log density.
Restricted mean survival time, model.rmst(tau), is available for Exponential,
Weibull and their PH wrappers; see the RMST guide for cutoff
broadcasting, derivatives and numerical-failure limits. Unrestricted means,
medians and quantiles remain planned.
Installation
From a local checkout, install the core package with:
pip install .
Python 3.12 or later is required. The core depends only on JAX and NumPy; install optimization and inference libraries separately when needed.
Minimal example
Construct observations, evaluate a likelihood, and differentiate it with respect to a model parameter:
import jax
import jax.numpy as jnp
import survjax
data = survjax.SurvivalData(
time=jnp.array([1.0, 2.0, 1.5, 5.0]),
event=jnp.array([True, False, False, True]),
)
# True denotes an observed event; False denotes right censoring.
def loss(log_rate):
model = survjax.Exponential.from_log(log_rate=log_rate)
return -model.log_likelihood(data).sum()
value_and_grad = jax.jit(jax.value_and_grad(loss))
log_rate = jnp.log(0.2)
value, gradient = value_and_grad(log_rate)
# value ≈ 5.118876; gradient ≈ -0.1
model = survjax.Exponential.from_log(log_rate=log_rate)
survival = model.survival(jnp.array([0.0, 1.0, 5.0]))
# survival ≈ [1.0, 0.818731, 0.367879]
The scalar loss can be passed to an external optimizer. The example uses
fixed parameters; it does not fit a model.
For exact and right-censored observations, likelihoods also accept raw arrays:
model.log_likelihood(time=time, event=event). Concordance accepts either
survjax.concordance_index(scores, data) or keyword time and event arrays;
higher scores indicate higher risk.
Guiding principles
- Composable APIs: data and distributions work with JAX transformations and external inference tools.
- Numerical accuracy: stable log-space calculations, without probability floors, clipping, or added epsilons.
- Differentiable likelihoods: first and second parameter derivatives on valid, smooth interior cases within the documented derivative guarantees.
- Performance: support for
jax.jitandjax.vmap, with correctness checked in eager and transformed execution.
Documentation
The documentation sources
contain the user guide, API reference and examples. Build the executable site
locally with scripts/build_docs.sh. Read the Docs hosting is not set up yet;
https://survjax.readthedocs.io is the intended Community address, subject to
project-slug availability and a successful hosted build.
Development
survjax is under active development. Contributions and co-maintenance are welcome.
If you're interested in helping, please open an issue or reach out directly.
The GPU badge shows the latest manually started Modal GPU run on main for an
NVIDIA T4 with CUDA 12. Each run is attached to the selected commit in GitHub
Actions. Run GPU CI before tagging a release that claims support for this
configuration; CPU-only releases need only pass CPU CI.
Metadata
Release files for survjax 0.0.1a2
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 |
|---|---|---|---|---|
| survjax-0.0.1a2.tar.gz | 44.6 kB | With provenance | Details for survjax-0.0.1a2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| survjax-0.0.1a2-py3-none-any.whl | Python 3 | none | any | Details for survjax-0.0.1a2-py3-none-any.whl |
Total release size: 101.9 kB
Release files / survjax-0.0.1a2.tar.gz
| Download URL | survjax-0.0.1a2.tar.gz |
|---|---|
| Size | 44.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
3583c7a535721e50ce66174a720833abd3c9aae98fe339b4b49fd2c4965cdd00
|
|
BLAKE2b-256 checksum How to use checksums |
695a5db9a379ba8aaf40287a72e3fd19dcb6cb5af06fba5a51d1603c9e2e9b67
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 6, 2026.
Transparency logRelease files / survjax-0.0.1a2-py3-none-any.whl
| Download URL | survjax-0.0.1a2-py3-none-any.whl |
|---|---|
| Size | 57.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d6e6b8616b018b95d162fff18bee906a55147b5f0305f84d5cb35734ab68d870
|
|
BLAKE2b-256 checksum How to use checksums |
ddd44f83a3cfc52ccb9538d64c9492c4973e794790c6dcc9c4c3f9093a7b681d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 6, 2026.
Transparency logSecurity for survjax 0.0.1a2
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.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for survjax-0.0.1a2.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 6, 2026.
Transparency logA 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.