fix(graph): sparse prop='fill' bit-parity with dense + upstream (changes metrics, needs review)#20
Merged
Conversation
…-identical) The CAFAEVAL_SPARSE switch selected not only the confusion-matrix kernel but also the propagation algorithm. Under prop='fill' the sparse path (_propagate_sparse_pushup) diverged from the dense serial sweep on real DAG inputs, shifting NK/LK Fmax by up to 2.2e-3. Root cause: fill is a stepwise leaves-to-roots recurrence where a non-zero intermediate term blocks deeper descendants (it keeps its own value and that value, not the descendant's, flows up). The pushup scattered every input non-zero straight into every ancestor and group-maxed, ignoring those blockers and overshooting (e.g. a parent got a deep leaf's score even though a lower-scored non-zero node sat between them). The dense sweep was already bit-identical to canonical upstream cafaeval fill (BioComputingUP / claradepaolis PK). Fix: route mode='fill' to a new _propagate_sparse_fill that reproduces the recurrence sparsely (walk ont.order, per-row max over each term's children's current values, never overwrite originally-non-zero cells). The fast scatter pushup is retained for mode='max', where it is correct. Result: sparse and dense produce bit-identical propagated matrices (max|diff|=0 across BPO/CCO/MFO); NK/LK/PK Fmax now identical between both paths and equal to the dense (canonical) values. Sparse stays ~5x faster than dense on the fill path. Adds tests/test_propagation_fill_parity.py: the worked blocked-chain counter-example, shared-ancestor and high-tau BPO-shaped rows, plus a 200-trial randomized DAG stress, all asserting sparse == dense == upstream-oracle bit-for-bit. Closes the coverage gap left by the existing self-parity test, which only exercises prop='max'.
frapercan
added a commit
that referenced
this pull request
Jun 25, 2026
Cherry-picks the propagation correctness fix (#20, bdbb103) onto main so PROTEA's git+main pin picks it up. main already has the CSR/sparse-DAG perf (#19); this adds ONLY the prop=fill correctness fix (sparse pushup overshot fill blockers; now bit-identical to dense + upstream, property test included). Metric-changing (tiny, ~0.002 Fmax) but strictly more correct.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary (CORRECTNESS-CRITICAL: changes metric numbers , please review)
The
CAFAEVAL_SPARSEenv switched not only the confusion-matrix kernel but also the propagation algorithm. Underprop="fill"(PROTEA's production default), the sparse path (_propagate_sparse_pushup) and the dense serial sweep produced different propagated prediction matrices on real DAG inputs, shifting Fmax:| Setting | sparse (before) | dense (before) |
|, -|, -|, -|
| NK Fmax | 0.58859 | 0.58914 |
| LK Fmax | 0.61612 | 0.61391 |
| PK Fmax | 0.40195 | 0.40195 |
Which impl was canonical
The dense serial sweep is canonical: it is bit-identical to upstream cafaeval
prop="fill"(BioComputingUP/CAFA-evaluator and claradepaolis/CAFA-evaluator-PK, the fork's ancestors). Verified on 5 hand-worked DAGs plus a 200-trial randomized stress; the dense path matched the upstream oracle in 100% of cases.The sparse pushup was the buggy one.
fillis a stepwise leaves-to-roots recurrence where a non-zero intermediate term blocks deeper descendants (it keeps its own value, and that value, not the descendant's, flows up to the parent). The pushup scattered every input non-zero straight into every ancestor and group-maxed, ignoring those blockers and overshooting. Worked counter-example (chain leaf->mid->root, leaf=1.0, mid=0.5, root=0):This matches the observed "sparse=1.0 where dense=0.86" divergence, concentrated at high tau on biological_process multi-term shared-ancestor rows.
The fix (which impl was fixed)
The sparse path is fixed.
mode="fill"is now routed to a new_propagate_sparse_fillthat reproduces the recurrence sparsely (walkont.order, per-row max over each term's children's current values, never overwrite originally-non-zero cells). The fast scatter pushup is retained formode="max", where it is proven correct. Minimal, localized change to the propagation path only.After: bit-identical
max|diff| = 0.000e+00across BPO/CCO/MFO (including the BPO rows where the bug lived).| Setting | sparse (after) | dense (after) |
|, -|, -|, -|
| NK Fmax | 0.5891445 | 0.5891445 |
| LK Fmax | 0.6139093 | 0.6139093 |
| PK Fmax | 0.4019451 | 0.4019451 |
(Residual ~1e-16 / 1 ULP in some weighted count columns is float reduction-order noise in the counting kernel, downstream of the now-identical propagated matrices, below any metric significance.)
Test added
tests/test_propagation_fill_parity.py: the worked blocked-chain counter-example, shared-ancestor and high-tau BPO-shaped rows, plus a 200-trial randomized DAG stress, all assertingsparse == dense == upstream-oraclebit-for-bit. Closes the coverage gap left by the existing self-parity test, which only exercisesprop="max".Local CI
ruff clean; mypy clean (py3.12 target, matching the CI runner); full
tests/+tests/diff(Phase B) green.Deploy note
PROTEA pins
cafaeval @ git+main. A redeploy will pick this up once it lands onmain. I did NOT bump the pin.