Skip to content

Add LiveCodeBench code generation task - #354

Merged
gregorybchris merged 6 commits into
mainfrom
chrisg/livecodebench-task
Sep 10, 2026
Merged

gregorybchris merged 6 commits into
mainfrom
chrisg/livecodebench-task

Conversation

@gregorybchris

@gregorybchris gregorybchris commented Sep 3, 2026 •

Copy link
Copy Markdown
Collaborator

Ports LiveCodeBench from oe-eval. Contest problems are tagged by contest date, so a model can be scored on problems published after its training data was collected, and solutions are graded by running them against the contest's own test cases.

Builds on #352 (sandbox file staging) and #353 (data file selection), both now merged; this branch is rebased on main and contains only the LiveCodeBench commits.

Tasks and variants

spec prompt and sampling
livecodebench LiveCodeBench's system prompt plus a reasoning line that names no tags ("Provide CONCISE reasoning on how to arrive at the answer."); sampling as oe-eval's ::olmo3:adapt: temp 0.6, top_p 0.95, context-bounded generation, 10 samples, pass@1/5/10
livecodebench:think_tags oe-eval's ::olmo3:adapt prompt, which asks for reasoning inside literal <think> </think> tags
livecodebench:paper oe-eval-internal's ::tulu-thinker_deepseek_no_think_tags, the regime reported in the OLMo 3 paper: the default prompt with no system message
livecodebench:tulu oe-eval's ::tulu — no reasoning instruction, temp 0.2, 2048 tokens
livecodebench:lite oe-eval's ..._lite — the default regime on a single sample, pass@1, for cheap iteration
livecodebench:grpo oe-eval's :grpo::tulu-thinker — temp 1.0, top_p 1.0, 16384 tokens, primary pass@10

Why the default prompt names no tags. The <think>-tag instruction dates from models trained on literal tags whose chat template did not insert them. A template that already opens a thinking block gets asked for something it has done, and a model with no such training is asked to invent a format, so the instruction measured template compliance alongside coding ability. The tag-free line gives both kinds of model the same instruction. The system prompt is the benchmark's own and is kept; the paper regime dropped it, which is available as :paper for reproducing published numbers.

livecodebench is release_v3 (612 problems); livecodebench_hidden is the v4–v6 window after the v3 cutoff (443 problems), registered separately so problems postdating a model's training data can be scored on their own. Both carry all six variants.

Left out: ::tulu-thinker (temp 0.8, superseded by the deepseek regime) and ::olmo3:midtrain (the base regime plus stop sequences). Easy to add if wanted.

What makes this task different

Its fixtures. HumanEval ships a few hundred bytes of assertions per problem; LiveCodeBench ships the contest's real input/output pairs. Measured across release_v3:

  • median problem: tens of KB
  • p90: 10–20MB
  • largest: 92MB compressed, 199MB decoded
  • release total: 2.6GB compressed

Neither oe-eval nor upstream caps them, and capping is not viable: even a 4MB budget truncates 26% of release_v3 problems, keeping a median of 43% of their tests, which would break comparability with published numbers.

Two consequences:

They reach the container as staged files rather than in the command string — the capability added in #352.

They are kept off the instances. build_requests splats instance.metadata into the run's request records, so carrying payloads there would write gigabytes per run. Instances carry a dataset row reference and the scorer reads the payload when it grades.

That row reference is an implicit coupling, so the scorer refuses to grade a row whose question_id does not match the instance. Grading against another problem's tests would score every solution wrong while still producing a plausible-looking number. Alignment was checked across both releases: 612 and 443 instances, all unique ids, zero mismatches.

Grading

A port of the reference harness, staged into the container as a script, following the existing harness/sandbox/scripts/ + get_script() pattern.

  • Call-based problems (LeetCode) invoke a named function on a Solution instance and compare parsed values; a tuple result is not counted as a mismatch, since ground truth is never a tuple.
  • Whole-program problems get stdin fed and stdout compared line by line, with a decimal fallback so numerically equal output is not failed over formatting. if __name__ == '__main__' guards are unwrapped so the program can be called per test case.
  • Compile failures, missing entry points, wrong answers and timeouts are distinguished in the recorded error code. A solution that does not compile is a failed solution, not a failure of the grader.
  • The solution runs in a forked child, as in the reference, under the reference's overall budget of (timeout + 1) * num_tests + 5 seconds. A solution that segfaults, is OOM-killed, or silences the per-case alarm is a failed solution, not a missing verdict. Per-case timeouts use setitimer, so sub-second budgets are enforced rather than dropped.
  • A grading run that cannot be scored raises. No verdict (no python3 in the image, a killed container), a payload that decoded to zero test cases, or an error inside the grader itself raises a SandboxInfrastructureError subclass, which the runner records against the task as lost scores. Previously an undecodable payload scored 1.0 (every solution passes an empty test set) and a missing verdict scored 0.0 with a warning.
  • Answer extraction takes the last fenced block, as the reference does. A reasoning model writes code while it thinks, so earlier blocks are attempts it discarded. The shared extract_code helper takes the first block and falls back to the whole reply, which reliably extracts a draft from such a model; it also cannot strip <think> blocks when a chat template supplied the opening tag and the reply only closes one. Taking the last block sidesteps both, which is why the reference strips no tags at all. This matches oe-eval's extract_code for this task, which also takes the last block, so it is a parity fix rather than a divergence. extract_code is unchanged, so humaneval and mbpp keep their behavior.

Verification

  • Prompts byte-identical to oe-eval across 61 real problems (52 starter-code, 9 stdin) for the think_tags and tulu regimes, checked against an independently constructed copy of oe-eval's template. The default and paper prompts differ from those only in the reasoning line and the presence of the system message, both covered by unit tests.

  • Grader correct on real dataset problems in both modes: correct solutions pass, wrong answers and missing functions fail with the right codes, __main__ guards unwrap, infinite loops time out.

  • End to end in Docker (mock model, release_v3): the grader ran in the container, decoded the compressed blobs there — reporting 14, 14 and 15 cases for the three problems, the real per-problem counts — and returned verdicts the scorer turned into pass@1.

  • Integration test (tests/integration/test_livecodebench_sandbox.py, skipped without Docker) covers what stubs cannot: correct solutions to a whole-program and a call-based problem both score 1.0 through the real staging path, a wrong one scores 0.0, and the grader in the container saw more test cases than the row's public ones.

  • A real model on GPU (Qwen/Qwen2.5-Coder-7B-Instruct, vLLM on one L40, livecodebench:lite, 50 problems of release_v3): pass@1 = 0.4200, 50/50 instances scored in 51s.

    The verdict breakdown is what makes that number trustworthy rather than merely plausible:

    outcome count
    passed 21
    wrong answer (-2) 26
    timeout (-3) 2
    compile error (-4) 1

    Failures are overwhelmingly wrong answers, with a single compile error. A run whose failures are mostly compile errors means extraction is broken, not that the model is weak — which is exactly what an earlier run with a different model showed before the extraction fix above (37 compile errors, 13 with no verdict, pass@1 = 0.0). All 50 replies contained a fenced block and all 50 arrived as clean text.

  • 44 unit tests for prompts, release selection, variants, extraction, the scorer, and the grader, including the zero-test, crashed-interpreter, disarmed-alarm and sub-second-timeout cases. Full suite: 2252 passed, 8 skipped.

  • Test-case counts across both releases, from the decoded payloads: release_v3 has a median of 15 and a maximum of 103 cases per problem, v4–v6 a median of 42 and a maximum of 52. The reference budget for the largest problem is 726s, under the scorer's 900s ceiling.

Still open

Parity is not yet demonstrated. The run above proves the pipeline is sound end to end, but I have no oe-eval number for this model on release_v3 to compare against. A true parity check needs the same model and regime through both harnesses; cheap to do now that the path works.

Unrelated issues noticed while testing

None of these are caused by this PR, and all three cost a failed launch:

  • ai2/oe-base is deprecated. It is the Beaker launcher's built-in default and appears in the README seven times, so launching from the documented example fails with [code=422] deprecated budget.
  • job_assembler.py:470 derives the vLLM venv layout from the harness provider kind while the runtime uses the model preset's kind. For a kind: vllm preset with a sandbox harness, vLLM is installed in an isolated venv the worker cannot import from, and the job dies at startup. This affects 10 of the 11 vLLM model presets and cannot be worked around from the CLI — a raw HuggingFace model id has to be passed instead of the preset, which is what this PR's testing did.
  • The codex_python harness preset cannot start locally: its image has no swerex-remote, and the preset sets neither inject_swerex nor a startup timeout above 60s, so every instance fails. codex_universal sets both. Worked around with an inline sandbox override rather than changing the preset here.

🤖 Generated with Claude Code

@abhishekraok abhishekraok left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Claude Code · https://claude.ai/code/session_01RcHPnv8oDU2PHDofoNBQDz

Reviewed at f0c765f (the LiveCodeBench commits are unchanged from the original push; only the base moved). ruff clean, ty at 11 diagnostics (same as main), full unit suite passes.

Parity, verified independently against oe-eval and the dataset's loading script: templates and sampling params for ::olmo3:adapt, ::tulu, :grpo::tulu-thinker match tasks.py character-for-character; the last-block extraction matches oe-eval's extract_code (indexlines[-2]:indexlines[-1]), so the second commit is a parity fix, not a divergence — worth saying so in the body; RELEASE_V3_FILES / RELEASE_V4_V6_FILES match ALLOWED_FILES["release_v3"] / ["v4_v6"], order preserved.

Major — each turns a grading failure into a plausible number

1. A test payload that fails to decode scores 1.0. decode_test_cases returns [] on any exception, both grade functions return True on an empty loop, and the scorer reads only passed. Reproduced with the grader as shipped:

undecodable blob, call-based:           {"passed": true, "num_tests": 0}
undecodable blob, stdio, wrong program: {"passed": true, "num_tests": 0}

The grader already reports num_tests; have the scorer treat num_tests == 0 as a grading failure. oe-eval has the same hole (all(r is True for r in [])), but reading the row lazily in the container adds a new way to reach it — a MemoryError decoding a 92MB blob lands in that bare except Exception.

2. timeout below 1s disables the per-case timeout entirely. int(problem.get("timeout", 6)) → signal.alarm(0), which cancels the alarm. LiveCodeBenchScorer.timeout is a float field, so timeout=0.5 looks legal. Reproduced: an endless loop with timeout=0.5 never terminates; timeout=2 correctly gives -3. signal.setitimer, or max(1, int(...)).

3. A missing verdict is scored 0.0, not raised. No python3 in the image, an OOM-killed grader, a segfault (plausible — the prelude sets setrecursionlimit(50000) and, unlike oe-eval's forked child, the solution runs in the grader's own process) → _parse_verdict is None → 0.0 with a logger.warning. A misconfigured image publishes a clean pass@1 of 0.0 for the whole run. The row-alignment RuntimeError already sets the precedent; raising here engages max_hard_failure_rate instead.

Should fix before a real run

4. ascore does its heavy lifting on the event loop. _test_case_rows(...), the Arrow row read, and json.dumps(problem) are synchronous inside async def. Measured json.dumps alone: 75 ms at a 20MB payload, ~490 ms at the 92MB worst case — and swerex re-serializes the same string into the request body, so roughly double. Over 612 × 10 samples that's minutes of aggregate loop stall blocking every in-flight inference request. asyncio.to_thread for the read + dumps.

Minor

5. overall_timeout is a flat 900s where oe-eval uses (timeout+1)*num_tests + 5; a correct-but-slow solution on a problem with >~150 cases is killed here and allowed there.
6. rm -rf rides on the command string, so it doesn't run when the outer timeout kills the command — up to a few hundred MB of problem.json leaks per timeout on a pooled executor. Prepend a sweep of stale /tmp/lcb-*.
7. zip(inputs, outputs, strict=False) silently truncates a length mismatch (matches upstream; combined with #1 an under-length outputs quietly shrinks the test set). A module-level while True in call-based mode reports -4 rather than -3.
8. test_private_test_cases_reach_the_container asserts only that '"num_tests"' appears in the output, not that the count exceeds the public cases, which is what its docstring claims. Nothing covers the zero-test case.

1–3 before merge; 4 before the first vLLM run. The codex_python preset issue in the body deserves its own issue so it doesn't get buried.

@gregorybchris
gregorybchris force-pushed the chrisg/livecodebench-task branch 2 times, most recently from e3102b6 to 6d6d6d8 Compare September 9, 2026 16:57
gregorybchris and others added 5 commits September 9, 2026 11:10
LiveCodeBench collects programming contest problems tagged by contest date,
so a model can be scored on problems published after its training data was
collected. Solutions are graded by running them against the contest's own
test cases.

Two tasks are registered: livecodebench (release_v3, 612 problems) and
livecodebench_hidden (v4-v6, 443 problems, the contest window after the v3
cutoff), each with tulu, lite and grpo variants. Defaults mirror oe-eval's
livecodebench_codegeneration::olmo3:adapt, and prompts were checked byte
identical to oe-eval's across 61 problems in both the thinking and
non-thinking regimes. The older ::tulu-thinker regime and the midtrain
variant are left out until something needs them.

What makes this task unlike the repo's other code evals is the size of its
fixtures. Where HumanEval ships a few hundred bytes of assertions per
problem, LiveCodeBench ships the contest's real input/output pairs: the
median problem carries tens of kilobytes, p90 is 10-20MB, and the largest is
92MB compressed. They reach the container as staged files for that reason.

They are also kept off the instances. Instance metadata is written into the
run's request records, so instances carry a dataset row reference and the
scorer reads the payload when it grades. Row alignment was checked across
both releases, and the scorer refuses to grade a row whose question id does
not match the instance, since grading against another problem's tests would
score every solution wrong while still looking like a plausible result.

Grading is a port of the reference harness, staged into the container as a
script. Call-based problems invoke a named function and compare parsed
values; whole-program problems get stdin fed and stdout compared line by
line, with a decimal fallback so that numerically equal output is not failed
over formatting. A solution that does not compile is a failed solution rather
than a failure of the grader.

Verified end to end against a live run (mock model, release_v3, Docker): the
grader ran in the container, decoded the compressed test blobs there, and
returned verdicts the scorer turned into pass@1. The integration test covers
what a stub cannot, asserting that correct solutions to a whole-program and a
call-based problem both score 1.0 through the real staging path; it is
skipped when Docker is unavailable.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
(cherry picked from commit 2c21ba3)
(cherry picked from commit e643d60)
A model's reply is not one code block. A reasoning model writes code while it
thinks, so the reply usually holds several: earlier attempts it went on to
discard, and the answer last. The reference implementation takes the last
block for that reason, and returns nothing when the reply holds fewer than
two fence markers, meaning no complete block.

This port used the shared extract_code helper, which takes the first block and
falls back to the entire reply when it finds no fence. On a reasoning model
that reliably extracts a draft rather than an answer.

Stripping <think> blocks does not solve it either, and the shared helper's
attempt to do so cannot fire here: a chat template that supplies the opening
tag leaves the reply closing a tag it never opened, so a pattern needing a
matched pair matches nothing. Taking the last block sidesteps the question,
which is why the reference implementation does not strip tags at all.

The helper keeps its current behavior for humaneval and mbpp, which pass a
single block and rely on the fallback.

Found by inspecting the generations from a real model run, where every problem
scored zero. Extraction was one of two causes; the other was that the
generations came back without being detokenized, which no extractor can
recover from and which is not specific to this task.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
(cherry picked from commit 7c856ae)
(cherry picked from commit 8286658)
…pty test set

The grader now runs the solution in a forked child, as the reference
harness does, and enforces the reference's overall budget of
(timeout + 1) * num_tests + 5 seconds from the parent. A solution that
segfaults, is killed for memory, or silences the per-case alarm is
reported as a failed solution instead of leaving no verdict for the
harness to read.

A test payload that decodes to nothing used to pass every solution,
because both grade loops return True over an empty list. Decoding
failures now surface in the verdict with the reason, and the verdict
always carries num_tests so the harness can refuse to score an empty
set.

Per-case timeouts use setitimer, since signal.alarm truncates a budget
under one second to no alarm at all. A module body that never finishes
is reported as a timeout rather than a compilation error, a function
that calls sys.exit is a runtime error, and the input/output lists are
zipped strictly.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
… a failure

A grader that never reported, found no test cases, or failed inside
itself used to score the solution 0.0 with a warning, so a misconfigured
image published a clean pass@1 of zero. Those cases now raise a
SandboxInfrastructureError subclass, which the runner records against
the task as lost scores rather than folding into the metric. The row
alignment check raises the same way.

The dataset row read and the JSON encoding of the test payload run in a
worker thread; the largest problems take most of a second, which was
stalling every in-flight request on the event loop. The one-time dataset
load is serialized so concurrent scorers do not each trigger it.

The grader runs under `timeout` so that the shell survives to remove the
staged files when the grader is stopped, and each run first sweeps
directories old enough that no run in flight can own them. The
integration test now checks that the grader saw more cases than the
row's public ones, which is what it claimed to check.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
…ut of task imports

The grader now raises the interpreter's int/str conversion limit as the
reference harness does, so a solution that prints or parses an integer
past 4300 digits is graded rather than failed. Captured stdout survives a
solution closing it, matching the reference's no-op close.

The verdict line carries a marker. The sandbox appends stderr after
stdout, so without one a solution's stderr debug output could be read as
the verdict.

Grading failures raise ScoringIncompleteError, a scorer-level error the
runner records as a lost score. Subclassing the sandbox's infrastructure
error made the task module import the whole harness package at load
time, which nothing else in the task import chain does.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
@gregorybchris
gregorybchris force-pushed the chrisg/livecodebench-task branch from 3a5770f to b570063 Compare September 9, 2026 18:11
@gregorybchris

Copy link
Copy Markdown
Collaborator Author

@abhishekraok thanks for your review! I've addressed your comments and run an extra agentic review for good measure. Ready for your eyes again when you get a sec

@abhishekraok abhishekraok left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Codex · codex://threads/01a0881f-9448-77b0-aa9c-77a3e437171a

Approved as requested. CI is passing; Docker and GPU integration checks were skipped.

@mgmorgan23

Copy link
Copy Markdown
Contributor

I'm not sure if we want to match exactly, but I just want to flag that I think the Olmo3 paper used the livecodebench_codegeneration::tulu-thinker_deepseek_no_think_tags formulation from oe-eval, with sampling parameters set to
"generation_kwargs": {"max_gen_toks": 999999, "truncate_context": false, "do_sample": true, "top_p": 0.95, "temperature": 0.6, "repeats": 10, "stop_sequences": []}, "metric_kwargs": {"pass_at_ks": [1, 5, 10]}},

The default prompt keeps LiveCodeBench's own system prompt but drops the
request to reason inside literal <think> tags. That request dates from
models trained on the tags whose chat template did not insert them. A
template that already opens a thinking block gets asked for something it
has done, and a model with no such training is asked to invent a format,
so the instruction measured template compliance alongside coding
ability. The tag-free line gives both kinds of model the same
instruction.

The previous prompt remains as the think_tags variant. A paper variant
reproduces the regime reported for OLMo 3, which is the default prompt
with no system message.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
@gregorybchris
gregorybchris merged commit 902952b into main Sep 10, 2026
10 checks passed
@gregorybchris
gregorybchris deleted the chrisg/livecodebench-task branch September 23, 2026 22:57
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.

3 participants