fix: eval script bugs and add missing features

- evaluate_mmlu: fix double few-shot injection (build_prompt no longer
  adds few-shot, apply_chat handles it once)
- evaluate_humaneval: fix pass@k k-filtering to be per-problem instead
  of using first problem's n globally; reuse ProcessPoolExecutor across
  problems; fix closure UnboundLocalError in test_one; handle None in
  report when k > n
- evaluate_ifd: remove dead code (score_plain/score_messages); add
  multi-file/directory input support with --input_path/--output_dir;
  add summary.json aggregation and --max_samples; add --dtype flag
- evaluate_ppl: add --device and --dtype flags (was hardcoded to cuda)
- evaluate_ifeval: fix docstring path (scripts/tools -> scripts/eval)
- analyze_weights: add --output JSON export; fix dead code filter
  ("_norm" not in r was always True)
This commit is contained in:
2026-07-17 14:02:58 +08:00
parent b12b24eadc
commit c17aa0dc54
6 changed files with 209 additions and 126 deletions
+16 -2
View File
@@ -117,7 +117,7 @@ def print_component_summary(results: dict[str, dict], title: str):
r["er_99_norm"]
for vs in matrix_groups.values()
for r in vs
if "_norm" not in r or not r.get("is_1d")
if not r.get("is_1d")
]
if all_er:
m = sum(all_er) / len(all_er)
@@ -232,8 +232,16 @@ def main():
action="store_true",
help="Skip SVD analysis, only show weight statistics (mean/std/min/max).",
)
parser.add_argument(
"--output",
type=str,
default=None,
help="Save results as JSON to this path.",
)
args = parser.parse_args()
all_results = {}
def analyze_one(ckpt_dir: str, label: str):
ckpt_dir = Path(ckpt_dir)
weights_path = ckpt_dir / "model.safetensors"
@@ -294,13 +302,19 @@ def main():
)
print_layer_grid(results)
print_weight_stats(results)
all_results[label] = results
return results
analyze_one(args.ckpt_dir, "Primary")
if args.compare:
for cdir in args.compare:
analyze_one(cdir, "Compare")
analyze_one(cdir, f"Compare_{cdir}")
if args.output:
with open(args.output, "w", encoding="utf-8") as f:
json.dump(all_results, f, indent=2)
print(f"\nResults saved to {args.output}")
if __name__ == "__main__":