Skip to main content

Devito: Fast Stencil Computation from Symbolic Specification

Build Status for the Core backend Build Status with MPI Build Status on GPU Code Coverage Slack Status asv PyPI version Binder Docker

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.

About Devito

Devito provides a functional language to implement sophisticated operators that can be made up of multiple stencil computations, boundary conditions, sparse operations (e.g., interpolation), and much more. A typical use case is explicit finite difference methods for approximating partial differential equations. For example, a 2D diffusion operator may be implemented with Devito as follows

>>> grid = Grid(shape=(10, 10))
>>> f = TimeFunction(name='f', grid=grid, space_order=2)
>>> eqn = Eq(f.dt, 0.5 * f.laplace)
>>> op = Operator(Eq(f.forward, solve(eqn, f.forward)))

An Operator generates low-level code from an ordered collection of Eq (the example above being for a single equation). This code may also be compiled and executed

>>> op(t=timesteps, dt=dt)

There is virtually no limit to the complexity of an Operator -- the Devito compiler will automatically analyze the input, detect and apply optimizations (including single- and multi-node parallelism), and eventually generate code with suitable loops and expressions.

Key features include:

  • 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.

Installation

The easiest way to try Devito is through Docker using the following commands:

# get the code
git clone https://github.com/devitocodes/devito.git
cd devito

# start a jupyter notebook server on port 8888
docker-compose up devito

After running the last command above, the terminal will display a URL such as https://127.0.0.1:8888/?token=XXX. Copy-paste this URL into a browser window to start a Jupyter notebook session where you can go through the tutorials provided with Devito or create your own notebooks.

See here for detailed installation instructions and other options. If you encounter a problem during installation, please see the installation issues we have seen in the past.

Resources

To learn how to use Devito, here is a good place to start, with lots of examples and tutorials.

The website also provides access to other information, including documentation and instructions for citing us.

Some FAQs are discussed here.

Performance

If you are interested in any of the following

  • Generation of parallel code (CPU, GPU, multi-node via MPI);
  • Performance tuning;
  • Benchmarking operators;

then you should take a look at this README.

Get in touch

If you're using Devito, we would like to hear from you. Whether you are facing issues or just trying it out, join the conversation.

Interactive jupyter notebooks

The tutorial jupyter notebook are available interactively at the public binder jupyterhub.

Metadata

Release files for devito 4.8.23

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

Source distribution (sdist)

Source distribution for devito 4.8.23
File Size Uploaded
devito-4.8.23.tar.gz 36.3 MB Details

Built distribution (wheel)

Table of built distributions (wheels) for devito 4.8.23
File Interpreter ABI Platform
devito-4.8.23-py3-none-any.whl Python 3 none any Details

Total release size: 72.4 MB

Release files / devito-4.8.23.tar.gz

Download URL devito-4.8.23.tar.gz
Size 36.3 MB
Tags Source
SHA-256 checksum
How to use checksums
9d14c6f22a98fa805d540bcaddb83bffa40f7c6f045b00e42784567e2440e43a
BLAKE2b-256 checksum
How to use checksums
4e6f712e42686d7279af28f844236ff3b7a6599ba3c5793a02cf0ffca30143af
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.6

Release files / devito-4.8.23-py3-none-any.whl

Download URL devito-4.8.23-py3-none-any.whl
Size 36.1 MB
Tags Python 3
SHA-256 checksum
How to use checksums
de5e7ce9026edefe214295216ecc13e0592139c6942a02a4bbf93c3cc8910a3d
BLAKE2b-256 checksum
How to use checksums
9624574946e1bd59f96a2e4309cca18e0545c6531ac3e90f4364dfdf055e34e9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.6

Release history Release notifications | RSS feed

This release

4.8.23 This release

2 release files

4.8.22

2 release files

4.8.21

2 release files

4.8.19

2 release files

4.8.18

2 release files

4.8.17

2 release files

4.8.15

2 release files

4.8.14

2 release files

4.8.12

2 release files

4.8.11

2 release files

4.8.10

2 release files

4.8.9

2 release files

4.8.8

2 release files

4.8.6

2 release files

4.8.5

1 release file

4.8.4

1 release file

4.8.3

2 release files

4.8.2

2 release files

4.8.1

2 release files

4.8.0

2 release files

4.7.1

2 release files

4.7.0

2 release files

4.6.2

2 release files

4.6.1

2 release files

4.6

2 release files

4.5

2 release files

4.4

2 release files

4.3

2 release files

4.2.3

2 release files

4.2.2

2 release files

4.2.1

2 release files

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