Skip to content

Getting started

One install gets you the whole stack. Pick the entry point that matches how you want to work — Python, or plain language.

Install

pip install sweepx

That pulls the engine (sweep-solver) and the toolkit built on it: the YAML task runner (sweepx.tasks), the losses, networks, optimizers and I/O it uses (sweepx.loss, sweepx.nn, sweepx.opt, sweepx.io) and the natural-language layer (sweepx.agent). The engine imports as sweep (the name sweep was taken on PyPI, hence sweep-solver), the toolkit as sweepx.<module>:

import sweep
import sweepx.tasks
print(sweep.__version__, sweepx.__version__)

Python 3.10+. The wheel ships a prebuilt CUDA core, so the native-CUDA backend (impl='c') runs straight after install with any PyTorch version: no nvcc, no compile step, just an NVIDIA GPU and driver. The pure-Python torch / JAX backends need nothing else.

import sweep
print(sweep.is_torch_binding_available())   # torch + CUDA GPU + a fitting core?

Your first forward model

import numpy as np, torch
from sweep.equations import Acoustic
from sweep.propagator.torch import PropTorch
from sweep.signal import ricker

dev    = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
solver = PropTorch(Acoustic(device=dev), shape=(96, 128), dh=10.0, dt=2e-3, device=dev)

wavelet   = ricker(np.arange(600) * 2e-3 - 0.12, f=10.0).astype(np.float32)
sources   = np.array([[64, 2]], dtype=np.int64)
receivers = np.array([[[ix, 4] for ix in range(0, 128, 2)]], dtype=np.int64)
vp        = torch.full((96, 128), 2000.0, device=dev)   # (nz, nx)

gather = solver(wavelet, sources, receivers, models=[vp])   # (1, nt, nrec, 1)

Your first gradient

Every propagator call is an autograd node, so inversion is ordinary PyTorch. Record data for a model with a faster box, then take the gradient of the misfit at the constant model:

vp_true = vp.clone()
vp_true[48:58, 32:96] = 2300.0
with torch.no_grad():
    obs = solver(wavelet, sources, receivers, models=[vp_true])

vp   = vp.clone().requires_grad_(True)
pred = solver(wavelet, sources, receivers, models=[vp])
loss = 0.5 * (pred - obs).pow(2).sum()
loss.backward()          # vp.grad is a plain torch Tensor — feed any optimizer

…or say it in plain language

sweepx.agent turns a sentence into a validated run, driven by a local LLM (Ollama on a Mac, vLLM on a GPU node):

sweep-agent chat
>>> load the Marmousi benchmark model and run a forward — show the shot gather

Where to go next

  • Solver


    Equations, propagators, backends, boundary-saving — and over thirty runnable notebooks under Examples.

  • Tasks


    Production FWI / LSRTM from one YAML file: specs, CLI, multi-GPU, data IO.

  • Loss


    Misfit functions for inversion — L2 to envelope, phase and optimal transport.

  • NN


    Implicit FWI: the model as a network — SIREN, hash encoding, priors.

  • IO


    SEG-Y to gathers: header index, data plans, prefetched reads, models, geometry.

  • Opt


    FWI optimizers: L-BFGS, truncated Newton / Gauss-Newton, Adam, Shampoo / SOAP, preconditioners.

  • Agent


    Tools, the web UI, and how to point it at any OpenAI-compatible LLM.

  • API reference


    Every equation, propagator, and operator, documented from source.