Repository navigation
feat(trace): carry sampler probability heads to training branches - #2804
Merged
Merged
Conversation
Contributor
ApprovabilityVerdict: Needs Human Approval Macroscope's review found this PR requires human approval — This PR adds a new sampler-probability data path from generation responses through serialized trace nodes into training branches. The cross-component runtime and wire-format contract is broader than a self-contained additive change and merits human review. You can add or adjust custom eligibility rules. Learn more. |
hallerite
approved these changes
Oct 19, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Carry sampler probability heads from renderer responses onto assistant nodes and training branches for prime-rl #4012, paired with renderers #180.
TopLogprobsis a flat IDs/logprobs/counts carrier. It shares the existing raw-array serializer with sampling masks, checks sampled-token alignment when attributed, and gives context or uncaptured positions zero counts when flattening a branch. Public trace records exclude the arrays. Empty completions preserve an empty carrier.Validation: 179 unit tests passed; a temporary probe covered multi-turn alignment, mixed capture, empty completions, malformed rows/counts, MessagePack round trips, and record exclusion. All contributor hooks and the configured type gate passed using uv 0.13.1. The full suite was attempted: four Docker Compose integration cases failed because the local Docker daemon is unavailable; provider/runtime cases were skipped where prerequisites were absent.
Updated onto current main without rewriting the existing PR history.
Note
Carry top-k sampler logprob heads onto graph nodes and branches
TopLogprobsdataclass in types.py that flattens top-k token IDs, log probabilities, and per-token counts, with a validatingfrom_top_logprobsconverter.response_from_generatein train.py parses completion top IDs/logprobs into a transientTurnTokens.top_logprobsfield._attribute_top_logprobsin graph.py validates payload alignment against the assistant node's sampling mask and attaches it to the node; misaligned payloads raiseValueError.Branch.top_logprobsin trace.py concatenates node-level heads in node order for branch-aligned training data. Serialization is shared withSamplingMask;top_logprobsis excluded from disk serialization viaEXCLUDE_FIELDSbut kept in the msgpack wire format.MessageNode.serialize_sampling_arraysanddeserialize_sampling_arraysnow handle bothSamplingMaskandTopLogprobs; misaligned top-logprob payloads at commit raiseValueError.📊 Macroscope summarized 2b8718e. 5 files reviewed, 2 issues evaluated, 2 issues filtered, 0 comments posted
🗂️ Filtered Issues
verifiers/v1/graph.py — 0 comments posted, 2 evaluated, 2 filtered
countsis only checked for negativity and its truncated total. A malformed numeric array such asnp.array([1.5, 0.5])for a two-token completion with two flat ids passes all four conditions (int(sum)==len(ids)), then is stored.Branch.top_logprobslater scatters it into anint32array, silently converting it to[1, 0]while retaining both ids/logprobs; the branch therefore has counts that no longer describe the flat head and training consumes misaligned sampler probabilities. Require an integral count dtype/values (and validate the exact sum withoutint()) before attaching it. [ Out of scope (post-validation triage) ]len(payload.ids)/len(payload.logprobs), which measures only axis 0 and never enforces the documented flat layout. For example, a one-token completion withidsandlogprobsshaped(1, 2)andcounts=[1]passes every check, is attached, andBranch.top_logprobsreturns 2-D candidate arrays despite its counts declaring one flat candidate. Downstream training then receives an invalid head layout (or fails when it assumes a 1-D CSR array). Reject non-1-D ids/logprobs/counts before assigning the payload. [ Out of scope (post-validation triage) ]