nemo_gym.token_id_capture.consumer
nemo_gym.token_id_capture.consumer
Turn a rollout’s frozen token capture into trajectories.
Gym rollout collection and trainer finalization use this consumer.
Gym reads a frozen snapshot from the local token store.
A trainer freezes the TokenSource provided by its transport.
Both paths pass snapshot entries through the same build and projection.
This module does not import rollout-record or model-server modules.
The caller supplies the rollout_id.
Gym derives that ID from task, rollout, and attempt indices.
The result includes metrics that describe the build.
Module Contents
Functions
Data
API
Whether an incomplete snapshot masks this build.
Incomplete means some model call registered its capture intent and never
committed a record (a harness killed at its timeout backstop leaves exactly
this signature). With always the build is masked, because that call may
be the trajectory’s real terminal.
Without always a delivered terminal attribution keeps the build: the
attributed terminal is the verified response’s final model output, the
delivered chain reaches it whole, and a call with no record cannot sit
inside that chain, so the uncaptured call is outside the scored trajectory.
Any other attribution outcome still masks.
Remove stale token records for rollouts about to be dispatched.
Rollout IDs are deterministic.
TokenCaptureStore.append uses append mode.
A reused ID would append records to a previous attempt.
The builder could then combine two attempts.
The caller passes only rows ready for dispatch.
Retry suffixes must already be assigned.
Return the token_id_capture.mask_incomplete_when_attributed setting.
A caller that holds the Gym global config reads the setting here and passes it to the build functions below, which default to the strict behavior.
Return the enabled token store directory or an empty list.
Build trajectories from a frozen local token-store snapshot.
Return None only when no capture directory is configured.
Missing records are unsafe and return a masked result.
An incomplete snapshot masks the result. With
mask_incomplete_when_attributed set to False it masks only when
terminal attribution did not deliver its chain, because a delivered chain
places the uncaptured call off the scored path.
Build trajectories from a frozen TokenSource snapshot.
declared_response_id is the served response id the harness reports;
a declared id that matches no entry masks the rollout.
Missing records are unsafe and return a masked result.
An incomplete snapshot masks the result. With
mask_incomplete_when_attributed set to False it masks only when
terminal attribution did not deliver its chain, because a delivered chain
places the uncaptured call off the scored path.