Backend
Wraps a training client + factory for sampling clients.
A Backend is constructed once per run (typically by the Algorithm
composer, see :mod:evsys_sdk.algorithms.sft). It owns the
live training client; everything else in the package operates against
this Protocol.
Functions
funcforward_backward_async(self, data, *, loss_fn, loss_fn_config=None) -> AnySubmit a forward + backward pass with a named server-side loss.
Returns an awaitable that resolves to a :class:ForwardBackwardResult.
Tinker's loss names are "cross_entropy" (with per-position weights
on Datum.loss_fn_inputs["weights"]) and "importance_sampling"
(with advantages on Datum.loss_fn_inputs["advantages"]).
paramselfparamdatalist[tinker.Datum]paramloss_fntinker.types.LossFnTypeparamloss_fn_configdict[str, Any] | None= NoneReturns
typing.Anyfuncforward_backward_custom_async(self, data, loss_fn) -> AnySame as :meth:forward_backward_async, but the loss is a
client-side Python callable.
Tinker streams logits/logprobs back, the callable runs locally on each Datum, and the returned scalar gets sent back for the backward pass. This is the same hook SDFT uses for analytical reverse-KL, exposed here as a first-class extension point.
paramselfparamdatalist[tinker.Datum]paramloss_fnLossCallableReturns
typing.Anyfuncoptim_step_async(self, adam) -> AnyOptimizer step. Returns an awaitable resolving to :class:OptimStepResult.
paramselfparamadamtinker.AdamParamsReturns
typing.Anyfuncsave_for_sampler(self, name) -> strSnapshot the current weights for inference. Returns the sampler URI.
paramselfparamnamestrReturns
strfuncsave_full_state(self, name) -> strSnapshot weights + optimizer state for resume. Returns the URI.
paramselfparamnamestrReturns
strfuncsnapshot_sampling_client(self, name=None) -> SamplingClientSave_weights_for_sampler + construct an inference client at that URI.
Convenience for the in-loop eval slot, which needs both: save the latest weights AND get a client that can sample from them. The manager records the URI; the eval slot uses the client.
paramselfparamnamestr | None= NoneReturns
evsys_sdk.training.backend.SamplingClientfuncget_tokenizer(self) -> AnyHF tokenizer the backend is using. Used by StepBuilders that need to tokenize text (SFT) or apply chat templates (SDFT).
paramselfReturns
typing.Any