skillfed

pyamg

PyAMG: Algebraic Multigrid Solvers in Python

pyamg v5.3.0 141.9K downloads/30d#11,231 on PyPI652
Permissive license MIT Active released

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 pyamg

uv

uv add pyamg

poetry

poetry add pyamg

Installing 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

Development Status :: 5 - Production/StableIntended Audience :: DevelopersIntended Audience :: EducationIntended Audience :: Science/ResearchLicense :: OSI Approved :: MIT LicenseNatural Language :: EnglishOperating System :: OS IndependentProgramming Language :: C++Programming Language :: PythonProgramming Language :: Python :: 3Programming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.9Topic :: EducationTopic :: Scientific/EngineeringTopic :: Scientific/Engineering :: MathematicsTopic :: Software Development :: Libraries :: Python Modules

Tags

algebraic multigrid solversparse matrix linear solverAMG preconditionerlarge-scale linear systemsmultigrid methods pythonsparse matrix solveriterative linear solver
numerical-linear-algebrasparse-matricesscientific-computing

More Scientific/Engineering packages