sparse-approx-gsm
Python (+ optional CUDA) implementation of Sparse Approximation by the Generalized Soft-Min (GSM) Penalty — a sparse-recovery solver based on the Trimmed Lasso.
Solves: min ||Ax - y||_2 subject to ||x||_0 <= k
Tal Amir, Ronen Basri, Boaz Nadler — The Trimmed Lasso: Sparse Recovery Guarantees and Practical Optimization by the Generalized Soft-Min Penalty. Weizmann Institute of Science.
Install
From PyPI:
pip install sparse-approx-gsm
From source (with CUDA extension):
pip install pybind11 scikit-build-core cython numpy
NVCC=/path/to/nvcc
PYBIND11_DIR=$(python -c "import pybind11; print(pybind11.get_cmake_dir())")
CMAKE_ARGS="-DCMAKE_CUDA_COMPILER=$NVCC -Dpybind11_DIR=$PYBIND11_DIR -DCMAKE_CXX_COMPILER=/usr/bin/g++" \
pip install --no-build-isolation . -v
From source (CPU only):
pip install --no-build-isolation .
Usage
from sparse_approx_gsm import sparse_approx_gsm, SparseApproxGSM, gsm
# High-level solver: min ||Ax - y||_2 s.t. ||x||_0 <= k
x = sparse_approx_gsm(A, y, k, profile='normal')
# GSM function and gradient
mu, theta = gsm(z, k, gamma)
GPU Acceleration
Install CuPy for the matching CUDA version (e.g. pip install cupy-cuda12x), then pass
a CuPy array to gsm() or use SparseApproxGSM(..., use_gpu=True).
When use_gpu=True, arrays are cached on the GPU and kept there throughout the solver loop, minimizing CPU-GPU data transfers.
What's New in v1.1.0
- GPU transfer optimization: Immutable arrays (A, G, y, Aty) cached on GPU; solution vector and weights stay on GPU through the MM loop
- Redundant computation elimination: GSM mu is cached from weight computation, avoiding duplicate GPU kernel launches
- Cython acceleration: Fused FISTA kernels and OpenMP-parallelized utilities for the CPU fallback path
- Module renamed: Import path is now
sparse_approx_gsm(wasgsm_python)
Metadata
Release files for sparse-approx-gsm 1.1.0
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 |
|---|---|---|---|---|
| sparse_approx_gsm-1.1.0.tar.gz | 2.7 MB | Without provenance | Details for sparse_approx_gsm-1.1.0.tar.gz |
Release files / sparse_approx_gsm-1.1.0.tar.gz
| Download URL | sparse_approx_gsm-1.1.0.tar.gz |
|---|---|
| Size | 2.7 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
304d2ab54ab94f55369a3439223b1f6cdfeb4b2d35693f684ea1652ff1f973ab
|
|
BLAKE2b-256 checksum How to use checksums |
01063f523b9ad2f0f9861f898aae03ff9595a6ec0be36454e12b59cf4c60ffb7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.10.19
|
Security for sparse-approx-gsm 1.1.0
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.