Linac implements GPU-accelerated linear algebra using CUDA, with support for real and complex floating-point arithmetic, finite fields, and leading-digit p-adic numbers. Its main functionality is dense Gaussian elimination to reduced row-echelon form. Applications include functional reconstruction of analytic scattering amplitudes.
Installation
The latest stable release is available from PyPI:
pip install linac
To enable GPU acceleration, install the CUDA extra:
pip install "linac[cuda]"
For development, clone the repository and install it in editable mode:
git clone https://github.com/GDeLaurentis/linac.git
pip install -e "linac[full]"
Available extras are:
cuda, dev, full(=cuda+dev)
Requirements
The core package depends on:
numpy, pycoretools, pyadic, syngular
Optional dependencies include:
pycuda # CUDA/GPU support
with the cuda extra, and
mpmath, galois, diskcache, pytest, pytest-cov, flake8
with the dev extra.
GPU acceleration requires a working CUDA development environment, including nvcc, compatible NVIDIA drivers, and access to a CUDA-enabled GPU.
You can check your CUDA setup with:
nvcc --version
nvidia-smi
Quick Start
The main entry point is cuda_row_reduce, which computes a row-reduced echelon form on the GPU.
import numpy
from linac import cuda_row_reduce
p = 2**31 - 1
A = numpy.random.randint(0, p, size=(2000, 2000), dtype="uint32")
rref = cuda_row_reduce(A, field_characteristic=p)
Setting field_characteristic=0 selects floating-point arithmetic:
A = numpy.random.rand(2000, 2000)
rref = cuda_row_reduce(A, field_characteristic=0)
For CPU row reduction, use:
from linac import row_reduce
rref, variable_order = row_reduce(A, prime=p)
Linac also provides utilities for constructing dense linear systems from polynomial ansätze:
from linac import load_matrices
matrices = load_matrices(prefactors, ansatze, points, use_cuda=True)
Testing
Run the test suite with:
pytest -rs --verbose --cov=linac --cov-report=html
Timings
The following timings are for dense Gaussian elimination to reduced row-echelon form over the finite field with p=(2**31 - 1). Times are shown in seconds as mean ± standard deviation.
| Matrix size | A100 80GB | RTX 4070 Laptop 8GB |
|---|---|---|
| 1,000 | 0.52 ± 0.01 | 0.28 ± 0.02 |
| 2,000 | 0.56 ± 0.01 | 0.34 ± 0.01 |
| 5,000 | 1.02 ± 0.01 | 3.31 ± 0.01 |
| 10,000 | 3.60 ± 0.01 | 25.97 ± 0.66 |
| 15,000 | 10.23 ± 0.02 | 98.21 ± 0.85 |
| 20,000 | 23.40 ± 0.03 | 241.29 ± 3.00 |
| 100,000 | 2824.64 | — |
The 100k run used approximately 37.67 GiB of memory on an 80 GiB A100.
For full benchmark details and comparison with CPU implementations, see the accompanying paper and documentation.
Size Limit
For 32-bit entries, the approximate upper bound for a dense square matrix is
N_max ~ sqrt(VRAM [bytes] / 4)
| Available VRAM | Approx. square matrix size |
|---|---|
| 4 GB | 31,622 |
| 8 GB | 44,721 |
| 11 GB | 52,440 |
| 12 GB | 54,772 |
| 16 GB | 63,245 |
| 24 GB | 77,459 |
| 40 GB | 100,000 |
| 80 GB | 141,421 |
The practical limit is usually close to this estimate, up to padding and (small) memory-management overheads.
Documentation
Documentation is available at:
https://gdelaurentis.github.io/linac/
Citation
If you use Linac in academic work, please cite the accompanying paper and the Zenodo archive:
@software{linac,
author = {De Laurentis, Giuseppe and Franklin, Jack},
title = {Linac: linear algebra with CUDA over finite fields},
year = {2026},
doi = {10.5281/zenodo.xxxxxxxx},
}
Metadata
Release files for linac 1.0.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 |
|---|---|---|---|---|
| linac-1.0.1.tar.gz | 42.0 kB | Without provenance | Details for linac-1.0.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| linac-1.0.1-py3-none-any.whl | Python 3 | none | any | Details for linac-1.0.1-py3-none-any.whl |
Total release size: 81.2 kB
Release files / linac-1.0.1.tar.gz
| Download URL | linac-1.0.1.tar.gz |
|---|---|
| Size | 42.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
3679915b4432ebf8dee270e638610f730914069d14d17830b79bddc231d08c3f
|
|
BLAKE2b-256 checksum How to use checksums |
5f6186d2a986634891b19cbf9d5e5dabebe2cbabbb18f40743ef5626efb94e3a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.12.3
|
Release files / linac-1.0.1-py3-none-any.whl
| Download URL | linac-1.0.1-py3-none-any.whl |
|---|---|
| Size | 39.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e1c275b8d6d215f678c3ea04ff25b1ab7ac9f5791060bfb42f940a6c7a2eec27
|
|
BLAKE2b-256 checksum How to use checksums |
b28f7525225be66600b3b59504437aa678d83ab1ab5785b2011c6c2115508648
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.12.3
|
Security for linac 1.0.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.