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.

pipekit-train — quickstart

Open In Colab

End-to-end MLP training on a synthetic 1-D regression task. This is the minimal “Hello, training!” for pipekit-train v0.1 — it shows the four pieces that compose into a working training run:

  1. A TrainingDataset that yields (input, target) pairs.

  2. A Loss Operator (MSE here).

  3. A model Operator — wrap an eqx.Module in EquinoxModelOp.

  4. A TrainingLoop that ties them together and calls pipekit_train.backends.equinox.run under the hood.

TrainingLoop.run() returns (trained_model_op, artifact). The trained operator drops into any inference pipeline; the artifact captures everything needed to reproduce the run.

Python implementation: CPython
Python version       : 3.12.3
IPython version      : 9.10.0

numpy        : 2.4.4
jax          : 0.10.1
equinox      : 0.13.8
optax        : 0.2.8
pipekit      : 0.0.1
pipekit_train: 0.0.1

Compiler    : GCC 13.3.0
OS          : Linux
Release     : 6.18.5
Machine     : x86_64
Processor   : x86_64
CPU cores   : 4
Architecture: 64bit

1. The synthetic task

y = 2x + 1 + small noise — small enough to converge in seconds.

<Figure size 600x300 with 1 Axes>

2. Wrap as a TrainingDataset

IterableDataset is the generic escape hatch. For datasets that come from a pipekit_cycle.ForwardModel, use SimulationDataset (covered in the cycle-handoff notebook). For catalog-backed sources, CatalogDataset will ship in v0.1.x once geocatalog publishes.

3. The model

A tiny Equinox MLP. We wrap it in EquinoxModelOp so it’s a pipekit_ops.Operator — same surface as every other pipekit primitive. (When pipekit-jax.JaxModelOp ships, it’s a drop-in replacement.)

4. The training loop

TrainingLoop is a pipekit_ops.StatefulOperator. We supply the model, dataset, loss, and an optimiser config; the Equinox adapter handles the rest. MetricWriter is optional — useful for inspecting the loss curve afterwards.

Run it. The first call compiles train_step via eqx.filter_jit (a few hundred ms on CPU); subsequent steps reuse the compiled function.

Backend       : equinox
Final step    : 200
Final loss    : 0.001485
Dataset hash  : 1018572d5647a58a…
Total seconds : 1.67

5. Inspect the loss curve

<Figure size 600x300 with 1 Axes>

6. Use the trained model

trained_op is a pipekit_ops.Operator. It composes into any Sequential; calling it directly works too.

<Figure size 600x300 with 1 Axes>

7. The artifact

TrainingArtifact is the reproducibility record. Save it to JSON and the run is recoverable — pin a ModelRegistry and even the weights round-trip.

Saved artifact.
Contains: training_pipeline_yaml (606 chars)
          dataset_hash:    1018572d5647a58a…
          backend_info:    ['backend', 'jax_version', 'equinox_version', 'optax_version', 'devices', 'total_seconds', 'final_step', 'final_metrics']
          deps_lock:       3876 chars

What’s next

  • Cycle handoff — train an emulator on a pipekit_cycle.ForwardModel and drop it back as a NeuralForward (see the companion notebook).

  • Custom callbacks — implement any of the five on_train_begin / on_step_end / on_epoch_end / on_eval_end / on_train_end hooks; the adapter dispatches via getattr.

  • Experiment trackers — LogToExperiment(tracker=…) bridges to any pipekit_experiment.ExperimentTracker (MLflow, W&B, …).