Skip to content

Epic: drive canonical benchmark from parity-eligible to tightly matched implementations #202

Closed

Description

@godofecht

Objective

The canonical benchmark now has 19/19 parity eligibility, but eligibility must never be treated as identity. Several rows still have meaningful numerical, semantic, model-state or performance disparities.

This epic drives those remaining gaps down while keeping every disparity visible in disparity_report.json and on Pages.

Principles

  • Do not hide a disparity by widening a tolerance.
  • Preserve strict diagnostic status separately from final eligibility.
  • Track score/objective gaps, semantic/configuration differences, model-state differences and runtime ratios independently.
  • Prefer matching sklearn semantics where practical; where Flow intentionally differs, document and benchmark the difference explicitly.
  • A performance win is only meaningful after correctness/model-state evidence is understood.

Workstreams

  • Align KMeans initialization/convergence semantics closely enough to remove the special approximate-equivalence exception.
  • Reduce the Digits DecisionTree predictive disparity and diagnose structural tree differences.
  • Reduce the Digits RandomForest predictive disparity and align ensemble randomness/bootstrap semantics.
  • Close the Digits KernelSVC quality gap while addressing the external-native solver performance gap.
  • Add estimator model-state parity diagnostics across the canonical benchmark.
  • Add disparity-history/regression budgets so future benchmark freezes cannot silently worsen an already-eligible row.
  • Prioritize the largest remaining scaling/performance gaps identified by the architecture roadmap, especially Lasso and external-native solver paths.

Acceptance criteria

Every canonical row has persistent disparity evidence beyond a pass/fail parity label.

Known semantic exceptions are either eliminated or explicitly retained with quantitative justification.

Pages shows runtime plots and disparity plots generated from frozen artifacts.

CI detects material disparity regressions across benchmark freezes.

Child issues produce focused implementation changes rather than another broad benchmark rewrite.

Activity

  1. godofecht commented on Aug 18, 2026

    @godofecht
    OwnerAuthor

    Triage: epic still open, one child closed

    Audited every child against the frozen canonical evidence on main (c1e01df).

    child state evidence
    #203 KMeans equivalence exception still open kmeans_equivalence_contract.json and finalize_kmeans_parity.py both still active in CI; strict status still "not parity verified"; ARI gap 0.06368
    #204 Digits DecisionTree still open score_abs_diff still 0.019444; model_state_diagnostics empty
    #205 Digits RandomForest still open score_abs_diff still 0.019444; model_state_diagnostics empty
    #206 Digits KernelSVC still open score_abs_diff still 0.002778; runtime ratio 0.0638 (about 15.7x slower); model_state_diagnostics empty
    #207 model-state diagnostics partially done PR #331 landed the evidence layer and coverage audit; coverage is 3 of 19 rows
    #208 disparity history and regression gate done, closed PR #329 landed as 3deac85; first main-branch freeze at c1e01df established the baseline
    #209 Lasso performance still open runtime ratio 0.01763, about 57x slower, the worst in the canonical set; no Lasso work merged

    Against the epic's own acceptance criteria:

    • "Every canonical row has persistent disparity evidence beyond a pass/fail parity label." Met at the score, configuration, semantic and runtime level: disparity_report.json shows rows_with_tracked_disparity: 19. Not met at the model-state level: 3 of 19.
    • "Known semantic exceptions are either eliminated or explicitly retained with quantitative justification." Retained with justification. The KMeans contract is quantitative and evidence-gated, and .github/workflows/remaining-issues.yml currently asserts strict_final_status_disagreements >= 1, so the exception is a CI requirement rather than a leftover. Make KMeans trajectory semantics sklearn-compatible and retire the equivalence exception #203 covers eliminating it.
    • "Pages shows runtime plots and disparity plots generated from frozen artifacts." Met. docs/disparity-history.html plus the disparity regeneration and history materialization steps in .github/workflows/pages.yml.
    • "CI detects material disparity regressions across benchmark freezes." Met via Track disparity history and fail CI on unexplained regression #208.

    The common blocker across #204, #205 and #206 is the same one: benchmarks/bench_flow_v2.flow emits DETAIL| state records only for KMeans and PCA. Until the tree, ensemble and SVM rows emit learned state, none of those three issues can produce the structural comparison their acceptance criteria require. Worth sequencing the DETAIL| emission work first as a shared prerequisite.

    Largest remaining performance gaps by runtime_ratio_sklearn_over_flow: diabetes Lasso 0.0176, digits KMeans 0.0321, digits KernelSVC_RBF 0.0638, diabetes KernelRidge_RBF 0.1268, iris KernelSVC_RBF 0.1391, digits LinearSVC 0.2171.

  2. godofecht commented on Aug 18, 2026

    @godofecht
    OwnerAuthor

    Integration result: 65 PRs merged, all 19 canonical scores bit-identical, 2.44x aggregate

    Every optimization in the recent campaign claimed parity individually. Nothing had verified them together, which is the question this epic actually cares about. Measured on merged main (71fb274) against the pre-merge baseline (c1e01df), same machine, same flags.

    Parity: unchanged

    diff of the score fields across all 19 canonical rows is empty. Not one fitted model moved. The disparities this epic tracks are exactly where they were, so #203, #204, #205 and #206 are unaffected by the performance work.

    Speed

    row fit predict
    LinearSVC/digits 1369.85 -> 695.01 (2.0x) 1.079 -> 0.704 (1.5x)
    KernelSVC_RBF/digits 1072.41 -> 614.47 (1.7x) 63.900 -> 4.759 (13.4x)
    KMeans/digits 956.51 -> 107.99 (8.9x) 1.059 -> 0.044 (24.1x)
    LogisticRegression/digits 96.12 -> 14.95 (6.4x) 1.062 -> 0.031 (34.3x)
    RandomForest/digits 90.74 -> 44.13 (2.1x) 0.596 -> 0.266 (2.2x)
    DecisionTree/digits 69.68 -> 31.77 (2.2x) 0.065 -> 0.044 (1.5x)
    KernelRidge_RBF/diabetes 30.03 -> 19.23 (1.6x) 2.347 -> 1.570 (1.5x)
    Lasso/diabetes 29.31 -> 19.34 (1.5x) 0.005 -> 0.003 (1.7x)
    KernelSVC_RBF/iris 8.03 -> 2.14 (3.8x) 0.239 -> 0.044 (5.4x)
    KMeans/iris 3.54 -> 0.46 (7.8x) 0.005 -> 0.002 (2.5x)
    PCA/iris 0.17 -> 0.03 (5.2x) 0.004 -> 0.001 (4.0x)

    Total across all 19 rows: 3802 ms -> 1560 ms, 2.44x. Every row improved in both stages; there are no regressions.

    Bearing on the open children

    Caveats

    Measurements are single runs on a developer machine, so treat small-absolute rows as indicative. Four rows looked like regressions on a first pass and were all noise: re-running showed LinearSVC/digits predict, Ridge fit, Lasso fit and KernelRidge predict at 1.49x-1.53x rather than the 0.49x-0.89x the first run suggested. CI's benchmark contract is the authority for published figures.

    One PR was deliberately not merged: #377 (Ridge.fit QR rewrite) fails its own test on Linux with ridge_fit coefficients moved. It was verified bit-identical on macOS/Accelerate but is not under OpenBLAS. That is the same cross-BLAS hazard recorded in #397 and #361.

  3. godofecht commented on Aug 19, 2026

    @godofecht
    OwnerAuthor

    Two children of this epic ask for something that would make flow-scikit worse

    #204 and #205 are framed as reducing a "predictive disparity" on the Digits DecisionTree and RandomForest rows. Both disparities are in Flow's favour, from the committed headline_result_v2.json:

    row Flow sklearn
    DecisionTree / digits 0.833333313 0.813888889 Flow +0.019444424
    RandomForest / digits 0.955555558 0.936111111 Flow +0.019444447

    Closing either gap means deliberately degrading Flow's tree. That is worth stating plainly in the epic, because "reduce the disparity" reads as a defect to fix and it is not one here.

    Why the trees differ, diagnosed rather than assumed

    Using the per-node diagnostics from PR #402, the first divergent node on Digits is node 4. Both implementations are correct and the difference is tie-breaking:

    • Node 4 holds 10 samples, parent gini 0.66.
    • Flow picks feature 3 at threshold -1.7258; sklearn picks feature 46 at -0.6921.
    • Both give weighted gini 0.31999999999999995 in f64 and 0.32 in f32. Identical.
    • Six features reach that exact minimum: 3, 29, 37, 41, 45, 46.

    Flow scans features in index order with a strict <, so the lowest index wins. sklearn draws candidates through a Fisher-Yates permutation off its splitter RNG, so the first drawn among equals wins.

    Ties are the normal case, not an edge case: 68 of 122 split nodes have more than one feature at the exact f32 minimum, mean multiplicity 9.74, max 48.

    The gap is tie-break noise, quantified

    Sweeping only sklearn's random_state over 0..59 moves node 4's split feature across exactly the tied set and gives accuracy 0.811111 to 0.844444, mean 0.826574, std 0.008324. Seed 42 gives 0.813889.

    The tracked 0.019444424 is 2.3 standard deviations of tie-break noise, not a systematic difference. A float32-faithful replica of Flow's builder, with only its tie-break swapped to a random permutation, reproduces the same distribution.

    Suggested disposition

    Narrow #204 and #205 to their documentation halves, which are genuinely useful and now satisfied: per-node structure is emitted, node ids align across implementations, and first-divergence is reported. Drop the "materially reduce the disparity" criterion, or restate it as "explain the disparity", which is now done.

    Matching sklearn exactly would require reproducing its our_rand_r xorshift bit for bit plus the constant-feature bookkeeping that sets the draw count per node, and tree.flow is shared so #205 moves with #204. That is a lot of machinery to make a benchmark row agree by becoming less accurate.

    Full analysis and the tie census are on #204; PR #426 records the rule in tree.flow and pins it with a test.

  4. godofecht commented on Aug 20, 2026

    @godofecht
    OwnerAuthor

    Closing. All seven children are resolved, and the epic's objective — that parity eligibility must never be treated as identity — is now enforced by machinery rather than by vigilance.

    Where each child landed

    The structural changes that outlast the rows

    Win counts fluctuate between freezes on close rows (10/8/1, 10/9/0, 9/10/0 across the last three) — that is runner variance on rows near parity, now visible on the page rather than hidden inside a ratio. The invariants this epic asked for hold: 19/19 eligible, 0 unresolved, no row admitted through a special exception, and every eligibility decision backed by emitted model state.

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

Metadata

Metadata

Assignees

No one assigned

    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