Your solver choice changes a single-threaded Brightway score by up to 5 times
On one thread with bw2calc 3.1.0, scikit-umfpack from conda-forge factors the ecoinvent 3.12 matrix about 5 times as fast as SciPy's default SuperLU. PyPardiso is about 2 times as fast and also scales across multiple threads. Check which solver you have, then install the one for your workflow.
One Brightway score builds a sparse matrix A, solves Ax = b, and takes a weighted dot product cTx. Most coefficients in A are zero. The solver package factors A into two triangular matrices that solve quickly, and bw2calc picks the solver from what you have installed.
For ecoinvent 3.12 cut-off, the matrix has 26,533 rows and 338,195 nonzeros. On one thread (efficiency core, bw2calc 3.1.0), factorizing it takes 0.66 to 3.66 s depending on the solver, and solving on the factors takes 5 to 24 ms. PyPardiso can use several threads and is not measured multithreaded in the main comparison.
What to install
First check which solver you have:
python -c "import bw2calc as bc; print('PyPardiso' if bc.PYPARDISO else 'UMFPACK' if bc.UMFPACK else 'SuperLU')"If it prints UMFPACK or PyPardiso, you already have a fast solver. Keep PyPardiso if you use MultiLCA or bw_timex. If you want to try UMFPACK on conda for single-demand LCA or Monte Carlo, remove PyPardiso so bw2calc uses UMFPACK.
If it prints SuperLU, switching saves about 3 s of factorizing per score on real ecoinvent (about 50 minutes over 1,000 Monte Carlo draws). Find your computer and installer:
| Computer | conda | pip or uv |
|---|---|---|
| Linux x86_64 | scikit-umfpack, without PyPardiso | PyPardiso |
| Windows, 64-bit | scikit-umfpack, without PyPardiso | PyPardiso |
| Mac with Intel | scikit-umfpack, without PyPardiso | PyPardiso, on MKL up to 2023.2.2 |
| Mac with Apple silicon | scikit-umfpack | No fast solver installs from PyPI: use conda |
bw2calc uses PyPardiso whenever it is installed, so it runs UMFPACK only without it. PyPardiso needs Intel's MKL, which PyPI has only for the x86_64 computers above.
conda (single-demand LCA or Monte Carlo; remove PyPardiso only if installed and you don't need MultiLCA or bw_timex):
conda remove pypardiso && conda install -c conda-forge scikit-umfpackconda install -c conda-forge scikit-umfpackpip or uv:
pip install pypardisouv add pypardisoSpecial cases
- bw_timex on Linux x86_64 or 64-bit Windows: bw_timex requires PyPardiso there, so you get PyPardiso. Removing it breaks bw_timex, so keep it.
- Many products in one go (
MultiLCA): PyPardiso. If you only need the scores,from bw2calc import FastScoresOnlyMultiLCAwith UMFPACK is faster still. - scikit-umfpack from PyPI:
pip install scikit-umfpackoruv add scikit-umfpackcompiles it on install, and it runs a little slower than PyPardiso.
How long each solver takes
Factorizing is 96 to over 99% of the solver's time for one score. On the ecoinvent 3.12 cut-off matrix, SuperLU takes 5.5 times as long as scikit-umfpack from conda-forge to factorize on one thread. See the measurement settings.
- scikit-umfpack from conda-forge (UMFPACK, on OpenBLAS)0.66 s
- PyPardiso (PARDISO, on MKL)1.48 s
- scikit-umfpack from PyPI (UMFPACK, on reference BLAS)1.78 s
- Nothing extra (SciPy's SuperLU)3.66 s
Details for benchmark readers
The rest covers whole-score times, why the scikit-umfpack builds differ, other bw2calc classes and how this was measured.
One score
The charts below come from a pinned benchmark machine, on one thread, and each links to its benchmark's full history. They use a synthetic database with ecoinvent's size and shape. A whole score there takes 1.4 to 1.6 times as long as the factorization above, mostly because the synthetic matrix takes longer to factorize than the real one, and the solvers come in the same order.
bw2calc's LCA class builds the matrices, factorizes the technosphere, solves it and characterizes the result. The whole first score takes 4.98 s with SuperLU against 1.03 s with scikit-umfpack from conda-forge.
- scikit-umfpack from conda-forge (UMFPACK, on OpenBLAS)1.03 s
- PyPardiso (PARDISO, on MKL)2.22 s
- Nothing extra (SciPy's SuperLU)4.98 s
With nothing extra installed, bw2calc uses SciPy's SuperLU, the slowest bar. With PyPardiso installed, bw2calc uses it even when scikit-umfpack is there too. So the fastest bar needs scikit-umfpack and no PyPardiso.
Where scikit-umfpack comes from
UMFPACK does most of its work through BLAS, the library of basic matrix routines that NumPy also uses. conda-forge links it to OpenBLAS, a fast BLAS. PyPI has only scikit-umfpack's source, so pip compiles it against whatever BLAS you have.
The pip build measured here runs on reference BLAS, the plain textbook version. It is a little slower than PyPardiso on both databases: 2.54 s against 2.30 s for PyPardiso from PyPI on the synthetic one (the pip build's history), and 1.78 s against 1.48 s on the real matrix.
Thirty products at once
MultiLCA scores 30 products against three impact methods in one call.
- PyPardiso (PARDISO, on MKL)2.75 s
- Nothing extra, or scikit-umfpack (SciPy's SuperLU)5.40 s
Here scikit-umfpack makes no difference. Without PyPardiso, MultiLCA passes all 30 demands to SciPy's spsolve at once, as one matrix with 30 columns. spsolve hands the work to UMFPACK only for a single right-hand side, one demand vector (SciPy's source). For more, it uses SuperLU. PyPardiso solves all 30 itself and is about twice as fast.
If you only need the scores, FastScoresOnlyMultiLCA factorizes the matrix once and then solves the products separately (one at a time with UMFPACK, 50 per call with PyPardiso), so UMFPACK is back in front: in bw2calc 3.1.0, 1.63 s, against 2.68 s for PyPardiso (the forward-direction history). It needs PyPardiso or UMFPACK and refuses to run on SuperLU.
Monte Carlo, and the class you call
Each Monte Carlo draw has new matrix values, so the solver starts over and its time counts once per draw. On the synthetic database, ten draws with LCA and PyPardiso take 21.6 s (the Monte Carlo history).
The bw2calc class matters too. JacobiGMRESLCA doesn't factorize: it improves a guess step by step until the result is within a tolerance, so its score is close, not exact. In bw2calc 3.1.0 it gives one score in about 130 ms, with a relative error of 5.6e-9, and ten draws in 0.65 s (its history).
That is on the synthetic matrix. bw2calc's own docs report a 20% error on one real ecoinvent process, so check the result before you rely on it. IterativeLCA factorizes once, then iterates; UMFPACK does the one factorization, and ten draws take 0.76 s, on the synthetic database too.
Baseline: bw2calc 3.1.0, SciPy 1.18.1, Python 3.13, one thread on an efficiency core of a pinned benchmark machine.
How this was measured
- A pinned benchmark machine, Linux x86_64, in a container, on one efficiency core. BLAS and OpenMP run on one thread:
OPENBLAS_NUM_THREADS=1,MKL_NUM_THREADS=1,OMP_NUM_THREADS=1. - Python 3.13 from conda-forge, bw2calc 3.1.0, NumPy 2.5.3, SciPy 1.18.1, PyPardiso 0.4.7 with MKL 2026.1.0, and scikit-umfpack 0.4.2 (SuiteSparse 7.10.1) on OpenBLAS 0.3.34. The pip build is scikit-umfpack 0.4.2 from PyPI. The one-score times are the same in every bw2calc release from 2.0 to 3.1.0, except PyPardiso from PyPI, which takes about 0.1 s longer from 3.0.0 on (the release history).
- A synthetic database with 26,533 products, like ecoinvent 3.12 cut-off.
- Real ecoinvent: the ecoinvent 3.12 cut-off technosphere matrix, 26,533 rows and 338,195 nonzeros, on one efficiency core of the pinned machine, one thread.
scripts/solver_factorize.pytimes one factorization of each solver (median of 3) through bw2calc 3.1.0'sspsolveandlu_solver, with SciPy 1.18.1, PyPardiso 0.4.7 and scikit-umfpack 0.4.2 from PyPI and from conda-forge. A performance core gives 1.7 to 2 times shorter times in the same order. - One score:
LCA(demand={0: 1}, data_objs=[inventory, method]), thenlci()andlcia(). Thirty products:MultiLCA(demands=..., method_config=..., data_objs=...), thenlci()andlcia(), orFastScoresOnlyMultiLCA(..., direction="forward")andnext(lca). Monte Carlo:LCA(..., use_distributions=True, seed_override=1), then tennext(lca)calls. - Each timed call has a fresh setup. For each parameter set in a process, the first setup warms the case and the checks run outside the timer. Each time is asv's median of 4 to 10 calls.
- Source: the benchmarks, SciPy's
spsolveand theJacobiGMRESLCAdocstring in bw2calc 3.1.0 for the 20% error (a demand for “market for waste polystyrene”).
Setup has tested install sets. The benchmark guide gives the command for reproducing the first-score comparison. Make your Brightway faster lists other measured changes you can try.
Back to Setup, where the tested install sets are.