Devito: Symbolic Finite Difference Computation

Devito is a Python package to implement optimized stencil computation (e.g., finite differences, image processing, machine learning) from high-level symbolic problem definitions. Devito builds on SymPy and employs automated code generation and just-in-time compilation to execute optimized computational kernels on several computer platforms, including CPUs, GPUs, and clusters thereof.

Symbolic computation is a powerful tool that allows users to:

  • Build complex solvers from only a few lines of high-level code
  • Use automated performance optimisation for generated code
  • Adjust stencil discretisation at runtime as required
  • (Re-)development of solver code in hours/days rather than months

Seismic Inversion using Devito

Devito is primarily designed to create wave propagation kernels for use in seismic inversion problems. A tutorial for the generation of a modelling operator using an acoustic wave equation can be found here and a paper outlining the verification procedures of the acoustic operator can be found here.

True velocity model (Marmousi-ii)

Initial velocity model for FWI

FWI inverted velocity model


Key Features

  • A functional language to express finite difference operators.
  • Straightforward mechanisms to adjust the discretization.
  • Constructs to express sparse operators (e.g., interpolation), classic linear operators (e.g., convolutions), and tensor contractions.
  • Seamless support for boundary conditions and adjoint operators.
  • A flexible API to define custom stencils, sub-domains, sub-sampling, and staggered grids.
  • Generation of highly optimized parallel code (SIMD vectorization, CPU and GPU parallelism via OpenMP and OpenACC, multi-node parallelism via MPI, blocking, aggressive symbolic transformations for FLOP reduction, etc.).
  • Distributed NumPy arrays over multi-node (MPI) domain decompositions.
  • Inspection and customization of the generated code.
  • Autotuning framework to ease performance tuning.
  • Smooth integration with popular Python packages such as NumPy, SymPy, Dask, and SciPy, as well as machine learning frameworks such as TensorFlow and PyTorch.

(Disclosed) Software using Devito