feat(train): make ValidationStep the loop's evaluator, or remove it
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 55/100
- Issue type
- Feature
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- python
- Domain
- backend, machine-learning
Research direction
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.
Written by the indexing model from the issue text.
Description
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)
validationandval_datasetare mutually exclusive, and setting both raisesValueError.with_model(op)returns a copy bound to the current weights, because the constructor fixesmodel_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
ValidationStepinpackages/pipekit-train/src/pipekit_train/loop.py@7c446f1._evaluateinpackages/pipekit-train/src/pipekit_train/adapters/equinox.py@7c446f1.LogToExperimentincallbacks.pytags metrics aseval/<name>.
Implementation Steps
- Add
validation: ValidationStep | None = NonetoTrainingLoop, 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
NotImplementedErrorforvalidation=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 standaloneValidationStep's on the same model to 1e-12. - Setting both
validationandval_datasetraisesValueError. -
with_modelleaves the original step unchanged.
Documentation
-
TrainingLoopdocstring and the validation section ofdocs/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
- Dominant language
- Python
- Stars
- 0
- Forks
- 0
- Avg merge
- 3h 50m
- Merged PRs (30d)
- 143
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from jejjohnson/pipekit
-
area:code layer:0-primitives priority:p2 type:feature
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
jejjohnson/pipekit#296 ·
Maintainers usually reply within 1 day
-
area:code type:feature
Difficulty 3/5 1-2 days Newbie friendliness 57/100
jejjohnson/pipekit#411 ·
Maintainers usually reply within 1 day
-
area:code type:feature
Difficulty 4/5 3-5 days Newbie friendliness 48/100
jejjohnson/pipekit#410 ·
Maintainers usually reply within 1 day
-
area:code type:feature
Difficulty 5/5 Over a week Newbie friendliness 38/100
jejjohnson/pipekit#409 ·
Maintainers usually reply within 1 day
-
area:code type:feature
Difficulty 3/5 1-2 days Newbie friendliness 75/100
jejjohnson/pipekit#408 ·
Maintainers usually reply within 1 day
All issues in jejjohnson/pipekit
Similar issues
-
bug(operator): VolterraOperator built inside jax.jit with a concrete decay raises TracerBoolConversionErrorPossibly taken @jejjohnson claimed this today. Opentype:bug
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
jejjohnson/integrix#144 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
finos/ai-governance-framework#459 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
autowarefoundation/autoware_carla_scenario#2963 ·
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
freelawproject/litigant-portal#1307 ·
Maintainers usually reply within 2 days
-
type/bug
Difficulty 1/5 Under an hour Newbie friendliness 86/100
h2oai/h2o-llmstudio#1163 ·
Maintainers usually reply within 1 day