nemo_gym.core.model_call_sampling
nemo_gym.core.model_call_sampling
Sampling values that a training framework sets for a rollout’s model calls, and how they reach each call.
A training framework that serves the policy samples the calls of the agents it trains with its own values: its
training values, or its validation values for a validation rollout. It sets them on each rollout’s row under
_ng_model_sampling, next to _ng_rollout_id. Gym carries them into the URL of every model call the rollout’s
agent makes, as /ng-sampling/<values> after any other prefix, and the Model Server writes them into the request.
Gym never interprets them.
In such a run, a call from a caller the framework does not train, such as a verifier’s LLM judge, carries
/ng-sampling/null: it keeps the sampling its caller chose, and its own Model Server’s sampling_overrides.
A run whose rows carry no values, such as Gym-only evaluation, adds no segment.
Module Contents
Classes
Functions
Data
API
Bases: BaseModel
Sampling values for the model calls of an agent that a training framework trains.
The Model Server sends the smaller of max_output_tokens and the call’s own limit, so a harness that reserves
fewer tokens, near the end of its context or for a summary, keeps its limit. An unset field leaves the call’s own
value.
Bases: BaseModel
The global model_call_sampling block. A training framework sets it when its rows carry values.
Its presence marks the run: resources servers then send null with the model calls they make through Gym’s
server client while handling a request, so their judges keep their own sampling.
Return the segment value for this request’s model calls, or None when they carry no segment.
Decode a segment value: null to None, anything else to values.
Raises ValueError for a malformed or ambiguous value, so a call never runs with values it did not send.
Encode values as the segment’s unpadded base64url JSON, and None as null.
Return the run’s model_call_sampling block, or None when the run sets none.
Raises ValueError when required_model_servers names a server that is not a Model Server of the run: a
misspelled name would otherwise leave the trained agent’s Model Server unenforced, without an error.
Give the model calls made inside the block the segment value segment.
Return the values a run request or row carries under _ng_model_sampling, or None.
Return /ng-sampling/<segment>, or "" for no segment.
Insert /ng-sampling/<segment> into a Model Server generation path, where its correlation prefix puts it.
Other paths, and paths that already carry a segment or a malformed prefix, are returned unchanged.