Repository navigation
fix(environments): copy the raw JSONL in instruction_following and reasoning_gym prepare - #5092
Open
qiaochuz-nv wants to merge 1 commit into
Open
qiaochuz-nv wants to merge 1 commit into
qiaochuz-nv wants to merge 1 commit into
Conversation
…asoning_gym prepare Both prepare.py scripts loaded a single published JSONL through datasets.load_dataset only to write it back out as JSONL. Arrow's JSON reader fails on both files: instruction_following has null entries in kwargs (ArrowIndexError, apache/arrow#51305) and reasoning_gym has metadata values whose JSON type changes between rows (ArrowInvalid). Download the artifact with hf_hub_download and copy it, as simple_strands_math/prepare.py does, so the prepared file is byte-identical to the published one and the shared Hugging Face cache stays intact. NVBug 6805516. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: qiaochuz <qiaochuz@nvidia.com>
Contributor
Author
|
/ok to test 72e7b4c |
This branch was previously deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
python environments/instruction_following/prepare.pyandpython environments/reasoning_gym/prepare.py, theREADME steps that download each environment's training data, now write the published file. Before this
change, both crashed inside Arrow before writing anything.
Fixes NVBug 6805516. Closes #4510.
Cause
Each Hugging Face repo publishes one JSONL file, and both scripts loaded it with
datasets.load_dataset(...)only to
json.dumpsevery row back out. They have done this since they were added (#1403 and #1378).load_datasetreads JSONL with Arrow's JSON reader, which rejects both files, though the data itself is valid:nvidia/Nemotron-RL-instruction_following:kwargsholds one entry per instruction, and 29,268 of46,391 rows have a
nullentry there. Arrow corrupts the list offsets for those rows([Python][JSON] Leading null list elements produce invalid list offsets during type inference apache/arrow#51305), so the read fails with
ArrowIndexError.nvidia/Nemotron-RL-ReasoningGym-v1: 12metadatakeys change JSON type between rows (for example,solutionis a number in one task and an array in another), so Arrow cannot infer one column type andthe read fails with
ArrowInvalid.Fix
Download the file with
hf_hub_downloadand copy it todata/train.jsonl, the same shape asenvironments/simple_strands_math/prepare.pyandenvironments/calendar/prepare.py. The script copiesrather than renames, so the shared Hugging Face cache keeps its file (the point of #3128). The
Wrote N rows to <path>line is kept, with N counted from the written file. The prepared file is byte-identical tothe published one, so the
nullentries and mixed metadata types reach the verifiers as published, whichis also how the committed
data/example.jsonlrows look.I kept the scripts unpinned (no
revision=), as they were before. The other 14environments/*/prepare.pyscripts that call
load_datasetread Parquet datasets, whereload_datasetis the right tool, so theyare unchanged.
Before the fix
Gym
882073970(main), freshHF_HOME:After the fix
Gym
72e7b4ccb(this branch), freshHF_HOME, same commands:The written files have the same SHA-256 as the published files (
c4b03c58…andebc81871…), and thecached copies are unchanged.
Validation
The prepare logs above and the new unit test were rerun at
72e7b4ccb. The longer runs below used thesame change one rebase earlier (
628012aceon main494528232). The rebase onto882073970touched noneof these files,
pyproject.tomloruv.lock.tests/unit_tests/test_jsonl_environment_prepare.py(2 cases). Each fixture holds rows Arrow cannotload and checks that the copy is byte for byte, that the cache file is kept, the
hf_hub_downloadarguments, and the exact
Wroteline. Both cases pass on this branch. On main they fail earlier, atImportError: pip install datasets, because the test stubshuggingface_hub. The Arrow failure itselfis shown by the logs above.
pytest tests/unit_tests -n 8(macOS): 11,127 passed, 40 failed, 2 errors; on main (these two scriptsswapped back) 11,125 passed, 40 failed, 2 errors. The failures are sandbox, telemetry and launcher tests
that fail on macOS. The two lists differ by one test each
(
test_harbor_package_store.py::test_short_http_reply_is_a_package_store_error,test_docker_compose.py::test_a_working_directory_the_image_lacks_is_created_before_the_first_exec[False]).Both pass and fail intermittently when rerun alone on this branch.
pre-commit run --all-files: passed.reasoning_gym(6 cases): main 5/6 (downloadfails on the error above); this branch 6/6.The
downloadcase now also records the HF revision before running and checks that every prepared rowequals the published
data/train.jsonlat that revision (15,000 rows at4c25c3b6).instruction_following(H100, Qwen3-0.6B on vLLM): main 0/2 (both cases stop at theprepare error above); this branch 2/2. The prepared file's SHA-256 equals the independently downloaded
file at revision
bcdec57a; the 5 README example rollouts match independently computed instructionflags (rewards 0, 0, 0, 1, 1); 24 direct
/verifycontrols passed. Because prepare had always crashedfirst, this run was the first to reach the case's later checks, and two of them expected the verify
response to echo the row's
id. It never has (InstructionFollowingVerifyResponsedoes not carry it),so the QA case is corrected on the QA side, not here.
gym env start --environment <env>+gym eval run --no-serve): rows taken from each freshly prepareddata/train.jsonl, chosen to be theshapes Arrow rejected. instruction_following: 3 rows with a
nullkwargsentry, 3 rollouts, 0 failures,rewards 1, 1, 0. reasoning_gym: 4 rows whose
metadata.solutionis null, a list, a float and a string,4 rollouts, 0 failures, rewards 1, 0, 0, 0.01. None masked.
Compatibility
data/train.jsonlnow holds the published rows unchanged. Before, nothing was written for these datasetrevisions. No change to configs or READMEs.
🤖 Generated with Claude Code