Skip to content

Derivative sources

For PDE discovery, KD computes derivatives from observed field values using finite differences on a grid or automatic differentiation through a neural network that represents the field. Tabular regression fits a target column without derivatives.

Finite differences

Central-difference stencils applied directly on the grid. Every derivative is computed once before the search starts, and every later use is a lookup.

  • First- and second-order derivatives use fourth-order accurate stencils; third-order uses a second-order accurate one. Atomic derivatives are supported up to third order.
  • Periodic axes use a wrap-around stencil, so boundary points keep the interior accuracy; non-periodic axes fall back to reduced-order formulas at the boundary.
  • Coordinates must be increasing and evenly spaced.

Automatic differentiation

A neural network is trained to map coordinates to field values, and PyTorch autograd differentiates that network. The derivatives are exact for the trained network, so they are not bounded by a stencil's order and they need not be evaluated at the original grid points. The price is one extra training run.

Surrogate network sources

Three things can supply the network that gets differentiated:

  • Trained by the platform: an algorithm declares that it needs a surrogate network, and the platform trains one and wires it in with nothing required from you. This is DLGA-PDE's route.
  • Trained by the algorithm: under derivatives="autograd", SGA-PDE trains its own surrogate network and uses it for the terminal derivatives (u_x, u_t), while derivative operators inside the expression tree still go through the dataset's finite differences.
  • Supplied by you: kd.Model(algorithm="dlga", surrogate_model=...) takes an already-trained torch.nn.Module and the platform skips its own training. The parameter applies to DLGA-PDE only.

Derivative source per algorithm

Every mode of every algorithm declares its derivative source in kd.instrument_schemas():

import kd

for schema in kd.instrument_schemas():
    for mode in schema["modes"]:
        print(f"{schema['algorithm']:9s} {mode['name']:15s} {mode['provider_kind']}")
sga       default         finite_diff
sga       autograd        autograd
dlga      default         autograd
discover  mode1           finite_diff
discover  mode2           autograd
discover  tabular         none
pysr      default         finite_diff
pysr      tabular         none
eqgpt     single_wave     finite_diff
eqgpt     wave_multicase  none
eqgpt     steady          none
llm4ed    default         finite_diff
pysindy   default         finite_diff
pysindy   tabular         none

DLGA-PDE differentiates through a network. The PDE modes of DISCOVER, PySR and PySINDy use finite differences, as do LLM4ED and EqGPT's single-case wave mode; SGA-PDE offers both and defaults to finite differences. DISCOVER, PySR and PySINDy also have tabular regression modes, which fit a target column without derivatives and report none. EqGPT's multi-case wave mode and steady mode report none: they take no derivatives from the platform and build their own field representation and evaluation internally.

Configurable options

  • How SGA-PDE differentiates: kd.Model(algorithm="sga", derivatives="autograd") switches the terminal derivatives to autograd. On a regular, well-resolved grid the default finite differences are computed once and cost you no training run; choose autograd when you want the derivatives to come from a continuous representation of the field.
  • DLGA-PDE's surrogate network: by default the platform trains it from the surrogate settings in kd.DLGAConfig. If you already have a trained field network, pass it through surrogate_model= and that training is skipped.

The other modes have a fixed derivative source. For what the data itself must look like, see data requirements.