GPU-native Persistent Topological Laplacians in PyTorch
Project description
PETLS-PyTorch
A PyTorch-native implementation of persistent topological Laplacians, based on the public PETLS API, PETLS documentation, and the algorithms described in the PETLS paper.
The goal of this project is to make PETLS-style computations easier to use in Python and PyTorch workflows, especially when downstream code already works with torch tensors or CUDA devices. The original C++/pybind11 PETLS implementation remains the reference for correctness.
Quick Start
import petls_torch
# Alpha complex from point cloud
alpha = petls_torch.Alpha(points=[[0, 0], [1, 0], [0.5, 1]], max_dim=2)
eigs = alpha.spectra(0, 0.0, 1.0)
# Rips complex from distance matrix
rips = petls_torch.Rips(distances=[[0, 1, 1], [1, 0, 1], [1, 1, 0]], max_dim=2)
# Directed flag complex from .flag file
dflag = petls_torch.dFlag("graph.flag", max_dim=3)
# Sheaf Laplacian
sst = petls_torch.sheaf_simplex_tree(st, extra_data, restriction)
psl = petls_torch.PersistentSheafLaplacian(sst)
Relationship to PETLS
petls_torch is an independent PyTorch-native implementation of the PETLS
methods and public API behavior, with attribution to the original PETLS paper
and project. Correctness tests compare against the original implementation using
shared inputs and the default tolerances used in this repository.
This project is based on the public PETLS API, PETLS documentation, and the algorithms described in the PETLS paper. No source code from the original PETLS implementation is included in this repository.
API Coverage
| Original PETLS API | PyTorch API | Status |
|---|---|---|
Complex |
Complex |
Implemented |
Alpha |
Alpha |
Implemented |
Rips |
Rips |
Implemented |
dFlag |
dFlag |
Implemented |
sheaf_simplex_tree |
sheaf_simplex_tree |
Implemented |
PersistentSheafLaplacian |
PersistentSheafLaplacian |
Implemented |
Profile, timer |
Profile, Timer |
Implemented |
summaries, plot_summary |
summaries, plot_summary |
Implemented |
up_Algorithms enum |
up_Algorithms enum |
Implemented |
eigvalsh_wrapper, sparse_wrapper, matrix_is_diagonal |
Same | Implemented |
flipped optimization |
flipped + get_L_top_dim_flipped |
Implemented |
nonzero_spectra() |
nonzero_spectra() |
Implemented |
store_L(), store_spectra(), store_spectra_summary() |
Same | Implemented |
time_to_csv() |
time_to_csv() |
Implemented |
Benchmark Notes
The benchmark results below are included to give a sense of current runtime behavior on one local machine. They should be read as preliminary measurements, not as a comprehensive performance study.
The benchmark suite uses the same synthetic datasets, filtrations, and matrix
sizes for both packages. The shared benchmark runner is parameterized with
--package petls or --package petls_torch.
Hardware
- CPU: Intel i7-14700K
- GPU: NVIDIA RTX 4070 Ti 12GB
- PyTorch 2.x with CUDA 12.x
Quick Preset
Configuration: torus n=500 plus sphere n=300, max_dim=2, 8 filtrations
per dataset.
| Package | Device | Total Time | Mean Trial | Mean Build | Mean Eigs |
|---|---|---|---|---|---|
petls |
CPU | 8.29 s | 172.6 ms | 15.2 ms | 157.4 ms |
petls_torch |
CPU | 1.82 s | 37.9 ms | 4.8 ms | 33.1 ms |
petls_torch |
CUDA | 1.85 s | 38.5 ms | 4.7 ms | 33.8 ms |
On this workload, the PyTorch implementation is about 4.5x faster than the reference PETLS run on the same CPU. The CUDA timing is similar to the CPU timing for this preset, which suggests that eigendecomposition and data sizes are still small enough that GPU overhead can offset part of the benefit.
Medium Workload
Configuration: torus n=500, max_dim=3, 16 filtrations.
| Package | Device | Total Time | Mean Trial | Max Matrix | Status |
|---|---|---|---|---|---|
petls |
CPU | > 300 s | unavailable | unavailable | Reached benchmark timeout |
petls_torch |
CUDA | 8.80 s | 137.5 ms | 5990 x 5990 | Completed |
For this larger dense-eigendecomposition workload, the PyTorch/CUDA path completed within the benchmark timeout. The PETLS CPU run reached the configured 300-second timeout in this test configuration.
Operation Breakdown
Quick preset timings:
petls (CPU) : build=15.2 ms eigs=157.4 ms
petls_torch (CPU) : build=4.8 ms eigs=33.1 ms
petls_torch (CUDA) : build=4.7 ms eigs=33.8 ms
In these measurements, most time is spent in eigendecomposition. The PyTorch implementation benefits from PyTorch's dense linear algebra backends on CPU and from CUDA support on larger matrix workloads.
Running Benchmarks
# Original PETLS
cd /path/to/workspace
python -m benchmark_shared --preset quick --package petls --algorithm eigvalsh
# PETLS-PyTorch on CUDA
python -m benchmark_shared --preset quick --package petls_torch --algorithm eigvalsh --device cuda
# PETLS-PyTorch on CPU
python -m benchmark_shared --preset quick --package petls_torch --algorithm eigvalsh --device cpu
# Custom single run
python -m benchmark_shared \
--dataset torus --n_points 2000 --complex alpha --max_dim 3 \
--package petls_torch --algorithm eigvalsh
Installation
pip install petls-pytorch
Dependencies:
torchnumpyscipygudhipyflagsertadasetsfor benchmarks
Test Suite
cd PETLS-PYTORCH
pytest tests/ -v
The test suite covers core functionality, Rips complexes, alpha complexes, directed flag complexes, sheaf support, eigenvalue utilities, and I/O helpers.
Citation
If you use petls_torch in research, please cite both this PyTorch
implementation and the original PETLS paper.
PETLS-PyTorch
@software{marston2026petlstorch,
title = {PETLS-PyTorch: A PyTorch-native implementation of persistent topological Laplacians},
author = {Marston, Sumner K.},
year = {2026},
publisher = {Sylverity Research},
url = {https://github.com/Sylverity/petls-pytorch}
}
Original PETLS paper
@misc{jones2025petlspersistenttopologicallaplacian,
title={PETLS: PErsistent Topological Laplacian Software},
author={Benjamin Jones and Guo-Wei Wei},
year={2025},
eprint={2508.11560},
archivePrefix={arXiv},
primaryClass={math.AT},
url={https://arxiv.org/abs/2508.11560},
}
This project is an independent PyTorch-native implementation based on the public PETLS API, PETLS documentation, and the PETLS paper. No source code from the original PETLS implementation is included in this repository.
- Original PETLS repository: https://github.com/bdjones13/PETLS
- PETLS documentation: https://www.benjones-math.com/software/PETLS/
- PETLS paper: https://arxiv.org/abs/2508.11560
Project details
Release history Release notifications | RSS feed
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 petls_pytorch-1.0.0.tar.gz.
File metadata
- Download URL: petls_pytorch-1.0.0.tar.gz
- Upload date:
- Size: 27.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 |
8e0da7e737bbb6cfc6437f7da7e4ea3497b38d575b3400e31e7b80eec1e25549
|
|
| MD5 |
695e20501c61205083fa70b0d3b63992
|
|
| BLAKE2b-256 |
bc92746cf8e4a8db0ec7d94ca8f20796761a159eaec46b84f755afbe75e8dffe
|
Provenance
The following attestation bundles were made for petls_pytorch-1.0.0.tar.gz:
Publisher:
release.yml on Sylverity/petls-pytorch
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
petls_pytorch-1.0.0.tar.gz -
Subject digest:
8e0da7e737bbb6cfc6437f7da7e4ea3497b38d575b3400e31e7b80eec1e25549 - Sigstore transparency entry: 1952323139
- Sigstore integration time:
-
Permalink:
Sylverity/petls-pytorch@fe96a7bd41846f1dbdea64968b48798c0f01089d -
Branch / Tag:
refs/tags/v1.0.0 - Owner: https://github.com/Sylverity
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@fe96a7bd41846f1dbdea64968b48798c0f01089d -
Trigger Event:
push
-
Statement type:
File details
Details for the file petls_pytorch-1.0.0-py3-none-any.whl.
File metadata
- Download URL: petls_pytorch-1.0.0-py3-none-any.whl
- Upload date:
- Size: 34.8 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 |
216c57bd0582bdf23656576daf54af3f3bbcecc9c7f219ad85a8a888f9b56997
|
|
| MD5 |
6d578f94db0e25219717c77dfc25c07a
|
|
| BLAKE2b-256 |
59481dd7aeadf57dc9894e7af82b446e7ae2c30e5880e1c89e2f6b1e016346f3
|
Provenance
The following attestation bundles were made for petls_pytorch-1.0.0-py3-none-any.whl:
Publisher:
release.yml on Sylverity/petls-pytorch
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
petls_pytorch-1.0.0-py3-none-any.whl -
Subject digest:
216c57bd0582bdf23656576daf54af3f3bbcecc9c7f219ad85a8a888f9b56997 - Sigstore transparency entry: 1952323281
- Sigstore integration time:
-
Permalink:
Sylverity/petls-pytorch@fe96a7bd41846f1dbdea64968b48798c0f01089d -
Branch / Tag:
refs/tags/v1.0.0 - Owner: https://github.com/Sylverity
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@fe96a7bd41846f1dbdea64968b48798c0f01089d -
Trigger Event:
push
-
Statement type: