core¶
core
¶
Base abstractions shared across DeltaFlow's models, losses, and solvers.
Every user-facing component (velocity field, interpolant, solver, loss) subclasses one of these bases, so new variants are drop-in and not rewrites of the surrounding machinery.
BaseInterpolant
¶
Bases: ABC
Base class for a probability path between noise x0 and data x1.
An interpolant defines, for each t in [0, 1], an intermediate point
x_t and its conditional target velocity u_t such that regressing
a model onto u_t (in expectation over the path) yields the marginal
velocity field of the flow-matching ODE.
Convention used throughout DeltaFlow: t = 0 corresponds to noise
(x_t = x_0) and t = 1 corresponds to data (x_t = x_1).
interpolate
abstractmethod
¶
Return (x_t, target_velocity) for the given data/time (and optional noise).
Source code in deltaflow/core/base_interpolant.py
BaseLoss
¶
Bases: ABC
Base class for a callable training loss.
Subclasses must implement __call__ and return a scalar tensor
with requires_grad=True (assuming the model has trainable
parameters). The signature is intentionally flexible - individual losses
define which positional and keyword arguments they consume.
BaseSolver
¶
Bases: ABC
Base class for numerical integrators of dx/dt = v_theta(x, t).
A solver holds a reference to a velocity model and exposes two methods:
stepperforms a single integration step from(x, t)to(x', t + dt). Subclasses implement the actual stepping rule.sampledrivesstepin a loop fromt_starttot_endand returns the final state.
Design note: PosteriorSolver
wraps a BaseSolver and hooks the likelihood gradient into every
call to step, so the base stepping logic is never duplicated.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model
|
Callable
|
callable |
required |
time_scale
|
float
|
multiplies the continuous |
1.0
|
Source code in deltaflow/core/base_solver.py
step
abstractmethod
¶
sample
¶
Integrate from t_start to t_end in n_steps uniform steps.
Source code in deltaflow/core/base_solver.py
BaseVelocityField
¶
Bases: Module, ABC
Base class for the time-conditioned velocity field v_theta(x, t).
Subclasses must implement forward and return a tensor with the
same shape as x. Any additional conditioning (e.g. a guidance flag,
class label, or cross-attention context) can be passed as keyword
arguments and is forwarded unchanged by the losses and solvers.