dendra-solvers
Differentiable implicit solvers for Dendra, with native C++ CPU kernels and Metal kernels for Apple GPUs through PyTorch's MPS device.
Installation
pip install dendra-solvers
Python 3.10+ and PyTorch 2.12+ are required. When a compatible wheel is available, installation does not require a compiler. Stable-ABI wheels work across supported Python and PyTorch versions on the same operating system and CPU architecture.
For an HPC environment or custom PyTorch build, install PyTorch first and build the extension against that installation:
python -m pip install "torch>=2.12.0" "setuptools>=77.0.3,<82" ninja wheel
MAX_JOBS=1 python -m pip install --no-build-isolation --no-cache-dir \
--no-deps --no-binary=dendra-solvers dendra-solvers
The build uses the C++ standard selected by your installed PyTorch. Use a C++20-capable compiler for current PyTorch releases. Stable-ABI builds do not need rebuilding just because PyTorch is upgraded; see installation and clean rebuilds for wheel availability, source builds, and upgrading older installations.
Useful build options:
DENDRA_NATIVE=1enables host-specific compiler optimizations. Do not use it for redistributable builds.DENDRA_OMP=1enables OpenMP when its runtime is available.MAX_JOBS=1limits compilation concurrency on memory-constrained systems.
Devices and precision
The public solve functions select their backend from the numeric tensors' device. General Thomas, PCR, 3×3 block-Thomas, scalar/block DHS trees and packed multi-morphology DHS support CPU float32/float64 and MPS float32. The owning DHS plan and physical-increment interfaces support the same devices.
For exact scalar tree contraction on MPS float32, use
TreeContractionPlan and tree_contraction_solve_plan. The plan owns the
CPU parent topology and defaults to at most 16 interior nodes per segment.
See scalar tree contraction
for the solve and preparation contracts.
MPS requires an available PyTorch MPS device and
torch.mps.compile_shader.
dendra_solvers.is_mps_available() checks both without compiling a shader.
Kernel compilation is lazy; CPU use does not initialize the Metal library.
Float64, float16/bfloat16 and the dedicated SPD/consuming APIs are currently
unsupported on MPS. CPU precision and SPD behavior are unchanged.
Keep immutable topology plans on CPU and place the numeric tensors on MPS:
import torch
from dendra_solvers import DHSPlan, dhs_solve_plan, is_mps_available
if not is_mps_available():
raise RuntimeError("An available PyTorch MPS device is required")
parent = torch.tensor([-1, 0, 0], dtype=torch.int64, device="cpu")
order = torch.tensor([1, 2, 0], dtype=torch.int64, device="cpu")
layers = torch.tensor([0, 2, 3], dtype=torch.int64, device="cpu")
plan = DHSPlan(parent, order, layers)
d_mem = torch.full(
(2, 3), 2.0, device="mps", dtype=torch.float32, requires_grad=True
)
a_geom = torch.tensor(
[[0.0, 0.2, 0.3]], device="mps", dtype=torch.float32
).expand_as(d_mem)
rhs = torch.ones_like(d_mem)
voltage = dhs_solve_plan(d_mem, a_geom, rhs, plan)
torch.testing.assert_close(voltage, torch.full_like(voltage, 0.5))
voltage.square().sum().backward()
torch.testing.assert_close(d_mem.grad, torch.full_like(d_mem, -0.25))
General solvers retain their reverse/forward AD, higher-order and vmap
interfaces on MPS. Numeric solves execute on the GPU; topology validation and
ownership remain on CPU. See solver contracts for
the supported APIs and transform usage for compilation.
Testing
For a development checkout:
python -m pip install "torch>=2.12.0" "setuptools>=77.0.3,<82" ninja wheel numpy pytest
MAX_JOBS=1 python -m pip install -v --no-build-isolation --no-deps -e .
python -c "import dendra_solvers._ext as ext; print(ext.__file__)"
python -m pytest -q -ra
Solver contracts and PyTorch transform usage are documented in docs/.
See Contributing for development tools, commit conventions, and versioning.
License
dendra-solvers is licensed under the BSD 3-Clause License.
Metadata
Release files for dendra-solvers 0.6.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| dendra_solvers-0.6.0.tar.gz | 148.5 kB | With provenance | Details for dendra_solvers-0.6.0.tar.gz |
Built distributions (wheels)
| File | Actions Reset | |||
|---|---|---|---|---|
| dendra_solvers-0.6.0-cp310-abi3-win_amd64.whl | CPython 3.10 | abi3 | Windows x86-64 | Details for dendra_solvers-0.6.0-cp310-abi3-win_amd64.whl |
| dendra_solvers-0.6.0-cp310-abi3-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl | CPython 3.10 | abi3 | Linux glibc 2.24+ x86-64, Linux glibc 2.28+ x86-64 | Details for dendra_solvers-0.6.0-cp310-abi3-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl |
| dendra_solvers-0.6.0-cp310-abi3-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl | CPython 3.10 | abi3 | Linux glibc 2.24+ ARM64, Linux glibc 2.28+ ARM64 | Details for dendra_solvers-0.6.0-cp310-abi3-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl |
| dendra_solvers-0.6.0-cp310-abi3-macosx_14_0_arm64.whl | CPython 3.10 | abi3 | macOS 14.0+ ARM64 | Details for dendra_solvers-0.6.0-cp310-abi3-macosx_14_0_arm64.whl |
Total release size: 5.2 MB
Release files / dendra_solvers-0.6.0.tar.gz
| Download URL | dendra_solvers-0.6.0.tar.gz |
|---|---|
| Size | 148.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9335fe445938709ec29a303c77fcb7da91eccd54b687ac16c18f88db406abf83
|
|
BLAKE2b-256 checksum How to use checksums |
efd8ea20f8753c0fc7719631a420f25bef519ac53a000c501c3cb465e71ed2ae
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 25, 2026.
Transparency logRelease files / dendra_solvers-0.6.0-cp310-abi3-win_amd64.whl
| Download URL | dendra_solvers-0.6.0-cp310-abi3-win_amd64.whl |
|---|---|
| Size | 368.7 kB |
| Tags | CPython 3.10 Windows x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
b31d72a5c1c8314a9482350b223b4cfbd4d055465fafd505a11b6b44a896a256
|
|
BLAKE2b-256 checksum How to use checksums |
d6f7cd2c8e8920e46f949fdca61550ad96a387bdde20cf876448073a490598c3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 25, 2026.
Transparency logRelease files / dendra_solvers-0.6.0-cp310-abi3-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
| Download URL | dendra_solvers-0.6.0-cp310-abi3-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl |
|---|---|
| Size | 2.3 MB |
| Tags | CPython 3.10 Linux glibc 2.24+ x86-64 Linux glibc 2.28+ x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
14b214cc10b4f00c5b82b261834c8fa84c07816f811a95455a707e7214031855
|
|
BLAKE2b-256 checksum How to use checksums |
bd0b116af231e60b0b7ecaedbe72e34994c0e060245eb1001e125e1086db0044
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 25, 2026.
Transparency logRelease files / dendra_solvers-0.6.0-cp310-abi3-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl
| Download URL | dendra_solvers-0.6.0-cp310-abi3-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl |
|---|---|
| Size | 2.2 MB |
| Tags | CPython 3.10 Linux glibc 2.24+ ARM64 Linux glibc 2.28+ ARM64 abi3 |
|
SHA-256 checksum How to use checksums |
037bbdc0ed88805391841c0fc8065f3bca0b99228bfa7eb1c11864b51b5dd0b1
|
|
BLAKE2b-256 checksum How to use checksums |
c205027058530d5684e0a15f54a924efdad04799874e15dc8bbc340e313e2de6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 25, 2026.
Transparency logRelease files / dendra_solvers-0.6.0-cp310-abi3-macosx_14_0_arm64.whl
| Download URL | dendra_solvers-0.6.0-cp310-abi3-macosx_14_0_arm64.whl |
|---|---|
| Size | 212.1 kB |
| Tags | CPython 3.10 abi3 macOS 14.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
944ccf93b70635120c82e590fe3f24256908efafb0a00fce96e3a03bc0a6ba73
|
|
BLAKE2b-256 checksum How to use checksums |
49a6116d37e4717ee1a2b8922d94d434235dda77e5927053841fe168662499f7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 25, 2026.
Transparency logSecurity for dendra-solvers 0.6.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
All 5 files in this release have been uploaded with provenance metadata.
Attestation for dendra_solvers-0.6.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 25, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.