Skip to content

perf: reduce scalar distance validation overhead - #113

Merged
isty2e merged 1 commit into
mainfrom
perf/scalar-distance-validation
Jul 28, 2026
Merged

perf: reduce scalar distance validation overhead#113
isty2e merged 1 commit into
mainfrom
perf/scalar-distance-validation

Conversation

@isty2e

@isty2e isty2e commented Jul 28, 2026

Copy link
Copy Markdown
Owner

Summary

  • use math.isfinite after the existing float normalization in the scalar distance validator
  • add direct contract tests for finite values, NumPy scalars, signed zero, non-finite values, and negative distances
  • leave the distance model, workspace ownership, public API, and exception behavior unchanged

Performance

I ran three alternating parent/current smoke passes on the same machine, giving six samples per cell. Median zero-cost results:

Workload Path Before After Change
Continuous Direct ask/tell 121.7 us/eval 94.5 us/eval -22.4%
Continuous Study scalar 149.2 us/eval 126.9 us/eval -15.0%
Structured Direct ask/tell 214.2 us/eval 180.0 us/eval -16.0%
Structured Study scalar 234.8 us/eval 198.4 us/eval -15.5%

The objective-only and legacy control paths varied by about 3% or less. At the 200 us objective band, every variopt path in the paired comparison also improved.

A separate 900-run full matrix covered both workloads, five objective-cost bands, three seeds, and five repeats. All 150 variopt semantic records matched the parent baseline exactly, including result and state digests, evaluation counts, proposal counts, generations, and failures.

Verification

  • uv run --extra test pytest: 1710 passed
  • uv run --extra test pre-commit run --all-files: passed
  • Ruff and BasedPyright: passed through pre-commit

@isty2e
isty2e merged commit 7e79916 into main Jul 28, 2026
8 checks passed
@isty2e
isty2e deleted the perf/scalar-distance-validation branch July 28, 2026 21:12
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