Skip to content

Add canonical model-state parity diagnostics for every headline estimator #207

Closed

Description

@godofecht

Parent: #202

Problem

The canonical benchmark currently tracks final predictive/objective metrics very well, but many estimators can produce similar scores from materially different learned states. A pass/fail score tolerance is therefore not enough to explain implementation differences.

Work

Define estimator-specific model-state diagnostics for all 19 canonical rows, including where applicable coefficients/intercepts, support vectors/dual coefficients, tree structure, ensemble member state, cluster centers/inertia/iteration count, PCA components/singular values/explained variance, class priors/means/variances, and solver iteration/convergence statistics. Use sign/permutation alignment where mathematically required and store raw/normalized deltas in a machine-readable artifact joined into disparity_report.json.

Implementation progress

PR #331 establishes the generic learned-state evidence layer instead of hard-coding estimator HTML. Existing *_diff state diagnostics are promoted into model_state_diagnostics, model-state becomes its own disparity dimension, and the disparity artifact counts rows with learned-state coverage.

A new model_state_coverage.py audit enumerates all 19 canonical rows as covered or missing and lists the exact state diagnostic keys for each covered row. CI generates and uploads this coverage artifact and verifies it remains aligned with the canonical row set. The script already supports --require-complete; that will become the hard gate once all rows have state evidence.

The first pass exposed 2/19 covered rows. A follow-up on #331 fixed an evidence-loss bug for failed strict score gates: both KMeans implementations already emit inertia and iteration count for Digits, but the previous comparison stopped before retaining them. The disparity generator now derives those state deltas directly from the frozen DETAIL records, so 3/19 rows are covered and 16/19 are missing.

Current covered rows are Iris KMeans, Digits KMeans, and Iris PCA. For Digits KMeans specifically, the canonical frozen evidence shows a large ARI trajectory gap (~0.06368) alongside only ~0.1044% final-inertia difference and a 22-vs-19 iteration-count difference. That distinction is now persistent even while the row remains approximately equivalent at the headline level.

The highest-value missing state work remains Digits DecisionTree, RandomForest and KernelSVC, followed by coefficient/state diagnostics for the linear estimators and GaussianNB priors/means/variances.

This issue remains open after #331: the coverage artifact is deliberately intended to expose and drive the remaining estimator-specific state work rather than treating score parity as completion.

Activity

  1. godofecht commented on Aug 18, 2026

    @godofecht
    OwnerAuthor

    Triage: partially done, staying open

    PR #331 landed as 8936641 ("Expose canonical learned-state diagnostic coverage"). The evidence layer exists; the estimator-specific state work does not.

    What is on main:

    • benchmarks/generate_disparity_report.py promotes every *_diff diagnostic into a model_state_diagnostics field, adds model-state as its own entry in disparity_dimensions, and parses DETAIL| records directly so a failed strict score gate cannot erase state evidence.
    • benchmarks/model_state_coverage.py enumerates all 19 canonical rows as covered or missing and lists the state diagnostic keys per covered row. It supports --require-complete, which is not yet wired as a hard gate.
    • .github/workflows/disparity.yml runs the coverage audit, asserts coverage["counts"]["canonical_rows"] == 19 and that covered rows match rows_with_model_state_diagnostics, and uploads model_state_coverage.json as an artifact.

    What the frozen artifact actually shows. benchmarks/disparity_report.json at c1e01df reports "rows_with_model_state_diagnostics": 3 out of 19. The three covered rows are:

    row state keys
    iris KMeans inertia_relative_diff, n_iter_abs_diff
    digits KMeans inertia_relative_diff, n_iter_abs_diff
    iris PCA explained_variance_ratio_abs_diff, singular_values_relative_diff, reconstruction_mse_abs_diff, component_0_sign_aligned_abs_diff, component_1_sign_aligned_abs_diff

    The other 16 rows emit no learned state at all. The root cause is upstream of the report: benchmarks/bench_flow_v2.flow emits DETAIL| records only for KMeans (iris, digits) and PCA (iris), at lines 236-237, 250-254 and 299. Nothing for the tree, ensemble, SVM, linear or naive-Bayes rows.

    Remaining work: emit DETAIL| state records from both implementations for the 16 uncovered rows (tree structure for #204, per-tree and ensemble state for #205, support vectors and dual coefficients for #206, coefficients and intercepts for the linear rows, priors/means/variances for GaussianNB), then flip model_state_coverage.py --require-complete on in CI.

  2. godofecht commented on Aug 18, 2026

    @godofecht
    OwnerAuthor

    PR #402 extends DETAIL| emission to every canonical row on both runners and
    makes generate_disparity_report.py pair the records generically instead of
    special-casing KMeans. Measured locally against freshly generated raw evidence,
    coverage goes from 3/19 to 19/19 and model_state_coverage.py --require-complete exits 0.

    Emitted per estimator: coefficients and intercepts for the linear models;
    one-vs-one support counts, bounded-support counts, summed dual coefficients,
    gamma and per-pair intercepts for KernelSVC; full preorder split vectors plus a
    per-depth node census and split-feature histogram for DecisionTree; per-tree
    structure, bootstrap checksums, unique-sample fractions and vote-margin
    statistics for RandomForest; class priors and per-class mean/variance norms for
    GaussianNB; center norms and cluster sizes for KMeans; dual-coefficient
    statistics for KernelRidge. benchmarks/README.md carries the full table and the
    summarisation rationale.

    The report also now records <field>_first_divergent_index for equal-length
    vectors, so Digits DecisionTree resolves to node 4 rather than just "the trees
    differ".

    Every canonical RESULT| line is byte-identical to origin/main on an identical
    local run, and DETAIL| output is identical across three consecutive runs, which
    also confirms nothing reads the uninitialised tree fields from #359.

    This issue should stay open. disparity.yml regenerates
    disparity_report.json from the committed flow_results_v2.txt and
    sklearn_results_v2.txt, which are refreshed by the freeze-results job on
    pushes to main and are kept out of feature-branch diffs. The disparity job will
    keep reporting 3/19 until that freeze runs after #402 merges. --require-complete
    should be added to .github/workflows/disparity.yml as a follow-up once the
    frozen evidence shows 19/19, not before.

    Still uncovered after #402: leaf class distributions for trees (blocked on #359,
    since TreeNode.value is unwritten on internal nodes in a malloc'd array),
    per-node structure inside forest members, per-phase timing for KernelSVC (needs
    timers inside svm.flow, the known victim of compiler bug #469), individual
    support vectors and dual coefficients, and any measure of how many test samples
    the two implementations actually label differently.

  3. godofecht commented on Aug 19, 2026

    @godofecht
    OwnerAuthor

    Closing. Coverage is complete and now enforced.

    Where this landed

    On current main:

    {"canonical_rows": 19, "covered_rows": 19, "missing_rows": 0}
    

    The assertion change matters on its own. covered_rows > 0 would have passed with a single covered row, which is precisely how coverage sat at 3/19 without the gate objecting. I verified the new gate bites rather than merely passing: clearing model_state_diagnostics on one row makes the step exit 1.

    What the diagnostics actually produced

    Worth recording, since the issue's value was always downstream:

    Depth gaps that remain, deliberately not blocking this

    These are recorded rather than dropped: leaf class distributions, per-node forest structure (only per-tree scalars today), raw bootstrap indices rather than a checksum, individual support vectors and dual coefficients for KernelSVC, and per-phase KernelSVC timing which #206 wants. None of them is needed for the coverage criterion this issue set.

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