nemo_gym.models.token_capture.delivery
nemo_gym.models.token_capture.delivery
Build a token-bearing record from one finished rollout.
The finalizer freezes the rollout’s captured model calls.
It rebuilds response.output from that frozen snapshot.
It does not retire the snapshot.
The caller may retire it only after durable handoff.
Retirement uses the frozen snapshot_id and version.
The caller provides both the rollout record and its TokenSource.
Gym resolves its source from Gym configuration.
A training framework may provide a source from its own data plane.
Training correlation must preserve /ng-rollout/<id>/training-token-capture.
Existing token ids are the policy’s sampled data. The finalizer leaves a rollout containing any token ids unchanged. Failed or masked builds retain their capture evidence.
Module Contents
Functions
Data
API
Mask a rollout that needed token ids and could not get them.
An unmasked rollout would appear healthy until it reaches the trainer. The record retains the reason for aggregate reporting.
Whether a successful build consumed a frozen snapshot.
Rebuild one finished rollout record’s response.output from its recorded token ids.
Call this after the harness and verifier finish the record.
The function mutates result in place.
It replaces response.output.
It preserves the reward and all other harness and verifier output, with one exception:
when the rebuilt response is incomplete because the delivered chain’s terminal call
was cut (length or content_filter), or because the engine refused the request
that continued it for the context window, and the harness reported completed or no
status, the harness response takes that status and incomplete_details, so a
reader of the record sees why the delivered chain stopped. A harness that reported
incomplete or failed itself keeps its own verdict. apply_capture_incomplete_verdict
states that rule once, for this path and for a framework that rebuilds from staged records.
The function freezes capture records through source.
It rebuilds from that frozen snapshot.
It never retires the snapshot.
A None source means this caller does not rebuild.
A rollout that already carries token ids is left unchanged.
Its redundant frozen capture remains eligible for retirement after handoff.
The function never raises. Missing or ambiguous tokens cause masking. Failed or masked builds retain their frozen evidence.
Return the build with its rebuilt response, metrics, and optional error.
Return None when no source exists.
An unusable build has no rebuilt response and sets mask_sample.
mask_incomplete_when_attributed is the
token_id_capture.mask_incomplete_when_attributed setting, which decides
whether an incomplete snapshot always masks the rollout.
Retire a frozen snapshot after durable handoff.
The caller owns the durability boundary.
Call this only after downstream acceptance or a local fsync.
Retirement uses the frozen snapshot_id and version.
Failed or masked builds remain as diagnostic evidence.
Whether this rollout already holds what training needs.
Return true when any output item carries generated token ids. These ids are what the policy sampled. They take precedence over a reconstruction that may differ. Partial token coverage must remain visible instead of being overwritten.