nexuml.core.post_train_layer¶
nexuml.core.post_train_layer
¶
PostTrainFitLayer — pipeline layer with a post-training accumulate/fit lifecycle.
PostTrainLayerNotFittedError
¶
Bases: RuntimeError
Raised when a PostTrainFitLayer is asked to transform before fitting.
PostTrainFitLayer
¶
Bases: PipelineLayer
Abstract pipeline layer that requires a post-training fit pass.
Lifecycle (managed by NexuSession._fit_post_train_layers):
1. Orchestrator arms exactly one unfitted layer per predict pass: layer._armed = True
2. During that predict pass, forward() calls collect_batch(x, y) and returns
(x, y) unchanged (no output key written yet).
3. on_predict_end() calls finalize_fit() and sets _fitted = True.
4. On subsequent calls, forward() calls _transform_forward(x, y) (fitted mode).
5. Other unfitted layers in the same pass are not armed — they pass through silently.
Fitted state is persisted via Lightning checkpoint hooks so loading a checkpoint restores a fully fitted pipeline without re-running fit passes.