Run seismic inversion on Chalk GPUs
This demo shows how to run Deepwave on a Chalk GPU to recover a velocity model from synthetic seismic shots. Change the starting blur to try it, then explore the code to see how it works.
Compare the reconstructed model with the known answer
The recorded inversion starts blurred and uses synthetic observations generated from the true model.
Try this experiment · expected results
1Compare the first and last iterations
Pause and scrub the recording; compare the large reconstructed image with the starting and true models below it.
Expected: Geological structure emerges as the simulated observations fit better.
2Inspect the fit, then vary one input
Read the misfit curve and change shot count or starting blur for a live run.
Expected: Lower misfit describes this synthetic reconstruction; compare both the image and the curve.
How far the simulated shots are from the observed ones, relative to the starting model at the same frequency. Each stage starts again at a higher frequency, so the misfit jumps before it falls.
The observed shots are simulated through the true model with the same acoustic wave equation, the textbook setup for testing an inversion; field data adds noise, elastic effects and an unknown source. The model is a 9 km × 3.5 km window of the AGL Elastic Marmousi (Marmousi2) P-wave velocity by Martin, Wiley and Marfurt, © 2004 Allied Geophysical Laboratory, University of Houston, CC BY 4.0, resampled to 25 m. The recorded run is the stream the button produces, saved from the deployed API. Timings cover the inversion after observed shots have been cached at startup.
Built on Chalk
Deepwave simulates acoustic waves and differentiates the misfit; PyTorch updates the velocity model. Chalk packages this workload, runs it on an L4 and serves the progress API.
Run PyTorch on an L4
Chalk deploys the Deepwave application on an NVIDIA L4 with four CPUs and 16 GiB of memory.
Prepare the image and data
The Python image definition installs Deepwave on a PyTorch CUDA image and downloads Marmousi2 at build time. Chalk packages that runtime for the replica.
Check the solver before serving
The application completes a short inversion at startup. Chalk waits for its status endpoint before routing traffic to the replica.
Follow the inversion
The example server streams misfit and velocity updates as JSON lines. Chalk exposes the endpoint so the browser can display progress during the solve.
The same code produces closely matching misfit after 30 iterations on each device. One L4 runs the inversion about 75 times faster than 32 cores of a Xeon Platinum 8468V, and an H100 about 110 times. Each iteration steps the wave equation 1,250 times over all 50,760 cells, forward and back, for every shot: bandwidth-bound stencil work that a GPU runs in parallel. The 4-core run was stopped after 30 iterations.
Run it on your own
You need uv, Chalk credentials, and an environment that can schedule an L4. The image definition installs Deepwave and downloads the Marmousi2 data; the application warms up the solver before its readiness check passes.
The snippets show the inversion and deployment pattern. Adapt the survey geometry, wavelet, starting model and data loader for your own experiment. Set URL to your deployed service before running the API example.
import json, httpx
params = {"shots": 20, "iterations": 120, "start_blur_m": 250}
with httpx.stream("POST", f"{URL}/api/run", json=params, timeout=None) as r:
for line in r.iter_lines():
msg = json.loads(line)
if msg["type"] == "step" and "velocity" in msg:
print(f"iteration {msg['iteration']:4d} {msg['stage_hz']:4.0f} Hz"
f" misfit {msg['misfit']:6.3f} wall {msg['wall_s']:6.1f}s")
# iteration 40 4 Hz misfit 0.009 wall 10.0s
# iteration 80 7 Hz misfit 0.002 wall 20.1s
# iteration 120 10 Hz misfit 0.001 wall 30.2sImage the subsurface on demand
Inversion, migration or seismic interpretation models: talk to an engineer about running your geophysics on GPUs in your own cloud.