Skip to content

perf: incremental metrics - #1036

Merged
mikasenghaas merged 5 commits into
mainfrom
incremental-metrics
Mar 19, 2026
Merged

mikasenghaas merged 5 commits into
mainfrom
incremental-metrics

Conversation

@mikasenghaas

@mikasenghaas mikasenghaas commented Mar 19, 2026

Copy link
Copy Markdown
Member

Description

Replace O(n²) metric recomputation in GenerateOutputsBuilder with incremental update/compute pattern. Introduces a Metric protocol and concrete classes (RewardMetric, ErrorRateMetric, InputTokensMetric, OutputTokensMetric, EnvMetrics, PassAtKMetric) in metric_utils.py. Each metric handles its own value extraction from RolloutOutput, making the builder a thin coordinator. Removes the compute_pass_at_k helper in favor of using PassAtKMetric directly.


Note

Medium Risk
Refactors core evaluation metadata computation (reward/error/usage/pass@k) to incremental accumulators, which can subtly change aggregation semantics and affect reported metrics. Low security risk but impacts correctness/performance of evaluation reporting.

Overview
Replaces the one-shot compute_pass_at_k helper and ad-hoc metadata aggregation with an incremental metric system (Metric protocol plus RewardMetric, ErrorRateMetric, EnvMetrics, token metrics, and PassAtKMetric). GenerateOutputsBuilder now updates these accumulators as outputs arrive and builds metadata in O(1) without rescanning all outputs.

Updates result printing to read pass_at_k/pass_all_k directly from saved metadata (instead of recomputing), and rewrites tests to validate the new metric classes, reset behavior, and GenerateOutputsBuilder pass@k integration.

Written by Cursor Bugbot for commit 18f14d6. This will update automatically on new commits. Configure here.

mikasenghaas and others added 2 commits March 19, 2026 16:56
Replace O(n²) metric recomputation in GenerateOutputsBuilder with
incremental update/compute pattern inspired by torchmetrics. Introduces
a Metric protocol and concrete classes (RewardMetric, ErrorRateMetric,
InputTokensMetric, OutputTokensMetric, EnvMetrics, PassAtKMetric) in
metric_utils.py. Each metric handles its own value extraction from
RolloutOutput, making the builder a thin coordinator. Removes the
compute_pass_at_k helper in favor of using PassAtKMetric directly.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@mikasenghaas mikasenghaas changed the title incremental metrics perf: incremental metrics Mar 19, 2026
@mikasenghaas
mikasenghaas marked this pull request as ready for review March 19, 2026 12:15

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Comment thread verifiers/utils/save_utils.py
@willccbb

Copy link
Copy Markdown
Member

@mikasenghaas LGTM pending MC resolve

@mikasenghaas
mikasenghaas merged commit 1960e77 into main Mar 19, 2026
6 checks passed
@mikasenghaas
mikasenghaas deleted the incremental-metrics branch August 5, 2026 04:32
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.

2 participants