nemo_gym.token_id_capture.staging.digest
nemo_gym.token_id_capture.staging.digest
Encode staged records for integrity verification.
The staged-record digest covers the call metadata and token columns. Optional extras are encoded separately. Their digest is included in the staged-record digest. This lets one consumer verify token data without loading extras. A later consumer can verify extras against the same recorded digest.
All values use versioned, length-delimited encodings. Masks and log probabilities use IEEE-754 float32 bit patterns. Extras use a typed binary encoding instead of JSON serialization.
Module Contents
Functions
Data
API
Slice a full prompt/generation pair into the next staged delta.
Chain one staged delta onto its parent’s chain hash.
chain_hash_N = H(chain_hash_{N-1} || token_ids_delta_N) lets every
consumer verify parent-child token continuity without materializing the
cumulative sequence. A root delta chains from None. The marker byte
keeps a root encoding from colliding with a child encoding.
Parameters:
The parent call’s chain hash, or None for a root.
This call’s exact staged token delta.
Returns: str
The lowercase SHA-256 hex chain hash for this call.
Digest a normalized JSON-like extras envelope.
Supported values are None, exact bool/int/float/str
scalars, lists, and string-keyed dictionaries. This deliberately rejects
numpy scalars, tuples, bytes, NaN, and infinity so different runtimes
cannot silently choose different encodings.
Compute the v2 digest for one staged call delta.
Encode token IDs as a length followed by unsigned big-endian values.
Hash one exact cumulative token prefix.