penfever's picture
v2: document test.sh reward-recording fix
7ce8aac verified
|
Raw
History Blame Contribute Delete
2.57 kB
---
language:
- en
license: apache-2.0
task_categories:
- text-generation
size_categories:
- 1K<n<10K
tags:
- agent
- code
- code-contests
- harbor
- reinforcement-learning
- rlvr
---
# code-contests-noblock
Harbor-format competitive-programming RL tasks (8,728 tasks) derived from CodeContests.
Each task is a Harbor task binary (gzip tar) stored in `tasks.parquet` with columns
`path` (str, `<task_id>.tar.gz`) and `task_binary` (binary). Each tar contains
`instruction.md`, `task.toml`, `environment/Dockerfile`, and a `tests/` verifier
(`test.sh`, `test_state.py`, `test_data.json`).
## v2 (current) — verifier reward-recording fix
> **Resolves a silent reward-distribution bias.** All 8,728 task verifiers are updated;
> task content (instructions, environments, tests, test data) is otherwise byte-identical to v1.
The v1 `tests/test.sh` ran pytest under `set -euo pipefail`:
```bash
set -euo pipefail
pytest --ctrf /logs/verifier/ctrf.json /tests/test_state.py -rA # aborts the script on test failure
if [ $? -eq 0 ]; then echo 1 > /logs/verifier/reward.txt; else echo 0 > /logs/verifier/reward.txt; fi
```
Under `set -e`, a failing solution makes pytest exit non-zero and the script **dies before
`reward.txt` is written**. Harbor then finds the verifier dir (with `ctrf.json`) but no reward
file and raises `RewardFileNotFoundError`. The net effect:
- Failed solutions (legitimate `reward=0`) **crash instead of recording 0**, so they are dropped
from generated trace sets rather than counted.
- The surviving reward distribution collapses to a single `1.0` bucket — useless for any config
that needs the success/failure signal — and reported mean reward is inflated.
v2 wraps pytest so the script never dies on a test failure and **always** records a reward:
```bash
set +e
pytest --ctrf /logs/verifier/ctrf.json /tests/test_state.py -rA
PYTEST_EXIT=$?
set -e
if [ $PYTEST_EXIT -eq 0 ]; then echo 1 > /logs/verifier/reward.txt; else echo 0 > /logs/verifier/reward.txt; fi
```
This matches the correct pattern already used by the Nemotron task verifiers (which had zero
`RewardFileNotFoundError`s for exactly this reason).
The buggy original remains resolvable at the [`v1`](https://huggingface.co/datasets/DCAgent/code-contests-noblock/tree/v1) tag.
```python
from huggingface_hub import hf_hub_download
hf_hub_download("DCAgent/code-contests-noblock", "tasks.parquet", repo_type="dataset") # v2 (fixed)
hf_hub_download("DCAgent/code-contests-noblock", "tasks.parquet", repo_type="dataset", revision="v1") # original
```