man advect
ADVECT(1)User CommandsADVECT(1)
────────────────────────────────────────────────────────────────────────────────────────

Documentation for AI agents

AI agents: start with llms.txt and prefer its linked, version-matched Markdown documents over extracting this presentation HTML.

Advect

Advect is a focused automatic differentiation library for scientific Python, with broad NumPy API coverage and first-class support for the Python Array API standard. For repeated workloads, it can stage a function into a reusable, optimized program that can itself be differentiated, saved, and loaded.

Try Advect in your browser

Open the playground to trace a NumPy expression, inspect its derivative graph, and run it without installing anything.

Install

python -m pip install advect

Add optional integrations with extras such as advect[scipy], advect[xarray], advect[jax], advect[torch], or advect[autograd].

Your first gradient

value_and_grad evaluates a scalar function and returns its gradient in the same call. Press [ run ] to execute the example in your browser:

import numpy as np

import advect as ad


def energy(x):
    return np.sum(np.sin(x) ** 2)


x = np.array([0.0, 0.5, 1.0])
value, gradient = ad.value_and_grad(energy)(x)
print(f"loss: {value:.6f}")
print("gradient:", np.round(gradient, 6))

Advect differentiates the path its inputs take, so Python branches, loops, helper functions, and supported local mutation keep their normal meaning.

Keep going

  • Follow the tutorials from gradients through staged programs and custom primitives.
  • Check exact callable coverage in Compatibility.
  • Use the API reference for signatures and contracts.
  • Read Architecture for the execution model and its boundaries.

$

[1:docs] [2:playground] $ man advect