nemo_gym.token_id_capture.protocols
nemo_gym.token_id_capture.protocols
Define interfaces for captured training tokens.
Gym owns the record shape and capture protocols.
A training framework may implement the transport.
The sink may run in a Gym model server.
It may instead run in a framework inference worker.
Engine-side placement keeps token arrays off Gym’s HTTP response.
Consumers read through TokenSource.freeze.
They identify the frozen state with snapshot_id.
This module avoids FastAPI, Ray, Torch, and aiohttp imports.
Module Contents
Classes
Functions
Data
API
An immutable view of one rollout’s frozen capture records.
Receive captured records through Gym’s file store or a framework transport.
Flush pending work and release resources idempotently.
Durably record that a call of this rollout failed to capture.
The rollout is now missing a turn. A consumer must mask the sample instead of training on a chain with a hole. The model call itself still succeeds. This marker is therefore the durable signal that capture failed.
Durably store one record.
Repeating the same call id with the same payload is a no-op. Reusing a call id with a different payload must fail. Writing after the rollout is frozen must fail.
This method may raise. The caller marks the rollout incomplete. A capture error never fails the model call.
Where a trajectory builder freezes, reads, and retires records.
Release resources idempotently.
Conditionally retire the exact frozen snapshot that was consumed.
Return False if state changed after the snapshot.
Implementations that cannot delete return True.
Their owner remains responsible for retention.
Freeze a rollout and return one atomic snapshot.
Freezing is idempotent. No successful writes may occur after it returns. Entry order carries no meaning.
Set (or clear, with None) the process-wide default sink.
Set (or clear) the caller-owned source in this process.
Gym does not close an installed source.