DeepGPR
Official website / documentation: https://songc0a.github.io/DeepGPR/
DeepGPR provides a wave propagation module for PyTorch, designed for applications such as Ground Penetrating Radar (GPR) imaging and inversion. Its core concepts are derived from Deepwave. You can use it to perform both forward modeling and backpropagation—thereby enabling the simulation of wave propagation to generate synthetic data—as well as for Full Waveform Inversion (FWI). Furthermore, you can integrate this wave propagation functionality into a larger operational pipeline—incorporating various wavelets, loss functions, and other components—to achieve end-to-end forward and reverse propagation, powered by automatic differentiation and our high-performance operators.
Features
- 2D and 3D forward modeling of Maxwell's equations with the Finite-Difference Time-Domain (FDTD) method, for single and multiple excitations.
- Gradients of the receiver data with respect to relative permittivity, conductivity, the initial wavefield and the source amplitudes, computed by an exact discrete adjoint.
- Automatic extension of the physical model into a CPML with an independent thickness on every face. Supply only air and the target region; sensitivities from replicated PML materials are summed back to the input model edges. Absorption uses a fixed
pml_max_velocityreference (vacuum light speed by default). - CUDA GPU backend and a C/OpenMP CPU backend (selected automatically with
device='cpu'). - Spatial FDTD order 2, 4 or 8 (
fdtd_order), and gradient mode 2 (Ez only) or 3 (Ex, Ey, Ez). - Large models: checkpointing, DDP, temporal sub-sampling (fixed or
"auto"from the source spectrum), E-only float32 histories (default; half the memory of E+R), FP16/BF16 or GPU-native INT8 wavefield histories and asynchronous offload to host memory. Material gradients with PML requirewavefield_history_region="extended"; physical-only histories remain available for diagnostics, source/initial-state gradients and models without PML. Seedocs/API.md§4.3-4.6.
System requirements
- OS: Linux, Windows and macOS for CPU execution; Linux and Windows for CUDA execution
- Python: 3.8+
- Libraries:
torch,numpy,matplotlib(the examples additionally usescikit-image) - Hardware: an NVIDIA GPU with sufficient memory for CUDA execution; CPU execution works without a GPU
Installation
Install a PyTorch build for your platform first (pytorch.org): a CUDA-enabled build for GPU use, or a CPU build. Then
pip install DeepGPR # runtime
pip install "DeepGPR[examples]" # + scipy, scikit-image, jupyter for the notebooks
For development from a clone:
pip install -e ".[dev,examples]"
The prebuilt native libraries ship in src/DeepGPR/lib. To rebuild them see docs/BUILDING.md.
Quick start: a small forward-modeling test
import torch
import matplotlib.pyplot as plt
import DeepGPR
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
dx = 0.02 # or [dx, dy, dz], for example [0.02, 0.015, 0.01]
dt = 3e-11
nt = 2000
eps_r = torch.ones(100, 100, 1) * 2
eps_r[50:, :] = 5
sigma = torch.zeros_like(eps_r)
eps_r.requires_grad_()
source_location = torch.tensor([[[10, 10, 0]]], device=device, dtype=torch.int)
receiver_location = torch.tensor([[[10, 90, 0]]], device=device, dtype=torch.int)
freq = 2e8
source_amplitudes = torch.zeros((1, nt, 1), device=device)
source_amplitudes[0, :, 0] = DeepGPR.wavelet.ricker(freq, nt, dt, 1 / freq, device=device)
E_saved, E, H, pml_state, receivers = DeepGPR.compute(
device=device, dx=dx, dt=dt,
source_amplitudes=source_amplitudes,
source_location=source_location,
receiver_location=receiver_location,
eps_r=eps_r, sigma=sigma,
fdtd_order=2,
)
receivers.square().sum().backward()
fig, ax = plt.subplots(1, 2, figsize=(10, 3))
DeepGPR.visualization.plot_trace(receivers[0, :, 0], dt=dt, ax=ax[0], title="Receiver data")
DeepGPR.visualization.plot_model(eps_r.grad, ax=ax[1], title="Gradient", cmap="seismic")
plt.show()
More examples are in examples/ (forward modeling, 2D FWI, 3D FWI).
Source wavelets
Wavelets live in DeepGPR.wavelet. Every function returns a one-dimensional
tensor and accepts optional dtype and device arguments.
ricker = DeepGPR.wavelet.ricker(freq, nt, dt, peak_time, device=device)
gaussian = DeepGPR.wavelet.gaussian(freq, nt, dt, peak_time, device=device)
derivative = DeepGPR.wavelet.gaussian_derivative(freq, nt, dt, peak_time, device=device)
morlet = DeepGPR.wavelet.morlet(freq, nt, dt, peak_time, cycles=3.0, device=device)
burst = DeepGPR.wavelet.sine_burst(freq, nt, dt, peak_time, cycles=3.0, device=device)
DeepGPR.ricker(...) remains available as a backward-compatible alias.
Full-waveform inversion results
The figures show the true model, the initial model and the inverted result.
2D FWI
| True model | Initial model | Inverted result |
|---|---|---|
3D FWI (central slice)
| Model | Central slice |
|---|---|
| True model | |
| Initial model | |
| Inverted result |
API overview
| Function | Purpose |
|---|---|
DeepGPR.compute(...) |
FDTD forward modeling with autograd (full reference: docs/API.md) |
DeepGPR.checkpoint_initial_field(...) |
zero E/H/CPML states for segment-wise (checkpointed) runs |
DeepGPR.wavelet.* |
source wavelets |
DeepGPR.TVRegularization |
total-variation penalty for εr and σ ("anisotropic", "isotropic") |
DeepGPR.apply_filter, DeepGPR.hilbert_transform |
low-pass FIR and envelope for multi-scale FWI |
DeepGPR.max_stable_time_step(...) |
largest CFL-stable dt for a grid, order and material |
DeepGPR.estimate_compute_memory(...) |
memory estimate (also printed by print_parameters=True) |
DeepGPR.recommended_sampling_interval(...), DeepGPR.source_max_frequency(...) |
gradient sampling interval bound floor(1 / (4 f_max dt)) from a source waveform (what model_gradient_sampling_interval="auto" uses) |
DeepGPR.decompress_wavefield_history(...) |
decode a packed INT8 history for diagnostics |
DeepGPR.visualization.plot_* |
models, radargrams, traces, true/initial/inverted comparison |
DeepGPR.configure_logging(level) |
enable DeepGPR log output |
Logging and errors
DeepGPR logs through the standard logging module under the DeepGPR
logger and never configures the root logger. Enable console output with
DeepGPR.configure_logging("INFO") # or "DEBUG" for per-call solver details
Errors raised by the package derive from DeepGPR.DeepGPRError and from the
built-in type used before 0.1.0, e.g. DeepGPR.CFLConditionError is also a
ValueError and DeepGPR.NativeLibraryError is also a RuntimeError.
Failures inside the native CPU/CUDA code (allocation, CUDA API or launch
errors) are raised as NativeLibraryError with the native message.
Project structure
src/DeepGPR/
├── __init__.py public API
├── _version.py package version
├── config/ physical constants, native ABI codes, API defaults
├── native/ library loader, declarative C ABI table, ctypes bridge
├── preprocessing/ input validation, grid/PML normalisation, CFL, wavelets
├── solver/ CPML, field state, history storage, autograd bridge, compute()
├── postprocessing/ FIR filter, envelope, forward-wavefield files
├── inversion/ TV regularisation
├── visualization/ matplotlib helpers
├── utils/ logging, exceptions, validators, diagnostics
├── lib/ deepgpr.cu, deepgpr_cpu.c, deepgpr.h and prebuilt binaries
├── common.py, compute2.py, multiscale.py, wavelet.py compatibility modules
docs/ API reference, build guide, changelog, manifest and Fig/
examples/ forward, 2D FWI and 3D FWI notebooks
tests/ unit tests, verification notebooks, benchmarks
website/ static pages, assets, scripts/, tools/ and promo_pixel/
Data flow of one compute call:
preprocessing.model_setup.initialization (validate, CFL, extend into CPML) →
solver.pml (CPML coefficients and state) → solver.autograd.DeepGPR
(native forward; native adjoint on backward) → receiver data, final states
and the saved history.
Tests and verification
python -m unittest discover -s tests -p "test_*.py" # unit tests
python -m unittest tests/test_native_abi.py # ABI check, no PyTorch needed
python tests/run_notebook.py tests/00_local_backend_and_contracts.ipynb
python website/tools/verify_equivalence.py --no-pml --reference-src /path/to/DeepGPR-0.0.20/src/DeepGPR
bash website/tools/run_local_validation.sh /path/to/DeepGPR-0.0.20 # rebuild CPU+CUDA libs, run everything
Run the notebooks 00 to 09 in numeric order, followed by
99_verification_summary.ipynb. See tests/README.md for
the complete matrix and CUDA options.
Reproducibility. The CPU backend gives bitwise identical forward results
and gradients for any OMP_NUM_THREADS. On CUDA, 2D Ez-TM runs (the 2D fast
path) gather their adjoint without atomics and are bitwise reproducible; the
general (3D) CUDA adjoint accumulates with atomics and can differ in the last
bits between runs.
Reproducing results from DeepGPR ≤ 0.0.20. 0.1.0 corrects the FIR design
for even filter lengths, the envelope for odd trace lengths and the isotropic
TV (see docs/CHANGELOG.md). Use apply_filter(..., legacy=True),
design_fir_filter(..., legacy=True), hilbert_transform(..., legacy=True)
and TVRegularization(method="legacy_isotropic") to reproduce earlier numbers.
Development
- Code style: PEP 8, enforced with
ruff check src/DeepGPR website/tools docs/build_support.py(configuration inpyproject.toml). - Type hints throughout;
mypyconfiguration inpyproject.toml. - Changes are recorded in
docs/CHANGELOG.md; known issues and recommended native work indocs/AUDIT.md. - Changes to
lib/deepgpr.hmust be mirrored insrc/DeepGPR/native/abi.py;tests/test_native_abi.pyenforces it.
Citation
If you find our code useful, please cite:
@article{liu2026fast,
title = {Fast ground penetrating radar dual-parameter full waveform inversion method accelerated by hybrid compilation of CUDA kernel function and PyTorch},
author = {Liu, Lei and Song, Chao and He, Liangsheng and Wang, Silin and Feng, Xuan and Liu, Cai},
journal = {Computers \& Geosciences},
pages = {106101},
year = {2026},
publisher = {Elsevier}
}
License
MIT — see license.
Metadata
Release files for DeepGPR 0.1.3
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 |
|---|---|---|---|---|
| deepgpr-0.1.3.tar.gz | 9.4 MB | Without provenance | Details for deepgpr-0.1.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| deepgpr-0.1.3-py3-none-any.whl | Python 3 | none | any | Details for deepgpr-0.1.3-py3-none-any.whl |
Total release size: 18.7 MB
Release files / deepgpr-0.1.3.tar.gz
| Download URL | deepgpr-0.1.3.tar.gz |
|---|---|
| Size | 9.4 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
311d1ae7851fad334c069ab2f3e84990e6171220dd37f1612aa30ce3784328bd
|
|
BLAKE2b-256 checksum How to use checksums |
9620eb6e1d534c51f717744b95bbb520be618383e068225d0d367226ea4764ee
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.10.20
|
Release files / deepgpr-0.1.3-py3-none-any.whl
| Download URL | deepgpr-0.1.3-py3-none-any.whl |
|---|---|
| Size | 9.3 MB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
48473933075c18633fe04ee6f85cd2ad0e8fc10879059a3c0e7a1872299ebd33
|
|
BLAKE2b-256 checksum How to use checksums |
980c793cd77ede5a375434a874bffcdb922eb9e1fb52ded1d8066a7a1c4cf7cd
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.10.20
|
Security for DeepGPR 0.1.3
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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A 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.