Skip to content

metrics: build the one-hot target without np.eye - #270

Open
Wenjix wants to merge 1 commit into
jaredpalmer:mainfrom
Wenjix:security/metrics-onehot
Open

Wenjix wants to merge 1 commit into
jaredpalmer:mainfrom
Wenjix:security/metrics-onehot

Conversation

@Wenjix

@Wenjix Wenjix commented Oct 27, 2026

Copy link
Copy Markdown

Closes #267

Summary

metrics() and _row_scores() built each row's target as np.eye(len(p))[y], allocating K² floats to read one row (finding 7 of a security scan of 2074cc4: a saved rows.json with a very long p asks for a matrix of that size). A zero vector with 1.0 at the label is the same float64 row, so every metric is unchanged bit for bit.

Verification

  • uv run --extra serve python -m pytest tests/test_unit.py tests/test_research.py tests/test_compare.py tests/test_rounds.py -q: 323 passed, 25 skipped. test_rounds.py recomputes the committed read-outs and compares every number exactly.
  • Parity with main (the kev-verify harness): kev.benchmark --run jaredpalmer/kev-0.8b@9a45d25 --suite evals/smoke-v1 --device cpu from both trees. rows.json is byte-identical, and all 468 numeric fields of report.json match except wall-clock latency.
  • The CI test set with all five hardening branches applied together: 603 passed, 26 skipped.

Merge Danger

None: the numbers are bit-identical.

Generated with Devin

np.eye(K)[y] allocated K squared floats to read one row; a zero
vector with 1.0 at the label is the same float64 row, so every metric
is bit-identical.

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings October 27, 2026 09:19

Copilot AI 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.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

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.

bug: metrics builds a K x K identity matrix for each one-hot target

2 participants