Skip to content

Unify the plain-commit and trial add paths #148

Open

Description

@NiklasMelton

#147 added trial mode (commit=False) and left two implementations of "add one sample" in every incremental index:

  • Plain commits use each index's original _param_inc (CH, WB, XB, DB, GD43, GD53, PS, cSIL, rCIP), unchanged from 0.7.2.
  • Trials, and commits that reuse a matching trial, use _plan_add / _apply_add. This path computes each candidate's new statistics without mutating, scores them (vectorized over candidates), and applies one slot.

They compute the same formulas. tests/test_trial.py checks they agree to a relative tolerance of 1e-12, but each change to the add math must now be made twice.

Goal

Use one implementation, so that _param_inc becomes "plan one label, then apply it", without slowing plain streaming commits.

What blocked it in #147

Routing plain commits through the plan path added about 10 µs per sample (CH: 13 → 24 µs at K=40, d=8). The cost was fixed numpy overhead on 1-row arrays, even with a single-label fast path. It also changed rounding slightly (einsum vs np.inner), so results were no longer bit-identical to 0.7.2.

Possible approaches

  • Make the single-label plan cheap enough to match the old path, e.g. scalar-only arithmetic with no 1-row array allocations.
  • Generate both forms from one formula definition, or compile the single-label case (Numba).
  • Accept a small overhead and the rounding change in a minor release.

Done when

  • Each index has one add implementation.
  • Plain-commit speed is within noise of the current numbers (benchmarks/ or a micro-benchmark).
  • The trial, move and memo tests in tests/test_trial.py still pass, with the cross-path tolerance removed.

Activity

  1. self-assigned this
    on Nov 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions