Skip to content

fix: core evaluator/cache/utils correctness fixes#1378

Open
Luodian wants to merge 2 commits into
mainfrom
fix/core-eval-correctness
Open

fix: core evaluator/cache/utils correctness fixes#1378
Luodian wants to merge 2 commits into
mainfrom
fix/core-eval-correctness

Conversation

@Luodian

@Luodian Luodian commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Core evaluator / cache / utils correctness fixes

A cluster of standalone correctness fixes for the eval pipeline, response cache, and utils. No new dependencies; all changes are additive or in-place bug fixes.

lmms_eval/caching/cache.py

  • save_to_cache accumulated per-item results into serializable_item and appended to serializable_obj. Before, the loop mutated subitem.arguments but never appended anything, so the cache always pickled an empty list.
  • Reviewer caveat: the request cache key does not fingerprint dataset contents, so with --cache_requests (opt-in, default off) a dataset changed in place under an unchanged task config will reuse stale requests. That key design predates this PR — flagging it because the cache now actually works and the caveat becomes reachable.

lmms_eval/caching/response_cache.py

  • Task fingerprinting now recurses into nested task groups (_collect_fingerprints), so subtasks get real config fingerprints instead of silently falling back to empty strings.

lmms_eval/evaluator.py

  • Secret redaction: sensitive keys are redacted from results["config"] before it is written out. Matching is suffix-based (*api_key / *_token / *_secret / *password, plus the exact-name set and key=value assignments inside model_args strings), so openai_api_key= and friends don't slip through.
  • Padding aliasing fix: rank-padding built [pad_source] * n, aliasing a single Instance so all padding requests shared one resps/token_counts list. Now each padding slot is a distinct isolated clone (_clone_padding_request inside the loop).
  • Multi-rank auto-init (torchrun path only): on distributed_executor_backend="torchrun", when world_size > 1 and torch.distributed is uninitialized, auto-init a gloo process group so backends that never call init_process_group don't crash evaluator collectives — guarded on MASTER_ADDR/MASTER_PORT being present (clear warning + skip otherwise, instead of raising). The default accelerate path is untouched: the evaluator's Accelerator() fallback creates its own state, so GPU collectives are never silently downgraded onto a pre-created gloo group.
  • torchrun gather fix: all_gather_into_tensor now uses a 1-D input tensor and a world_size-sized buffer.
  • Defensive skip: docs that land in a rank's shard with no requests are skipped instead of crashing at requests[0].doc.

lmms_eval/utils.py

  • Robust get_git_commit_hash / get_git_branch_name: anchored at the repo root (works regardless of CWD), with env fallbacks (LMMS_EVAL_GIT_COMMIT / GIT_COMMIT / GITHUB_SHA, LMMS_EVAL_GIT_BRANCH / GIT_BRANCH / BRANCH_NAME / GITHUB_REF_NAME) and detached-HEAD handling.
  • Local dataset builders (csv/json/parquet/text/pandas/arrow) now resolve relative dataset_kwargs.data_files paths to absolute against the YAML dir; HF-hub dataset paths are left untouched.
  • py3.13 fix: re.split(..., maxsplit=maxsplit) (positional maxsplit is deprecated in 3.13).

Validation

  • py_compile clean on all four files; pre-commit black+isort clean; ruff introduces no new findings.
  • Ported helpers unit-exercised: git resolution + env fallbacks + detached HEAD, data_files resolution, secret redaction (prefixed keys + string-form assignments), and padding-clone isolation (N distinct objects for N slots).

Review pass (2026-07-06)

Self-review follow-up commit: gated the gloo auto-init to the torchrun path with the MASTER_ADDR/PORT guard (see above), moved the padding clone inside the loop so slots are truly isolated, switched redaction to suffix matching, and dropped an unused build_eval_output_dir helper that had no callers.

Luodian added 2 commits July 6, 2026 18:24
- cache.save_to_cache: accumulate serializable_obj per item (previously
  mutated subitems but never appended, so it always pickled an empty list)
- response_cache: recursively fingerprint nested task groups so subtasks
  get real fingerprints instead of falling back to empty strings
- evaluator:
  - redact api_key/token/hf_token-style values from results.config
  - clone padding Instances so [pad_source]*n no longer aliases one object
  - auto-init a gloo process group and inject lm._rank/_world_size for
    multi-rank launches whose backend never called init_process_group
  - fix torchrun all_gather_into_tensor (1-D input tensor, world_size buffer)
  - defensively skip docs with no requests in the postprocess loop
- utils:
  - repo-root-anchored git commit/branch helpers with env fallbacks
    (LMMS_EVAL_GIT_COMMIT/GITHUB_SHA/GITHUB_REF_NAME) and detached-HEAD handling
  - build_eval_output_dir helper
  - resolve relative dataset_kwargs.data_files to absolute paths for local
    csv/json/parquet builders
  - py3.13 re.split(maxsplit=) keyword fix
@Luodian Luodian marked this pull request as ready for review July 6, 2026 13:56
@Luodian Luodian requested review from kcz358 and pufanyi July 6, 2026 13:57
@Luodian

Luodian commented Jul 6, 2026

Copy link
Copy Markdown
Contributor Author

@kcz358 @pufanyi This batch of 12 PRs (#1378#1389) upstreams fixes and features from our fork — all now ready for review. Every PR went through a full review pass today; findings were fixed on the branches and each PR body has a "Review pass (2026-07-06)" section summarizing what changed. A map to make this reviewable:

Suggested merge order — plain numeric order (#1378#1389) avoids all conflicts. The actual constraints:

What's in the batch:

PR Area
#1378 core evaluator / cache / utils correctness fixes
#1379 new verifiers module (pluggable per-sample verification)
#1380 opt-in strip-thinking filter (TaskConfig.auto_strip_thinking)
#1381 llm_judge OpenAI providers: base URL, reasoning-model params, PIL images
#1382 gemini → google-genai SDK migration (video/audio upload, concurrency)
#1383 HTTP eval server job-scheduler fixes
#1384 remove Lance-based data paths (public repo = HF/local data only)
#1385 SwanLab logger (--swanlab_args), wandb alternative
#1386 utils fixes across 7 benchmarks
#1387 IntPhys2 + VANTAGE-Bench tasks (PhysBench pulled — see PR for why)
#1388 migrate 10 benchmarks from llm_judge to verifiers (stacked on #1379)
#1389 8 diffusers/API world-model generation backends

CI note — pre-existing, not from this batch: compare-task-input-boundary is currently red on every task-touching PR in the repo (including merged #1374#1376). Root cause: lmms_eval/tasks/mmmu/utils.py builds the LLM-judge client at import time (module-level server = get_server(...)), and the CI runner has no OPENAI_API_KEY, so the snapshot tool crashes while importing mmmu_val from its spec — before any comparison happens. Same reason --tasks mmmu_val fails for anyone without an OpenAI key. Happy to send a small follow-up making that init lazy, which would turn the check green repo-wide.

Ping me here or on the individual PRs with anything.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant