pyamg
PyAMG: Algebraic Multigrid Solvers in Python
What it is and what it does
PyAMG is a library of Algebraic Multigrid solvers designed to solve large-scale sparse linear systems with optimal or near-optimal efficiency. Unlike geometric multigrid, AMG requires little geometric information about the underlying problem and develops a sequence of coarser grids directly from the input matrix—making it especially useful for problems on unstructured meshes and irregular grids. The library is written primarily in Python with performance-critical C++ components.
The package implements Classical (Ruge-Stuben) AMG and Smoothed Aggregation methods, with experimental support for Adaptive Smoothed Aggregation and Compatible Relaxation. It is commonly used as a preconditioner or standalone solver in scientific computing workflows, particularly for finite-element and finite-difference discretizations. Installation is straightforward via pip or conda, with prebuilt wheels for modern Python versions on major platforms.
Use it for:
- Solve 2D/3D Poisson problems and other elliptic PDEs on unstructured grids where geometric information is unavailable
- Precondition iterative solvers for large sparse systems arising from finite-element discretizations
- Accelerate convergence of Krylov subspace methods (e.g., GMRES, CG) via multigrid preconditioning
- Prototype and develop multilevel solution strategies for research in numerical linear algebra
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
PyAMG provides Algebraic Multigrid (AMG) solvers for efficiently solving large-scale sparse linear systems, with implementations of Classical AMG and Smoothed Aggregation methods.
Yes. PyAMG is a mature, actively maintained library (active status, recent commits) with no known vulnerabilities, permissive MIT licensing, and solid platform coverage. Install friction is moderate due to compiled components, but prebuilt wheels mitigate this. Suitable for anyone solving large sparse linear systems, especially on unstructured problems where classical multigrid is impractical.
Install
pyamg on PyPI
pip
pip install pyamguv
uv add pyamgpoetry
poetry add pyamgInstalling pyamg
Before you install
Medium install friction due to compiled C++ components, but prebuilt wheels are available for Python 3.9–3.13 on macOS, Linux, and Windows. Active maintenance with recent releases; last commit 2026-03-30.
License in practice
MIT license permits commercial and private use with minimal restrictions; suitable for most projects.
Quickstart
import pyamg
import numpy as np
A = pyamg.gallery.poisson((500, 500), format='csr')
ml = pyamg.ruge_stuben_solver(A)
b = np.random.rand(A.shape[0])
x = ml.solve(b, tol=1e-10)
Requires numpy and scipy; Python 3.9 or later.
Verify before relying
- Performance characteristics and scalability limits for specific problem sizes or matrix structures
- Comparative efficiency versus other multigrid or iterative solvers in typical use cases
Package facts
| License | MIT (permissive) |
| Python support | supports the current Python release (>=3.9) |
| Install friction | medium — platform-specific wheel |
| Runtime dependencies | 2 — numpy, scipy |
| Maintenance | actively maintained — 355 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 141,888/month — #11,231 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: pyamg-5.3.0-cp310-cp310-macosx_10_9_x86_64.whl; pyamg-5.3.0-cp310-cp310-macosx_11_0_arm64.whl; pyamg-5.3.0-cp310-cp310-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl; pyamg-5.3.0-cp310-cp310-musllinux_1_2_x86_64.whl; pyamg-5.3.0-cp310-cp310-win32.whl; pyamg-5.3.0-cp310-cp310-win_amd64.whl; pyamg-5.3.0-cp311-cp311-macosx_10_9_x86_64.whl; pyamg-5.3.0-cp311-cp311-macosx_11_0_arm64.whl; pyamg-5.3.0-cp311-cp311-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl; pyamg-5.3.0-cp311-cp311-musllinux_1_2_x86_64.whl; pyamg-5.3.0-cp311-cp311-win32.whl; pyamg-5.3.0-cp311-cp311-win_amd64.whl; pyamg-5.3.0-cp312-cp312-macosx_10_13_x86_64.whl; pyamg-5.3.0-cp312-cp312-macosx_11_0_arm64.whl; pyamg-5.3.0-cp312-cp312-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl; pyamg-5.3.0-cp312-cp312-musllinux_1_2_x86_64.whl; pyamg-5.3.0-cp312-cp312-win32.whl; pyamg-5.3.0-cp312-cp312-win_amd64.whl; pyamg-5.3.0-cp313-cp313-macosx_10_13_x86_64.whl; pyamg-5.3.0-cp313-cp313-macosx_11_0_arm64.whl
Keywords: algebraic multigrid, AMG, sparse matrix, preconditioning
Tags
More Scientific/Engineering packages
NumPy provides an N-dimensional array object…
permissive · top 100 on PyPI
pandaspandas provides fast, flexible data structures…
permissive · top 100 on PyPI
scipyscipy provides numerical algorithms for…
permissive · top 100 on PyPI
scikit-learnscikit-learn provides a comprehensive Python…
permissive · top 1,000 on PyPI
dilldill extends Python's pickle module to…
permissive · top 1,000 on PyPI
multiprocessMultiprocess is an enhanced fork of Python's…
permissive · top 1,000 on PyPI
nvidia-cusolverProvides CUDA solver native runtime libraries…
unclear · top 1,000 on PyPI
nvidia-cusolver-cu12Provides CUDA solver native runtime libraries…
unclear · top 1,000 on PyPI
qdldlProvides a Python interface to QDLDL, a free…
permissive · top 5,000 on PyPI
pybammsolverspybammsolvers provides a Python interface to…
unclear · top 15,000 on PyPI
pybammPyBaMM is a Python framework for simulating…
permissive · top 15,000 on PyPI
qpsolversProvides a unified Python interface to solve…
copyleft · top 5,000 on PyPI
nvidia-cusolver-cu11Provides NVIDIA CUDA solver native runtime…
unclear · top 5,000 on PyPI
POTPOT provides solvers for optimal transport…
permissive · top 15,000 on PyPI
gekkoGEKKO is a Python package for optimization and…
permissive · top 15,000 on PyPI
amplpyamplpy is a Python interface to AMPL, an…
permissive · top 15,000 on PyPI