BaseAlgorithm
Template-method base for the SDK's training algorithms. See module docstring.
Subclasses set the name / Config ClassVars (the registry contract)
and override :meth:setup + :meth:build_batch (+ optionally
:meth:step_metrics).
Attributes
attributenamestrattributeConfigtypeattributecfg= self.Config.model_validate(kwargs)attributesteps_per_epochintFunctions
func__init__(self, **kwargs) -> NoneparamselfparamkwargsAny= {}Returns
Nonefuncsetup(self, ctx, backend) -> NoneOne-time prep before the loop. Must set self._steps_per_epoch.
Override in the concrete algorithm.
paramselfparamctxRunContextparambackendTinkerBackendReturns
Nonefuncbuild_batch(self, step_idx) -> TrainingBatchProduce the batch for step_idx (0-based). Override.
paramselfparamstep_idxintReturns
evsys_sdk.training.loop.TrainingBatchfuncstep_metrics(self, step_idx, batch, fb_result) -> dict[str, float]Per-step metrics from the forward-backward result. Default no-op.
paramselfparamstep_idxintparambatchTrainingBatchparamfb_resultAnyReturns
dict[str, float]functrain(self, ctx) -> RunResultparamselfparamctxRunContextReturns
evsys_sdk.protocols.RunResultfunc_train_async(self, ctx) -> RunResultparamselfparamctxRunContextReturns
evsys_sdk.protocols.RunResultfunc_check_inputs(self, ctx) -> NoneValidate ctx.extras before the backend is allocated. Override to
fail fast on missing / empty inputs (e.g. no train_rows). Default
no-op.
paramselfparamctxRunContextReturns
Nonefunc_hyperparams_extra(self) -> dict[str, Any]Extra fields merged into the logged hyperparams. Override to add
algorithm-specific counts (e.g. n_train_rows).
paramselfReturns
dict[str, typing.Any]func_resolve_total_steps(self) -> intparamselfReturns
intfunc_resolve_save_every(self, total_steps) -> intResolve the checkpoint cadence from save_every /
save_at_fractions. Identical heuristic across all algos: take the
GCD of the requested fraction-marks, but fall back to total/10 if
that GCD would pathologically save every other step.
paramselfparamtotal_stepsintReturns
int