feat(train): make ValidationStep the loop's evaluator, or remove it

Abierto
#154 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
4/5
Tiempo estimado
3-5 días
Aptitud para principiantes
55/100
Tipo de issue
Nueva funcionalidad
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
python

Línea de trabajo

Read packages/pipekit-train/src/pipekit_train/loop.py for ValidationStep and TrainingLoop, then inspect _evaluate and the periodic and final evaluation paths in packages/pipekit-train/src/pipekit_train/adapters/equinox.py. First resolve the dependency on #122 and decide whether to wire in ValidationStep or remove it based on #125. Done means the chosen API behavior, backend handling, documentation, and listed tests are complete.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

area:code priority:p2 type:feature

Problem / Request

Either make ValidationStep the evaluator a TrainingLoop can actually use, or remove it.
ValidationStep is exported and documented, but no loop or adapter calls it.
Validation in the Equinox adapter goes through _evaluate, which can only report what loss_fn puts in its aux dict.

User Story

As a pipekit-train user, I want to name validation metrics that are not part of my loss, so that I can track them during training without writing a custom TrainTask.

Motivation

The class implies a capability that the loop does not have.
Today a metric that isn't in the loss needs a custom task, or a callback that re-runs the model itself.

Proposed API

# proposed (this issue); my_metric is a user Operator of (predicted, target)
TrainingLoop(
    model_op=op,
    dataset=train,
    validation=ValidationStep(op, val, metrics=(MSE(), my_metric)),   # instead of val_dataset=
    eval_every_n_steps=500,
)

# in the adapter, on each eval round
metrics = loop.validation.with_model(trained_op)()   # today*: ValidationStep._apply
_dispatch(loop.callbacks, "on_eval_end", loop, carry, metrics)
  • validation and val_dataset are mutually exclusive, and setting both raises ValueError.
  • with_model(op) returns a copy bound to the current weights, because the constructor fixes model_op.

Design Snapshot

ValidationStep today, from packages/pipekit-train/src/pipekit_train/loop.py @ 7c446f1:

def _apply(self) -> dict[str, float]:
    sums: dict[str, float] = {}
    count = 0
    for x, y in self.dataset:
        predicted = self.model_op(x)          # one sample at a time, eagerly
        for metric in self.metrics:
            result = metric(predicted, y)
            ...
        count += 1
    return {k: v / count for k, v in sums.items()}

It runs eagerly per sample, so it is slower than the jitted batched path of #122.

Recommended: wire it in as above, as the simple path for metrics that are means over samples.
Alternative: if #125's eval_fn covers these users, remove ValidationStep from the public API and close this issue as not planned; decide this once #125 lands.

References & Existing Code

  • ValidationStep in packages/pipekit-train/src/pipekit_train/loop.py @ 7c446f1.
  • _evaluate in packages/pipekit-train/src/pipekit_train/adapters/equinox.py @ 7c446f1.
  • LogToExperiment in callbacks.py tags metrics as eval/<name>.

Implementation Steps

  • Add validation: ValidationStep | None = None to TrainingLoop, with the exclusivity check.
  • Add ValidationStep.with_model(op).
  • Call it from the Equinox adapter's periodic and final eval, in place of _evaluate, when it is set.
  • Raise a clear NotImplementedError for validation= on the Bayesian backends.

Definition of Done

  • Code lands at the intended path.
  • Tests pass: make test.
  • Lint + typecheck pass: make lint && make typecheck.
  • Docstrings (Google-style) on all public symbols.

Testing

  • The loop's eval/* metrics equal a standalone ValidationStep's on the same model to 1e-12.
  • Setting both validation and val_dataset raises ValueError.
  • with_model leaves the original step unchanged.

Documentation

  • TrainingLoop docstring and the validation section of docs/design/api/components.md.

Relationships

  • Parent (theme epic): #144
  • Blocked by: #122
  • Related: #125
  • Related: geostack docs/reports/11_pipekit_train.md, workstream C and gate C3
Lenguaje dominante
Python
Estrellas
0
Forks
0
Merge medio
3 h 50 min
PR fusionados (30 d)
143

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de jejjohnson/pipekit

Todos los issues de jejjohnson/pipekit

Issues similares

Más issues de Python

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.