Skip to content

fix(v1): reject invalid sampled logprobs#2121

Draft
EazyReal wants to merge 1 commit into
PrimeIntellect-ai:mainfrom
EazyReal:fix/v1-sampled-evidence-alignment
Draft

fix(v1): reject invalid sampled logprobs#2121
EazyReal wants to merge 1 commit into
PrimeIntellect-ai:mainfrom
EazyReal:fix/v1-sampled-evidence-alignment

Conversation

@EazyReal

@EazyReal EazyReal commented Jul 24, 2026

Copy link
Copy Markdown

Description

The v1 renderer path currently persists completion token IDs and sampled logprobs independently through TurnTokens.model_construct. If the logprob list is short, Branch.logprobs silently fills the missing sampled positions with 0.0; if it is long, it truncates it.

At a sampled position, 0.0 asserts probability 1.0. Repairing malformed evidence this way changes the behavior-policy signal used for training.

This change:

  • requires exactly one finite real logprob per completion token before persistence and reports malformed responses as ProviderError;
  • applies the same parser when projecting a branch, so mismatched or non-finite evidence reaching projection fails instead of being truncated or zero-padded;
  • validates that each node's token and mask streams remain aligned;
  • keeps 0.0 only for genuinely unsampled positions.

It deliberately does not tighten the persisted Pydantic field types, so historical 0/1 masks keep their existing loading behavior.

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Test improvement

Malformed sampled evidence that previously flowed into training now fails closed.

Testing

  • All existing tests pass when running uv run pytest tests/ -q locally (provider E2E cases requiring PRIME_API_KEY skipped).
  • New tests have been added to cover the changes

Per AGENTS.md, no unit tests are added. A temporary adversarial probe covered aligned and interleaved masks; short, long, missing, non-list, non-finite, Boolean, and string logprobs; mask/token mismatches; and ProviderError translation.

Additional checks:

  • uv run pre-commit run --all-files
  • uv run ruff check .
  • pre-push Ty check
  • independent final-diff review

Checklist

  • My code follows the style guidelines of this project as outlined in AGENTS.md
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation (not applicable; no public interface changed)
  • My changes generate no new warnings
  • Any dependent changes have been merged and published

Draft blocker

Released Renderers 0.1.8 can normalize missing evidence to an apparently aligned 0.0 before Verifiers receives it, losing both missing-versus-real-zero provenance and per-entry token identity.

Renderers #108 is merged and adds strict wire validation plus MalformedGenerateResponseError, but it is currently available only in the 0.1.9.dev5 prerelease. Before this PR is marked ready, the next stable Renderers release should be available; this branch can then translate that exact exception to ProviderError and advance the dependency floor and lock without catching unrelated ValueError failures.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant