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:

Which solver to install, by computer and installer
Computercondapip or uv
Linux x86_64scikit-umfpack, without PyPardisoPyPardiso
Windows, 64-bitscikit-umfpack, without PyPardisoPyPardiso
Mac with Intelscikit-umfpack, without PyPardisoPyPardiso, on MKL up to 2023.2.2
Mac with Apple siliconscikit-umfpackNo 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-umfpack
conda install -c conda-forge scikit-umfpack

pip or uv:

pip install pypardiso
uv add pypardiso

Special cases

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.

Factorizing real ecoinvent 3.12, one thread
The numbers in the findings: Factorizing real ecoinvent 3.12, one thread

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.

Time to the first score
Open in the viewer: Time to the first score

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.

MultiLCA, 30 products
Open in the viewer: MultiLCA, 30 products

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

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.