Skip to main content

Deepwave

DOI

Upgrading from v0.0.27? Deepwave 0.1.0 has breaking interface changes. The upgrading guide explains the changes and replacements, including output tuple indices that can change meaning without raising an error.

Deepwave provides wave propagation modules for PyTorch, for applications such as seismic imaging and inversion. It performs forward modelling and backpropagation, so it can simulate wave propagation to generate synthetic data, or invert for the scattering potential (reverse-time migration, RTM, or its least-squares counterpart, LSRTM), other model parameters (full-waveform inversion, FWI), initial wavefields, or source wavelets. It can also be used inside a larger chain of operations, with forward and backpropagation flowing through the whole chain end to end. You can use your own objective functions, or functions that generate the propagator's inputs, and PyTorch's automatic differentiation calculates how to backpropagate through them. New to seismic/wave-equation terminology? The glossary defines the terms (PML, CFL, Born, FWI, and more) used throughout this README and the rest of the documentation.

Deepwave requires Python 3.9 or later and PyTorch 2.4 or later. First install PyTorch for your CPU or CUDA device using the instructions on the PyTorch website. Then install Deepwave:

    pip install deepwave

macOS wheels support Apple Silicon. Intel Mac wheels are no longer provided: PyTorch 2.4 and newer do not publish wheels for that platform.

Prebuilt x86 wheels require AVX2. Older CPUs need a source build; see installation troubleshooting.

PyTorch is Deepwave's only dependency. The example scripts under docs/ additionally import matplotlib (to draw their figures) and, in some cases, numpy, scipy (smoothing and filter design), torchaudio (applying those filters), torchvision and geomloss, but those are needed only to run the examples, never by Deepwave itself. To install all of them:

    pip install 'deepwave[examples]'

The documentation contains examples and instructions on how to install and use Deepwave. You might also like to watch a video summary of Deepwave. Not every propagator supports every option (dimensionality, backend, boundary faces, batching, second-order differentiation, callbacks, ...). See the capability matrix (declared in the code and checked by conformance tests) before assuming a combination works.

Why Deepwave

  • Computationally efficient. Deepwave's compiled kernels use a hand-derived adjoint for better performance and lower memory requirements than pure PyTorch implementations. See what Deepwave calculates.
  • Second derivatives are supported, not just first. The scalar, acoustic, and elastic propagators can compute Hessian-vector products (derivatives of gradients); see the Hessian example.
  • Born (linearised) modelling. Model scattered waves from perturbations to a background medium for linearised inversion and imaging. See the torch.func example.
  • Deepwave fits into an ordinary PyTorch workflow. Because propagation is a normal PyTorch autograd Function, it works directly with PyTorch optimisers, DistributedDataParallel over shots, torch.func transforms, and any PyTorch loss function or neural-network model of the input parameters. See the capability matrix for exactly what each propagator supports.

Deepwave does not try to be a general symbolic PDE solver, a multi-node HPC code, or a non-differentiable simulation toolkit — see Devito, SPECFEM, and k-Wave respectively for those needs. If you are choosing between wave-propagation packages, see the comparison guide.

(Note: the DeepWave-KAUST GitHub organisation, home of the SWEEP package, is unrelated to this project.)

Features

  • Supports the 1D, 2D, and 3D constant density acoustic / scalar wave equation (regular and Born modelling), variable density acoustic, elastic, viscoacoustic (single-mechanism SLS attenuation), elastic VTI (anisotropic), and pseudo-acoustic VTI (deepwave.acoustic_vti, the Duveneck et al. 2008 V_S=0 reduction) wave equations
  • Runs on CPUs and appropriate GPUs
  • The gradient of all outputs (final wavefields and receiver data) can be calculated with respect to the model parameters (wavespeed, scattering potential, etc.), initial wavefields, and source amplitudes
  • Distributed acoustic sensing (DAS) strain-rate receivers (deepwave.das, including gauge averaging and helically wound fibre response) and transducer-array helpers for ultrasound/NDT (deepwave.transducers)
  • Segmented gradient checkpointing (deepwave.checkpointing.run_segments, composed with torch.utils.checkpoint) to bound backward-pass memory for long simulations
  • A time-dispersion correction (deepwave.time_dispersion) to remove the leapfrog time-stepping error when running near the CFL limit

Quick Example

This example also needs Matplotlib: python -m pip install matplotlib. On Python 3.9, also install "pyparsing<3.3" for compatibility with Matplotlib 3.9: python -m pip install "pyparsing<3.3". Newer Python versions can use the current Matplotlib and Pyparsing releases.

In a few lines you can make a velocity model, propagate a wave from a source in the top left corner to a receiver in the top right, calculate an objective function, and backpropagate to obtain its gradient with respect to the velocity.

import torch
import deepwave
import matplotlib.pyplot as plt

v = 1500 * torch.ones(100, 100)
v[50:] = 2000
v.requires_grad_()

out = deepwave.scalar(
    v, grid_spacing=4, dt=0.004,
    source_amplitudes=deepwave.wavelets.ricker(25, 200, 0.004, 0.06).reshape(1, 1, -1),
    source_locations=torch.tensor([[[0, 0]]]),
    receiver_locations=torch.tensor([[[0, 99]]]),
    pml_freq=25,
    max_vel=2000,
)

(out.receiver_amplitudes**2).sum().backward()

_, ax = plt.subplots(1, 3, figsize=(9, 3))
ax[0].imshow(v.detach())
ax[0].set_title("Velocity model")
ax[1].plot(out.receiver_amplitudes.detach().flatten())
ax[1].set_title("Receiver data")
ax[2].imshow(v.grad.detach(), vmin=-1e-5, vmax=1e-5)
ax[2].set_title("Gradient")
plt.show()

This objective measures receiver energy; an inversion instead compares predicted data with observations. max_vel and pml_freq fix the numerical setup. At this dt, CFL substepping makes the default model gradient a sampled approximation. For exact discrete model derivatives and finite-difference checks, see the gradient conditions.

(plt.show() only opens a window if a display is available. On a headless machine it does nothing and the script exits without complaint; replace it with plt.savefig("quick_example.png") to see the result in that case.)

(This example never moves anything to a GPU, so it runs on the CPU even if one is available; move v and the other tensors to a GPU with .to(device) to use it, as the quick start guide and the FWI example do.) Output from quick example

For a line-by-line walkthrough of this same example -- including what pml_freq and the other arguments mean -- see the quick start guide. There are more examples in the documentation.

Example notebooks

A few of the examples are also available as Jupyter notebooks (paired with their .py source via jupytext, so the two stay in sync -- see CONTRIBUTING.md) that you can run directly in Google Colab, no local install required (the first cell installs Deepwave):

Example Colab
Generated model (quickstart-style FWI) Open In Colab
Elastic FWI Open In Colab
Photoacoustic reconstruction Open In Colab
FWI recipes (OT, soft-DTW, deep image prior, UQ) Open In Colab

Citing

If you would like to cite Deepwave, I suggest:

@software{richardson_alan_2026,
  author       = {Richardson, Alan},
  title        = {Deepwave},
  year         = 2026,
  publisher    = {Zenodo},
  version      = {0.1.0},
  doi          = {10.5281/zenodo.3829886},
  url          = {https://doi.org/10.5281/zenodo.3829886}
}

Metadata

Release files for deepwave 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for deepwave 0.1.0
File Size Uploaded Provenance Actions
deepwave-0.1.0.tar.gz 1.2 MB Without provenance Details for deepwave-0.1.0.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for deepwave 0.1.0
File Interpreter ABI Platform Actions
deepwave-0.1.0-py3-none-win_amd64.whl Python 3 none Windows x86-64 Details for deepwave-0.1.0-py3-none-win_amd64.whl
deepwave-0.1.0-py3-none-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl Python 3 none Linux glibc 2.17+ x86-64, Linux glibc 2.28+ x86-64 Details for deepwave-0.1.0-py3-none-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
deepwave-0.1.0-py3-none-macosx_11_0_arm64.whl Python 3 none macOS 11.0+ ARM64 Details for deepwave-0.1.0-py3-none-macosx_11_0_arm64.whl

Total release size: 186.7 MB

Release files / deepwave-0.1.0.tar.gz

Download URL deepwave-0.1.0.tar.gz
Size 1.2 MB
Tags Source
SHA-256 checksum
How to use checksums
004da366e1df413e7cf4d6dbfca3900d94a703431ae3bd0b142b652a3c714d42
BLAKE2b-256 checksum
How to use checksums
b04f9b7af358d079e9ba39b56cb95b8361ef5bcfd8ae76d674923ca3a0cc0198
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.5

Release files / deepwave-0.1.0-py3-none-win_amd64.whl

Download URL deepwave-0.1.0-py3-none-win_amd64.whl
Size 42.4 MB
Tags Python 3 Windows x86-64
SHA-256 checksum
How to use checksums
d9f987224e2c6e6a9bd649e6de93ff3fd338725cea925ccdcfd9e7075f5a3f22
BLAKE2b-256 checksum
How to use checksums
71d9a4ec0b9522ffff7b81da64f430224a7f51c38a873781d11ae2347dca84b2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.5

Release files / deepwave-0.1.0-py3-none-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl

Download URL deepwave-0.1.0-py3-none-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Size 100.5 MB
Tags Linux glibc 2.17+ x86-64 Linux glibc 2.28+ x86-64 Python 3
SHA-256 checksum
How to use checksums
7d8c9e0a0cb87da9ab887074fbf63e764c607819bbe3735a32e67d450451ba6b
BLAKE2b-256 checksum
How to use checksums
e414f74138c2721d4fe7900aa81d06139c1aa6c31b3267134c3c02fdb3780d46
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.5

Release files / deepwave-0.1.0-py3-none-macosx_11_0_arm64.whl

Download URL deepwave-0.1.0-py3-none-macosx_11_0_arm64.whl
Size 42.7 MB
Tags Python 3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
a7ef57637e82203afa3391fd86653319863584ce6fd10af15ce336b9a30aa5f5
BLAKE2b-256 checksum
How to use checksums
ff6f6f577514acdd40fffdace7029898457e4f98f2a05c30173005e0c110cbb8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.5

Security for deepwave 0.1.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.

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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page