Repository navigation
feat(v1): optional sampler logprobs on SamplingMask - #2756
Open
faresobeid wants to merge 2 commits into
Open
faresobeid wants to merge 2 commits into
faresobeid wants to merge 2 commits into
Conversation
faresobeid
marked this pull request as ready for review
October 3, 2026 11:52
Contributor
ApprovabilityVerdict: Approved at Macroscope's review found this PR approvable — This is a focused, backwards-compatible extension that carries optional sampler logprobs through existing SamplingMask ingestion, graph serialization, and branch aggregation. Existing behavior remains unchanged when the optional data is absent, and the new cases have targeted test coverage. You can add or adjust custom eligibility rules. Learn more. |
faresobeid
force-pushed
the
feat/top-logprobs-v2
branch
3 times, most recently
from
October 6, 2026 17:18
1a0edde to
f46cf44
Compare
faresobeid
force-pushed
the
perf/packed-sampling-mask
branch
from
October 8, 2026 14:35
8069b2b to
cef65c3
Compare
faresobeid
force-pushed
the
feat/top-logprobs-v2
branch
from
October 8, 2026 14:35
f46cf44 to
1e499fb
Compare
macroscopeapp
Bot
dismissed
their stale review
October 8, 2026 14:36
Dismissing prior approval to re-evaluate 1e499fb
faresobeid
force-pushed
the
perf/packed-sampling-mask
branch
from
October 10, 2026 15:21
cef65c3 to
dc361d8
Compare
faresobeid
force-pushed
the
feat/top-logprobs-v2
branch
from
October 10, 2026 15:21
1e499fb to
71ad510
Compare
# Conflicts: # verifiers/v1/types.py
macroscopeapp
Bot
dismissed
their stale review
October 12, 2026 18:48
Dismissing prior approval to re-evaluate cf6ebfe
This branch has not been deployed
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.
What
On top of #2778's packed sampling-mask format, carries the sampler's logprobs at the sampling-mask ids onto the trace graph.
SamplingMaskgets an optional float32logprobsarray, parallel toids: the sampler's renormalized logprobs of the kept ids.SamplingMask.from_sampling_mask(mask, logprobs=None)decodeslogprobsfrom prime-rl's/generatesampling_mask_logprobs: packed float32, base64{data, shape, dtype}, the same form as perf(v1): accept packed CSR sampling masks from prime-rl's /generate #2778's packedids, decoded with perf(v1): accept packed CSR sampling masks from prime-rl's /generate #2778's_decode_packed.response_from_generatepassesresult.get("sampling_mask_logprobs"). Stock vLLM does not send it, so the per-row mask path has no logprobs.logprobslength differs fromidsis not attributed (same rule as a mask whose counts do not match the node's sampled positions).Branch.sampling_maskconcatenates the logprobs only when every mask on the path has them; otherwiselogprobsisNoneand ids/counts still merge. Nodes without a mask (prompt, replayed prefix) do not count.__nd__serializer/validator handle every field present on the dataclass. Without logprobs, the serialized form and payload are unchanged.Payload when present: 4 B per kept id.
Consumer
prime-rl score centering, PrimeIntellect-ai/prime-rl#3794 (stacked on prime-rl#3900), pins this head. It sends
sampling_mask_logprobspacked. Without that consumer this field is unused.Stack
Base: #2778 (
perf/packed-sampling-mask). Companion: PrimeIntellect-ai/renderers#170 (passessampling_mask_logprobsandpayloadthrough), on top of renderers#174. Order: renderers#174 -> #2778 -> prime-rl#3900; then renderers#170 + this PR -> prime-rl#3794. #2778 is merged into this branch.Validation
tests/v1/test_graph.py::test_sampling_mask_logprobs_attributed_aggregated_and_round_tripped: branch concat, wire round trip, mixed turns ->None, mismatched length not attributed.tests/v1/test_trace.py::test_sampling_mask_from_packed_matches_lists: packed logprobs decode.pytest tests/v1/test_graph.py tests/v1/test_trace.py,ruff check,ruff format --check.Note
Add optional sampler logprobs to
SamplingMasklogprobsfield toSamplingMaskin types.py, parallel to the flattened ids, plus support for packed logprobs in the factoryresponse_from_generatein train.py now passes renderer-provided mask logprobs intoSamplingMaskconstructionBranch.sampling_maskin trace.py concatenates logprobs across turns when every contributing mask has them, and sets them toNoneotherwise_attribute_sampling_maskin graph.py rejects masks whose logprobs length does not match the flattened ids; such masks are no longer attached to the assistant nodeMacroscope summarized cf6ebfe.
Note
Low Risk
Additive optional field with strict length validation; behavior unchanged when logprobs are absent (e.g. stock vLLM).
Overview
Adds optional sampler logprobs on v1
SamplingMask, carried parallel to flattened maskidsfrom prime-rl/generatethrough traces and training.SamplingMaskgains an optional float32logprobsarray andfrom_sampling_mask(..., logprobs)decodes packedsampling_mask_logprobsalongside the existing packedids/counts. The train client wires that field from generate results intoTurnTokens.sampling_mask.On the graph,
_attribute_sampling_maskdrops masks whenlogprobslength does not matchids;Branch.sampling_maskconcatenates logprobs only if every attributed node mask includes them (otherwise aggregatedlogprobsstaysNone). Serialization/deserialization now round-trips all non-Nonedataclass fields on the mask, not just ids/counts.Tests cover multi-turn branch concat, wire round-trip, mixed turns without logprobs, and invalid length rejection.
Reviewed by Cursor Bugbot for commit 71ad510. Bugbot is set up for automated code reviews on this repo. Configure here.