Twelve self-checking notebooks for the batchlas Python package. Each explains part of the API, computes something, and checks the result against NumPy/SciPy, so a clean run doubles as a smoke test:
A [FAIL] line means a check did not hold on your machine. The notebooks are committed with output from a reference run, so they render on GitHub without executing.
The notebooks import batchlas, so the kernel must be able to find it. From a build tree configured with BATCHLAS_BUILD_PYTHON=ON:
To execute and check all twelve without Jupyter:
run_all.py exits non-zero if a notebook raises or reports a failed check. After editing a notebook, --save re-executes it and writes the refreshed output back:
Requirements: NumPy for all notebooks, SciPy for notebook 09, and nbformat, nbclient and ipykernel for run_all.py. A GPU is optional. The notebooks fall back to the device the library picks, but some routines are GPU-only (see Device requirements below).
| # | Notebook | What it covers |
|---|---|---|
| 01 | 01_getting_started.ipynb | Backends, devices, features, first gemm, the batching convention, dtypes, out= |
| 02 | 02_dense_blas.ipynb | gemm, gemv, symm, syrk, syr2k, trmm, trsm, heterogeneous batches, mixed precision |
| 03 | 03_linear_solvers.ipynb | potrf, getrf/getrs, getri, inv, triangular solves, complex input |
| 04 | 04_qr_and_orthogonalization.ipynb | geqrf, orgqr, ormqr, ortho algorithms, ortho_metric |
| 05 | 05_svd.ipynb | gesvd, gesvd_blocked, gesvd_cta, gebrd_*, bdsqr, ormbr |
| 06 | 06_symmetric_eigensolvers.ipynb | The whole syev family incl. syev_jacobi_cta, syev_variant_support, options objects |
| 07 | 07_tridiagonal_reduction.ipynb | sytrd_cta, sytrd_blocked, sytrd_sy2sb, sytrd_sb2st, hetrd_hb2st, sytrd_band_reduction |
| 08 | 08_tridiagonal_eigensolvers.ipynb | steqr, steqr_cta, stedc, tridiagonal_solver |
| 09 | 09_sparse_and_iterative.ipynb | spmm, syevx (with convergence history), lanczos, ritz_values, ILU(k) |
| 10 | 10_jacobi_relative_accuracy.ipynb | Why syev_jacobi_cta exists: relative accuracy on graded matrices |
| 11 | 11_generators_and_utilities.ipynb | Constructors, conditioned random generators, norm, cond, transpose, lascl |
| 12 | 12_choosing_a_variant.ipynb | Batching speed-up, throughput scaling, picking a syev variant, CPU vs GPU |
Together they exercise 77 of the 78 names exported by batchlas. The 78th is ILUKPreconditioner, the handle type returned by iluk_factorize.
_common.py holds shared helpers (device selection, reporting, reference constructions). It is not part of the library API.
Timings and device names in notebook 12 come from an RTX 4090 and will differ on your hardware.
These are library defects. The notebooks call them out where they come up.
The *_cta routines map one work-group onto one matrix. They need a sub-group width of 32, so they are GPU-only. On a CPU they raise RuntimeError: ... device does not support subgroup size 32 .... They also accept only n <= 32. To ask the device directly instead of guessing, call syev_variant_support(a, device=...).