Skip to content

Commit d9c79de

Browse files
committed
fix(faithfulness): thread COMP composition into report_2x2; correct 2x2 to 31.8%
report_2x2.py recomputed faithfulness on the fly and called the COMP checker with composition=None -- the same over-reporting bug rescore_faithfulness.py fixes elsewhere. Since COMP is ~54% of the dataset, this inflated the headline faithful rate to 45.6%. Thread the real composition (lazy variant_id->composition map from the dataset) for COMP rows only; non-COMP scoring is unchanged. Corrected overall faithful rate: 45.6% -> 31.8% (COMP 58.2% -> 32.7%, parse% 0.0% -> 77.4%). README 2x2 table, per-strategy rates, and COMP/held-out scoring caveats updated to match the regenerated report. run_faith_rescore.sh: switch phase 2 (6 venv-scored models) from the 9-config recompute equivalence path to reuse -- the recompute path spawned parallel compilers + spinning candidate binaries that OOM-crashed the machine and would take weeks; reuse keeps the (correctness-based) equivalence already in the CSV, identical to recompute's fallback for non-overfit candidates, while the COMP structural fix still applies in both modes. Sequential, no compilation.
1 parent ebb8cae commit d9c79de

3 files changed

Lines changed: 55 additions & 7 deletions

File tree

README.md

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,15 @@ The patterns are organized by *why* the compiler fails to fix them:
5656

5757
| | Faithful | Unfaithful | Row |
5858
|---|---|---|---|
59-
| **Fast** | 23.6% | 6.7% | 30.2% |
60-
| **Slow** | 22.0% | 47.7% | 69.8% |
61-
| **Col** | 45.6% | 54.4% | 100% |
59+
| **Fast** | 18.7% | 11.5% | 30.2% |
60+
| **Slow** | 13.0% | 56.7% | 69.8% |
61+
| **Col** | 31.8% | 68.2% | 100% |
62+
63+
Per-strategy faithful rates are close: generic 30.0%, pattern-aware 33.8%, taxonomy-guided 31.5%.
64+
65+
**Faithfulness-scoring caveats.** Two structural factors shape this aggregate, and the headline rate is sensitive to both:
66+
- **COMP composition (≈54% of rows).** COMP variants are scored against their constituent-pattern list (`composition` from `metadata.json`); the COMP checker *requires* it, and without it falls back to a generic regex battery that massively over-reports `FAITHFUL`. Earlier runs omitted it and reported an inflated ~45.6% overall (COMP alone read 58% faithful); both `faithfulness/report_2x2.py` and `scripts/rescore_faithfulness.py` now thread `composition`, which drops COMP to 33% faithful and the overall rate to 31.8%.
67+
- **Held-out patterns (`HO-*`, ≈14% of rows).** These post-cutoff patterns have no dedicated AST checker and fall through to a coarse structural fallback, so they essentially cannot earn a `FAITHFUL` verdict and weigh toward the unfaithful column. Authoring per-pattern held-out checkers is the remaining faithfulness-coverage gap.
6268

6369
### Findings from the sweep
6470

faithfulness/report_2x2.py

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,29 @@
6060
except Exception:
6161
_PATTERNS_BY_ID = {}
6262

63+
# COMP variants carry their constituent pattern list in dataset metadata. The
64+
# COMP checker NEEDS that list: without it, it falls back to a generic regex
65+
# battery that massively over-reports `FAITHFUL` (COMP is ~54% of the dataset,
66+
# so this dominates the aggregate). Build variant_id -> composition lazily so
67+
# non-COMP runs pay nothing, and resolve the dataset relative to the repo root
68+
# so the lookup works regardless of the caller's cwd.
69+
_COMP_COMPOSITION: Optional[dict] = None
70+
71+
72+
def _composition_for(variant_id: str):
73+
global _COMP_COMPOSITION
74+
if _COMP_COMPOSITION is None:
75+
_COMP_COMPOSITION = {}
76+
try:
77+
from pdob_core.dataset_evaluator import discover_variants # type: ignore
78+
for v in discover_variants(str(_HERE.parent / "dataset")):
79+
comp = v.metadata.get("composition") if getattr(v, "metadata", None) else None
80+
if comp:
81+
_COMP_COMPOSITION[v.variant_id] = comp
82+
except Exception:
83+
pass
84+
return _COMP_COMPOSITION.get(variant_id)
85+
6386

6487
# --------------------------------------------------------------------------
6588
# Instrumentation: wrap PatternChecker.check + _parse so we can report
@@ -229,7 +252,16 @@ def _compute_faithfulness_for_row(
229252

230253
_INSTR.reset()
231254
try:
232-
result = check_faithfulness(pid, slow_code, llm_code)
255+
if pid == "COMP":
256+
# Thread the composition so COMPChecker scores the actual
257+
# constituent transforms instead of the over-reporting regex
258+
# fallback. Mirrors scripts/rescore_faithfulness.py.
259+
result = check_faithfulness(
260+
pid, slow_code, llm_code,
261+
composition=_composition_for(row.get("variant_id", "")),
262+
)
263+
else:
264+
result = check_faithfulness(pid, slow_code, llm_code)
233265
except Exception:
234266
return (Verdict.UNKNOWN, _INSTR.last_path)
235267
return (result.verdict, _INSTR.last_path)

scripts/run_faith_rescore.sh

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,21 @@ for m in $OLD; do for s in generic pattern-aware taxonomy-guided; do
2020
$PY scripts/rescore_faithfulness.py "$f" --equivalence reuse
2121
done; done
2222

23-
echo "=== [2/4] recompute faithfulness: 18 venv-scored cells (recompute 9-config equiv, slow) ==="
23+
# [2/4] The 6 venv-scored models had their equivalence axis degraded to
24+
# correctness-based single-config (faithfulness_equivalent == correct on every
25+
# row). Full 9-config recompute would re-run differential equivalence on ~22k
26+
# rows; ~39% are timeout-prone broken candidates costing up to 30s x 9 configs
27+
# each -> weeks single-threaded on a laptop (and the compile+spin load OOM-crashed
28+
# the machine last attempt). We therefore reuse the stored (correctness-based)
29+
# equivalence -- identical to what recompute falls back to for any non-overfit
30+
# candidate. The composition-aware COMP structural fix (the actual point of this
31+
# rescore) is recomputed in BOTH modes. Bounded limitation: no 9-config overfit
32+
# detection on the equivalence axis for these 6 models. Sequential, no compilation.
33+
echo "=== [2/4] recompute faithfulness: 18 venv-scored cells (reuse equiv, fast) ==="
2434
for m in $NEW; do for s in generic pattern-aware taxonomy-guided; do
2535
f="results/pareto/${m}_${s}_scored.csv"
26-
echo " recompute ${m}_${s}"
27-
$PY scripts/rescore_faithfulness.py "$f" --equivalence recompute
36+
echo " reuse ${m}_${s}"
37+
$PY scripts/rescore_faithfulness.py "$f" --equivalence reuse
2838
done; done
2939

3040
echo "=== [3/4] rebuild combined + lean CSVs ==="

0 commit comments

Comments
 (0)