hpfracc.solvers — architecture, dependencies, and maintenance
This note complements CONTRIBUTING.md, ALGORITHMS_ARCHITECTURE.md, SPECIAL_ARCHITECTURE.md, and VALIDATION_ARCHITECTURE.md. It is the detailed map for fractional ODE / PDE / SDE time-stepping, noise models, graph–temporal coupling, and the JAX/Diffrax bridge.
1. Design goals
Time-stepping first: provide reference integrators for fractional-in-time dynamics (history convolutions, GL-type weights) that are usable from examples, validation scripts, and
hpfracc.ml.neural_fsde.Clear separation from “solver” in other stacks: the word solver also appears in SciPy (
solve_ivp), torchdiffeq, Diffrax (dfx.diffeqsolve(..., solver=...)), and generic numerical texts. This package ishpfracc.solvers— not those APIs (see §6).Optional acceleration without hard cycles: FFT / array backends may consult
hpfracc.ml.intelligent_backend_selectorfrom inside lazy helpers (_get_intelligent_selector), so importinghpfracc.solversdoes not require ML training code until a backend decision runs.Honest modeling docs:
coupled_solvers.pyships an explicit module docstring on approximation limits (spatial Euler, temporal memory model, asymmetric coupling in splitting). Treat that text as normative for interpreting coupled outputs.
2. Module layout (file-by-file)
Module |
Role |
Primary entry points |
|---|---|---|
|
Fractional ODE stepping, FFT-accelerated history convolution, |
Uses |
|
Fractional SDE drivers, |
Imports |
|
Spatial–temporal fractional PDE prototypes (diffusion / advection / reaction–diffusion), sparse GL-style operators, |
SciPy sparse linear algebra; Γ from |
|
|
Optional NumPyro / JAX for some paths ( |
|
Graph–SDE coupling: |
Imports |
|
JAX ecosystem bridge: Diffrax VirtualBrownianTree, optional precomputed fBm via |
Not imported from |
|
Re-exports ODE / PDE / SDE / noise / coupled symbols; compatibility aliases and explicit placeholders for unimplemented high-order APIs (see §4). |
Keeps legacy names ( |
3. Import graph (intended edges)
flowchart TB
subgraph solvers_pkg["hpfracc.solvers"]
ODE["ode_solvers"]
SDE["sde_solvers"]
PDE["pde_solvers"]
NOISE["noise_models"]
COUPLED["coupled_solvers"]
JAXU["solvers_jax_utils (explicit import)"]
end
CORE["core.definitions.FractionalOrder"]
SPEC["special.gamma_beta (gamma_function)"]
MLSEL["ml.intelligent_backend_selector (lazy)"]
ODE --> CORE
ODE --> SPEC
SDE --> CORE
SDE --> NOISE
PDE --> CORE
COUPLED --> ODE
COUPLED --> SDE
ODE -.->|first FFT backend use| MLSEL
SDE -.->|first FFT backend use| MLSEL
PDE -.->|first array backend use| MLSEL
Downstream of solvers
hpfracc.ml.neural_fsdeimportssolve_fractional_sde/FractionalSDESolverfromsde_solvers.
There is no solvers → neural_fsde import at module load; the dependency is one-way ML → solvers.
4. Public surface and compatibility policy (__init__.py)
Supported ODE workflow: FixedStepODESolver and solve_fractional_ode with documented methods (e.g. Euler, Adams–Bashforth, Runge–Kutta, predictor–corrector where implemented).
Aliases (same implementation):
FractionalODESolver,AdaptiveFractionalODESolver,AdaptiveFixedStepODESolver→FixedStepODESolver(adaptive behaviour is not a separate class — controlled by solver parameters where applicable).
Explicit placeholders (raise NotImplementedError on construction or call):
AdvancedFractionalODESolver,HighOrderFractionalSolver,VariableStepPredictorCorrector,solve_advanced_fractional_ode,solve_high_order_fractional_ode.
Thin wrappers:
solve_predictor_corrector→ delegates tosolve_fractional_ode.PredictorCorrectorSolver,AdamsBashforthMoultonSolver→FixedStepODESolver.
When extending the package, prefer adding real implementations or narrowing __all__ in a major release over growing the placeholder list.
5. Gamma (Γ) usage consistency
Module |
Γ source |
Note |
|---|---|---|
|
|
SciPy-first, matches SPECIAL_ARCHITECTURE.md “solvers use |
|
|
Historical / simpler path for spatial coefficients; not the JAX-aware |
6. Naming collisions (read before mixing ecosystems)
Term here |
Often means elsewhere |
Disambiguation |
|---|---|---|
|
|
Different formulation (fractional history, not classical |
|
Diffrax |
Diffrax solves SDEs/ODEs with its own stepper objects named “solver”; |
|
torchdiffeq |
|
|
|
Validation benchmarks compare methods; |
7. Optional dependencies (install surface)
Feature |
Typical extras / packages |
|---|---|
NumPyro noise paths |
|
Diffrax + fBm driver |
|
Intelligent FFT / array backend hints |
|
8. Tests (where to run what)
Tree |
Focus |
|---|---|
|
API, predictor–corrector, PDE/ODE “goldmine” style coverage. |
|
Smaller grids, accuracy, system shapes, no-placeholder regressions. |
|
SDE correctness, noise models, coupled dynamics. |
Example focused runs from repo root:
python -m pytest tests/test_solvers/ tests/solvers/ -q
python -m pytest tests/test_sde_solvers/ -q
For JAX-only utilities, add targeted tests (or subprocess import checks) if you change solvers_jax_utils — avoid assuming GPU.
9. Maintenance risks
Risk |
Mitigation |
|---|---|
|
|
Placeholder class proliferation |
Document in release notes when removing symbols; tests in |
Coupled solver semantics |
Do not “fix” silently: if physics changes, update module docstring, this file §1, and tests together. |
ML selector import failures |
Already caught; keep fail-soft behaviour so CI without full ML stack still runs ODE/SDE smoke tests. |
11. Sphinx / Read the Docs
hpfracc.solvers.solvers_jax_utilsis intentionally not run through.. automodule::indocs/api/solvers_api.rst: optional JAX / Diffrax stacks (and JAX version quirks such asprimitive_jvps) make autodoc brittle on minimal builders. Treat this file and the module docstring as the canonical export map.sphinx -W(warnings as errors): the default HTML build is kept strict viadocs/conf.py(narrowsuppress_warnings, large auxiliary Markdown trees excluded from the source set, sectionaldocs/api/*.rstautomoduledirectives marked:no-index:so the flatapi_referencepage owns the inventory, redundantautomethodstubs removed fromapi_reference.rst, and a few docstrings fixed so docutils does not treat|…|as substitution markup). Re-run locally aspython -m sphinx -b html docs docs/_build -W -q.