Add pure-Python solver backend for simplified installation#245
Merged
jameslehoux merged 4 commits intomasterfrom Apr 4, 2026
Merged
Add pure-Python solver backend for simplified installation#245jameslehoux merged 4 commits intomasterfrom
jameslehoux merged 4 commits intomasterfrom
Conversation
When the compiled C++ backend (_core) is unavailable, OpenImpala now transparently falls back to a pure-Python solver that uses SciPy sparse matrices on CPU or CuPy on GPU. This enables `pip install openimpala` to work without any compiled extensions, CUDA toolkit, or MPI — matching the install simplicity of packages like TauFactor. The solver implements the same algorithm as the C++ HYPRE path: - 7-point stencil Laplacian with harmonic-mean face coefficients - Dirichlet BCs at inlet/outlet, zero-flux Neumann on sides - Sparse CG solve (CuPy GPU or SciPy CPU) - Flood-fill percolation via scipy.ndimage.label - Flux integration → D_eff → tau = active_vf / D_eff Validated against all three analytical benchmarks: - Uniform block: tau = (N-1)/N — exact match for N=8,16,32,64 - Volume fraction: exact counting - Percolation: correct connected/disconnected detection New/modified files: - python/openimpala/_solver.py — pure-Python solver engine - python/openimpala/session.py — graceful fallback when _core missing - python/openimpala/facade.py — auto-routing to Python or C++ backend - python/openimpala/__init__.py — better error messages for _core attrs - pyproject.toml — scipy dependency, cupy optional extra - python/CMakeLists.txt — install _solver.py in wheels https://claude.ai/code/session_01RKnn97qiD7sbCeABHH3eQk
The CPU wheel previously compiled _core.so with AMReX+HYPRE+MPI, requiring users to have MPI installed at runtime. Now `pip install openimpala` ships a pure-Python wheel (py3-none-any) with only numpy+scipy as dependencies. GPU acceleration is automatic when CuPy is present (e.g. Colab GPU runtime). Two install paths: - pip install openimpala → pure Python, SciPy/CuPy solver - pip install openimpala-cuda → compiled C++ HYPRE backend (HPC) Changes: - python/pyproject.toml: new setuptools-based build config for pure-Python wheel - .github/workflows/pypi-wheels-cpu.yml: simplified to `python -m build` - pyproject.toml: removed [gpu] optional extra (CuPy auto-detected at runtime) https://claude.ai/code/session_01RKnn97qiD7sbCeABHH3eQk
All tutorials and notebooks now use `pip install openimpala` instead of the old `openimpala-cuda --find-links ... nvidia-cuda-*` pattern. The pure-Python package auto-detects CuPy for GPU acceleration. Updated files: - All 7 tutorials: simplified install cells - notebooks/profiling_and_tuning.ipynb: removed MPI/CUDA deps - README.md, docs/getting-started.md, docs/index.rst: primary install is now `pip install openimpala`, openimpala-cuda moved to Advanced/HPC - docs/user-guide/gpu.md: rewritten for CuPy auto-detection - paper.md: updated distribution description https://claude.ai/code/session_01RKnn97qiD7sbCeABHH3eQk
Performance Benchmark Results
Fastest solver: bicgstab at 64³ (0.3741s) Benchmark: uniform block (analytical τ = (N-1)/N) |
Code Coverage ReportGenerated by CI — coverage data from gcovr |
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.