EvSys

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) -> Any

Submit 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"]).

paramself
paramdatalist[tinker.Datum]
paramloss_fntinker.types.LossFnType
paramloss_fn_configdict[str, Any] | None
= None

Returns

typing.Any
funcforward_backward_custom_async(self, data, loss_fn) -> Any

Same 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.

paramself
paramdatalist[tinker.Datum]
paramloss_fnLossCallable

Returns

typing.Any
funcoptim_step_async(self, adam) -> Any

Optimizer step. Returns an awaitable resolving to :class:OptimStepResult.

paramself
paramadamtinker.AdamParams

Returns

typing.Any
funcsave_for_sampler(self, name) -> str

Snapshot the current weights for inference. Returns the sampler URI.

paramself
paramnamestr

Returns

str
funcsave_full_state(self, name) -> str

Snapshot weights + optimizer state for resume. Returns the URI.

paramself
paramnamestr

Returns

str
funcsnapshot_sampling_client(self, name=None) -> SamplingClient

Save_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.

paramself
paramnamestr | None
= None

Returns

evsys_sdk.training.backend.SamplingClient
funcget_tokenizer(self) -> Any

HF tokenizer the backend is using. Used by StepBuilders that need to tokenize text (SFT) or apply chat templates (SDFT).

paramself

Returns

typing.Any

On this page