You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Epic: drive canonical benchmark from parity-eligible to tightly matched implementations #202
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.
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.
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.
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.
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.
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.
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
Make KMeans trajectory semantics sklearn-compatible and retire the equivalence exception #203 KMeans: fixed outright. The seeded k-means++ initializer now matches scikit-learn's (greedy local trials + MT19937 draw order), Digits ARI went 0.4646 → 0.5283 against sklearn's 0.5283, held-out label agreement 0.79 → 1.00, and the approximate-equivalence exception (kmeans_equivalence_contract.json, finalize_kmeans_parity.py) is deleted. The row passes the normal gate.
Close the Digits KernelSVC quality gap and isolate the libsvm performance deficit #206 KernelSVC: both halves closed. Predict was rebuilt (45 duplicate kernel blocks → one gemm; beats libsvm on the CI runner). Fit had a genuine sign error: eta was computed as K11+K22−2·y1·y2·K12 instead of K11+K22−2·K12, so every mixed-label SMO step undershot by up to 2x. Second-order working-set selection fixed it necessarily; the dual objective now matches libsvm to four decimals (2813.4047) and score_abs_diff went 0.002777767 → 1.2e-8. Fit ratio 20.0x slower → 2.05x.
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.
Activity
godofecht commentedon Aug 18, 2026
Triage: epic still open, one child closed
Audited every child against the frozen canonical evidence on
main(c1e01df).kmeans_equivalence_contract.jsonandfinalize_kmeans_parity.pyboth still active in CI; strict status still "not parity verified"; ARI gap 0.06368score_abs_diffstill 0.019444;model_state_diagnosticsemptyscore_abs_diffstill 0.019444;model_state_diagnosticsemptyscore_abs_diffstill 0.002778; runtime ratio 0.0638 (about 15.7x slower);model_state_diagnosticsempty3deac85; first main-branch freeze atc1e01dfestablished the baselineAgainst the epic's own acceptance criteria:
disparity_report.jsonshowsrows_with_tracked_disparity: 19. Not met at the model-state level: 3 of 19..github/workflows/remaining-issues.ymlcurrently assertsstrict_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.docs/disparity-history.htmlplus the disparity regeneration and history materialization steps in.github/workflows/pages.yml.The common blocker across #204, #205 and #206 is the same one:
benchmarks/bench_flow_v2.flowemitsDETAIL|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 theDETAIL|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.godofecht commentedon Aug 18, 2026
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
diffof 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
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.godofecht commentedon Aug 19, 2026
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: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:
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_stateover 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_rxorshift bit for bit plus the constant-feature bookkeeping that sets the draw count per node, andtree.flowis 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.flowand pins it with a test.godofecht commentedon Aug 20, 2026
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
kmeans_equivalence_contract.json,finalize_kmeans_parity.py) is deleted. The row passes the normal gate.test_tree_split_tiebreak.flow.etawas computed asK11+K22−2·y1·y2·K12instead ofK11+K22−2·K12, so every mixed-label SMO step undershot by up to 2x. Second-order working-set selection fixed it necessarily; the dual objective now matches libsvm to four decimals (2813.4047) andscore_abs_diffwent 0.002777767 → 1.2e-8. Fit ratio 20.0x slower → 2.05x.--require-completeenforced in CI. These diagnostics directly produced the Make KMeans trajectory semantics sklearn-compatible and retire the equivalence exception #203 fix (the singleton-centre-norm lead), the Reduce Digits DecisionTree predictive disparity and compare learned tree structure #204/Reduce Digits RandomForest disparity and align bootstrap / per-tree randomness #205 diagnosis (first-divergent-node), and the Close the Digits KernelSVC quality gap and isolate the libsvm performance deficit #206/SMO working-set selection: 98.4% of _smo_step calls make no progress, and the solver is 96% of KernelSVC fit #412 evidence (per-pair duals).The structural changes that outlast the rows
alpha=0.001againstC=1.0(LogisticRegression coefficient norm is 2x sklearn's at identical accuracy, suggesting the penalty is not being applied equivalently #408 → fix: match sklearn's C=1.0 in the canonical LogisticRegression benchmark (#408) #430), and the multiclass objective now matches (multinomial softmax, LogisticRegression fits one-vs-rest where sklearn fits multinomial softmax #433 → feat: fit multinomial softmax for multiclass logistic regression #434). 19/19 held after both corrections, on honest terms.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.