Remove loop output transforms - #657
Open
seanmor5 wants to merge 1 commit into
Open
Conversation
Loops no longer carry an `output_transform`. `Axon.Loop.run/4` always
returns the final `%Axon.Loop.State{}`, so the full training state is
never silently discarded — callers extract what they need:
%Axon.Loop.State{step_state: %{model_state: model_state}} =
Axon.Loop.run(loop, data)
Breaking changes:
* `Axon.Loop.loop/3` is now `Axon.Loop.loop/2`
* `Axon.Loop.trainer/4` no longer returns only the model state
* `Axon.Loop.evaluator/1` no longer returns only the metrics map
Closes #362
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
polvalente
approved these changes
Aug 16, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #362.
Loops no longer carry an
output_transform.Axon.Loop.run/4always returns the final%Axon.Loop.State{}, so you never accidentally lose the entire training state — callers extract what they need:Breaking changes
Axon.Loop.loop/3is nowAxon.Loop.loop/2— step function plus an optional init functionAxon.Loop.trainer/4no longer returns onlystep_state.model_stateAxon.Loop.evaluator/1no longer returns onlystate.metrics(they're atstate.metrics[epoch])Notes
Axon.Loop.validate/4was the only internal consumer of a transform; it now pattern matches%State{metrics: %{0 => validation_metrics}}off the evaluator run.Map.put(:output_transform, & &1)(plus a# TODO: Fix default output transformcomment). Those are all gone.Axon.Loop.metric/5's last argument) was also called an "output transform" in docs and error messages. That naming is now just "transform" to avoid confusion with the removed concept — the argument itself is unchanged.Verification
mix test→ 822 passed (198 doctests, 624 tests).mix test --only integrationfails on the same pre-existing flaky set as the unmodified baseline (verified by stashing and re-running onmain):bce with simple xor model,f64 input test,image classification test,rnns static and dynamic unroll match, and the mixed-precision accuracy checks vary run to run.🤖 Generated with Claude Code