Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Protocols: the plug-in seam

pipekit’s interoperability story is structural: algorithm and domain libraries plug in by satisfying a Protocol, never by inheriting from a pipekit base class or importing pipekit at all. Every protocol except pipekit-train’s Callback (whose hooks are all optional) is @runtime_checkable, so isinstance(obj, ForwardModel) succeeds on any structurally compatible class, and adapters in filterax, vardax, geotoolz and xrtoolz stay dependency-free.

This page is the inventory: what each protocol is for, where it lives, and who satisfies it.

Core (pipekit_ops.core)

Carrier-agnostic seams for model-inference wrappers.

ProtocolContractSatisfied by
Predictorpredict(x)scikit-learn estimators, Keras models, geotoolz GeoTensorEstimator, xrtoolz XarrayEstimator
FittableTransformerfit(x) + transform(x)scikit-learn transformers, the carrier-aware sklearn wrappers in geotoolz / xrtoolz

Models invoked via bare __call__ (PyTorch modules, JAX functions) are covered by callable(model); a __call__-only Protocol would match nearly everything, so pipekit deliberately doesn’t define one.

Carriers and stores (pipekit_ops.carriers, pipekit_ops.saving)

ProtocolContractSatisfied by
NamedArrayAdapterdims(x), data(x), labels(x, dim), rewrap(…), … per carrier familypipekit-array’s DimArrayAdapter and xarray adapter, or a carrier library’s own; registered with register_adapter
LabelledAdapterrelabel(x, labels)adapters that can set the labels of new or renamed dims (optional)
ConvertingAdapterto_backend(x, backend)adapters whose carriers have more arrays than their data (optional)
MissingValueAdapterkeep_missing(out, *inputs)adapters whose carriers mark missing elements in their data, such as a fill value (optional)
Storekey in store, load(key), save(key, value)MemoryStore, DirectoryStore; where a Cache(op, store=name) keeps its entries

Data assimilation (pipekit_cycle.protocols)

The standard-form triple

ProtocolContractRole
ForwardModelstep(state, dt), dt, state_signatureAdvance the state (predict)
ObservationOperator__call__(state), linearize(state)State → predicted observations (compare)
AnalysisStep__call__(forecast, obs, *, obs_op, obs_err_cov)Forecast + observations → analysis (update)

vardax exposes every Layer-2 method (OI, 3D-Var, strong/weak/incremental 4D-Var, FourDVarNet, amortized posteriors) as an AnalysisStep via .as_analysis_step(); its observation operators (LinearObs, MaskedIdentity, AveragingKernel) satisfy ObservationOperator directly.

Reduced-order seams

ProtocolContractRole
ReducedBasisoperg(t, X, state), prior_inv(X), nbasisReduced control basis with a prior (4D-Var on SSH, …)
TangentLinearModeltangent(state, dx, dt), adjoint(state, dz, dt)Explicit M′ / M* of the dynamics
ErrorSubspacepropagate(model, state, dt), modes, rankPropagating low-rank covariance factor (SEEK / SEIK)
ReducedOrderModelencode, decode, step(coords, dt), latent_dimGalerkin ROM: projection maps + latent dynamics
LatentMapencode(state), decode(coords)The stateless subset of ReducedOrderModel, what latent-space filters and autoencoder priors need

Ensemble-method seams

ProtocolContractRole
ObservationNoisecovariance(), sample(key, shape)Error model usable by both deterministic and stochastic analyses
CovarianceLocalizer__call__(covariance, coords)Distance-based covariance tapering (Gaspari-Cohn, …)
EnsembleInflator__call__(particles, forecast_particles=None)Post-analysis inflation (multiplicative, RTPS / RTPP, additive)

filterax’s AbstractNoise, AbstractLocalizer, and AbstractInflator hierarchies satisfy these structurally.

Iterative-inversion seams

ProtocolContractRole
IterativeProcessinit(particles, obs, noise_cov), update(state, forward_evals)Ensemble Kalman inversion / sampling (EKI, EKS, UKI)
StepSchedulerget_dt(state)Pseudo-time step policy for the process loop

Differentiation seam

ProtocolContractRole
SupportsAdjointadjoint, with_adjoint(spec)A rollout component that says how gradients flow through it, with a spec from pipekit_cycle.cycles; integrix.adjoint.to_diffrax_adjoint and integrix.adjoint.truncated_scan interpret it

Experiment tracking (pipekit_experiment.protocols)

ProtocolContractSatisfied by
ExperimentTrackerstart_run, log_metrics, log_artifact, end_runyour own adapters and ad-hoc writers; none ships yet (the [mlflow] and [wandb] extras only pin those libraries)
MetricWriterwrite(step, metrics), close()pipekit_experiment.JSONLWriter (re-exported by pipekit-train) and FanoutWriter, your own writers; TrainingLoop and sesmax-experiment’s run record write to it
ModelRegistrystore, load, load_weights, list, tagLocalModelRegistry, S3ModelRegistry

Training (pipekit_train)

ProtocolModuleContract
Losspipekit_train.lossesCarrier-agnostic loss callable
Callbackpipekit_train.loopTraining-loop hook points
MetricWriterpipekit_train.loopMetric sink, re-exported from pipekit_experiment (pipekit_experiment.JSONLWriter is the reference impl)

Benchmarking (pipekit_evaluate.benchmark, and Estimate, CovarianceEstimate and Scorer in pipekit_evaluate.scoring)

ProtocolContractRole
Priorsample(n, key), log_prob(theta)Prior over task parameters θ
Taskname, domain, prior(), simulator(), observation_operator(), datasets()One benchmark scenario; reuses ForwardModel / ObservationOperator as its simulator
Estimatepoint(), sample(n, key), log_prob(theta)A point and/or posterior produced by an estimator
CovarianceEstimateEstimate + covariance()An estimate that reports its posterior covariance, for coverage and spread scorers
Estimatorrung, complexity, fit(task), __call__(obs)Any rung mapping observations → an Estimate
Oraclereference_for(task)The designated reference estimator for a task
Scorername, __call__(prediction, reference); optional unit, lens, stages, differentiable tags, read by tags_ofOne (Unit, Lens) scorer, returning named metric values

Conventions