Skip to content

Add human-eval-infilling (FIM) benchmark + code_fim resource server - #1258

Merged
bxyu-nvidia merged 3 commits into
NVIDIA-NeMo:mainfrom
gwarmstrong:georgea/migrate-gym-human-eval-infilling-on-main
May 8, 2026
Merged

bxyu-nvidia merged 3 commits into
NVIDIA-NeMo:mainfrom
gwarmstrong:georgea/migrate-gym-human-eval-infilling-on-main

Conversation

@gwarmstrong

Copy link
Copy Markdown
Contributor

Add human-eval-infilling (FIM) benchmark

Summary

  • Migrates the HumanEval-Infilling (Bavarian et al., 2022) Code Fill-in-the-Middle benchmark from NeMo Skills (nemo_skills/dataset/human-eval-infilling) into NeMo Gym.
  • Adds a small new resource server, code_fim, that splices prefix + completion + suffix + test and runs the spliced program via human_eval_infilling.execution.check_correctness (the same library Skills uses at evaluation time). The server is independent of the existing evalplus server — evalplus handles function-completion (HumanEval+, MBPP+); code_fim handles fill-in-the-middle, which has a different data shape (prefix / suffix / test / entry_point instead of prompt / entry_point / test).
  • Adds the human_eval_infilling benchmark dir, which inherits from code_fim and ships data + prompt + prepare script for the three default difficulty levels (single_line / multi_line / random_span). Default benchmark variant is random_span (matches Skills' EVAL_SPLIT).

Follow-up to the EvalPlus-server / HumanEval+ migration (#1201). All changes are additive — resources_servers/evalplus/ is untouched.

Files added

  • benchmarks/human_eval_infilling/
    • config.yaml — agent + resource-server config, _inherit_from: code_fim
    • prepare.py — fetches the three splits via human_eval_infilling.data.read_problems(...) (the upstream .jsonl.gz files; the HF mirror at loubnabnl/humaneval_infilling is a script-based dataset and is no longer compatible with modern datasets versions, but the gz files are content-equivalent)
    • prompts/default.yaml — char-for-char copy of Skills' nemo_skills/prompt/config/generic/fim.yaml
    • README.md, __init__.py
  • resources_servers/code_fim/
    • app.py — FastAPI / Ray verifier with last-fence + strict-mode code extraction (matches Skills' preprocess_code with strip_whitespace=False), Skills' remove_overlap postprocessing, and a thin Ray-remote wrapper around human_eval_infilling.execution.check_correctness
    • human_eval_infilling_integration/runner.py — Ray-remote shim, mirrors the pattern in resources_servers/evalplus/evalplus_integration/runner.py
    • configs/code_fim.yaml, tests/test_app.py (30 tests, all passing), data/example.jsonl + example_rollouts.jsonl + example_metrics.json for CI, pyproject.toml, README.md

Skills → Gym component mapping

Skills component Skills location Gym location
Dataset definition nemo_skills/dataset/human-eval-infilling/__init__.py (METRICS_TYPE=human_eval_infilling, EVAL_SPLIT=random_span) benchmarks/human_eval_infilling/config.yaml
Data preparation nemo_skills/dataset/human-eval-infilling/prepare.py benchmarks/human_eval_infilling/prepare.py
Prompt template nemo_skills/prompt/config/generic/fim.yaml benchmarks/human_eval_infilling/prompts/default.yaml (char-for-char)
Code extraction (preprocess_code, last-fence + strict + strip_whitespace=False) nemo_skills/evaluation/evaluator/code.py::preprocess_code code_fim server's extract_code_strict
Boundary cleanup (remove_overlap against prefix and suffix, drop one leading \n) nemo_skills/evaluation/evaluator/code.py::eval_human_eval_infilling (postprocess_code) code_fim server's postprocess_completion
Verification human_eval_infilling.evaluate.evaluate(...) code_fim server's Ray-remote check_correctness
Metrics class (HumanEvalInfillingMetrics, pass@k on passed) nemo_skills/evaluation/metrics/code_metrics.py code_fim server's compute_metrics (uses compute_pass_majority_metrics with accuracy=passed)

Data parity (Skills vs Gym)

prepare.py produces JSONLs whose per-row fields match Skills byte-for-byte for every shared task_id across all three default splits. Verified via compare_prepare.py:

Split Tasks Gym tasks Common Field mismatches Row-order match
single_line 1033 1033 1033 0 yes
multi_line 5815 5815 5815 0 yes
random_span 1640 1640 1640 0 yes

The compared fields are the ones Skills writes: prefix, suffix, canonical_solution, language, split, comment_delimiter. Gym additionally writes a verifier_metadata.task_id field (= top-level task_id) so the resource server can look up entry_point + test at verify time without bloating the on-disk JSONL.

Verification details (parity with Skills)

The Gym verifier mirrors Skills' eval_human_eval_infilling step-for-step:

  1. Code extraction — strip <think>...</think>, take the LAST fenced block (preferring ```python over ```), strict mode (no closer → empty), no .strip() (FIM uses strip_whitespace=False in Skills since indentation is significant for the spliced program).
  2. Drop one leading \n — LLMs emit ```python\n<fill>```, so the literal newline is part of the fence formatting and not the completion.
  3. remove_overlap(prefix, completion, "following") — strips a tail of prefix that the model re-emits at the head of its completion. Whitespace-only overlaps without a newline are skipped, matching Skills.
  4. remove_overlap(completion, suffix, "preceding") — symmetric: strips a head of suffix that the model re-emits at the tail.
  5. Run — Ray-remote call to human_eval_infilling.execution.check_correctness(problem, completion, timeout=3.0). The check program executed by the upstream library is prefix + completion + suffix + "\n" + test + "\n" + check(entry_point), the same program Skills' evaluator runs.

Why a new code_fim server, not extending evalplus?

The evalplus server on the base branch handles function-completion benchmarks (HumanEval+, MBPP+) by feeding prompt + completion into evalplus.evaluate.check_correctness against base + plus tests. FIM is structurally different:

  • input is prefix + suffix (not just prompt),
  • the spliced program must be prefix + completion + suffix + test,
  • there are no "plus" tests — a single passed verdict per task,
  • the sandboxed runner is human_eval_infilling.execution.check_correctness (a different package), not evalplus.evaluate.check_correctness.

A new directory keeps evalplus's server logic, schemas, and tests untouched, which keeps the parallel MBPP migration that stacks on the same base branch unaffected.

End-to-end smoke test

Ran ng_run + ng_collect_rollouts against https://integrate.api.nvidia.com/v1 with nvidia/nvidia-nemotron-nano-9b-v2 on the 5-row resources_servers/code_fim/data/example.jsonl:

  • 4/5 rollouts produced non-empty output_text
  • 4/5 had code extracted and executed (status populated by the upstream library)
  • 5/5 rewards in [0, 1]
  • Aggregate metrics returned pass@1/accuracy, majority@1/accuracy, pass@1[avg-of-1]/accuracy

The model passes 0% on this small smoke run with max_output_tokens=2048 (the 9B model truncates / mis-indents); a real parity run vs Skills would use a 30B-class model with the larger token budget Skills' baseline uses.

Tests

  • resources_servers/code_fim/tests/test_app.py — 30 tests covering: code extraction (last-fence + strict + no-strip + <think> handling), remove_overlap, postprocess_completion, the verify endpoint (pass / fail / no-code / unknown task / missing task / boundary trim), the metrics layer (pass@k, no_answer tracking, headline-metrics selection), and dataset loading.
  • resources_servers/evalplus/tests/test_app.py — 24 tests pre-existed; all still pass (no regressions).

Licensing

Test plan

  • pytest resources_servers/code_fim/tests/ — 30/30 pass
  • pytest resources_servers/evalplus/tests/ — 24/24 pass (no regressions)
  • Skills-vs-Gym prepare.py byte-equivalence check across all three default splits (1033 + 5815 + 1640 rows, 0 field mismatches, row order matches)
  • End-to-end ng_run + ng_collect_rollouts smoke test against https://integrate.api.nvidia.com/v1
  • Skills-vs-Gym pass@1 / pass@k parity run on a larger model (left to follow-up — same pattern as migrate-gym-human-eval)

Adds the HumanEval-Infilling (Bavarian et al., 2022) Code Fill-in-the-Middle benchmark and a small new `code_fim` resource server that splices prefix + completion + suffix and runs the spliced program via `human_eval_infilling.execution.check_correctness`. Mirrors NeMo-Skills' `eval_human_eval_infilling` evaluator step-for-step (last-fence + strict-mode extraction, leading-newline drop, prefix/suffix overlap trimming). Strictly additive — `evalplus` server unchanged so parallel MBPP migration stacking on the same base branch is unaffected. Three default splits (single_line / multi_line / random_span) byte-equivalent to Skills' prepare.py output (0 field mismatches across 1033 + 5815 + 1640 rows). 30/30 unit tests pass at 99% coverage; existing 24 evalplus tests still pass.

Signed-off-by: gwarmstrong <[email protected]>
@gwarmstrong
gwarmstrong requested a review from a team as a code owner May 7, 2026 18:05
@copy-pr-bot

copy-pr-bot Bot commented May 7, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@cwing-nvidia cwing-nvidia added the env-integration Integrate with existing environments or gyms external to NeMo Gym label May 7, 2026
…uman-eval-infilling-on-main-fixmerge

Signed-off-by: gwarmstrong <[email protected]>

# Conflicts:
#	README.md
@bxyu-nvidia
bxyu-nvidia merged commit 9867939 into NVIDIA-NeMo:main May 8, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

env-integration Integrate with existing environments or gyms external to NeMo Gym

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants