feat: traces -> hf dataset converter - #3382
Merged
Merged
Conversation
Replace scripts/export_sft.py, which read the pre-episode raw-Trace format, with tools/sft/vf_to_hf.py. The tool reads one traces.jsonl of episode records (written by train runs via FileMonitor and by uv run eval) and emits the dataset shape the SFT trainer consumes: a messages column plus a JSON-encoded tools column. Only trainable agents' traces convert, so a judge's trace never becomes training data. Each branch becomes one sample: a compacted rollout contributes one linear history per branch. Output targets (name, subset, split): locally the tool writes <name>/<subset>/<split>.parquet and maintains the dataset card's configs metadata so load_dataset(name, subset, split) resolves it; --push pushes to the HF Hub instead. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Export every agent branch without selection. Persist trace metadata as\ncolumns so downstream scripts own filtering.\n\nRename the tool to traces_to_hf.py and use traces-to-hf in its\noutput.
mikasenghaas
marked this pull request as ready for review
August 25, 2026 21:09
Treat the dataset name as a Hub repository unless --local is set.\nLet --private create a private Hub repository.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 2 potential issues.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 08c1be0. Configure here.
Keep README content when it has no valid YAML frontmatter. Continue\nupdating valid metadata without replacing the card body.
mikasenghaas
commented
Aug 25, 2026
samsja
approved these changes
Aug 25, 2026
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.

Summary
scripts/export_sft.pywithtools/convert_traces_to_hf_dataset.py.reward,stop_condition,has_error, andis_truncated.--publicas an explicit opt-out.--localto write Parquet files with Hugging Face dataset-card metadata.Verification
Eval → dataset → SFT
All eight episodes succeeded. Mean reward was 1.0 and the error rate was 0.0.
uv run --project /home/ubuntu/prime-rl python \ tools/convert_traces_to_hf_dataset.py \ /tmp/trace-converter-e2e-20260825/eval/traces.jsonl \ --name /tmp/trace-converter-e2e-20260825/dataset --localThe converter wrote eight branch rows. The dataset loaded through
load_dataset.uv run --project /home/ubuntu/prime-rl sft \ --output-dir /tmp/trace-converter-e2e-20260825 --run.name sft \ --max-steps 5 --model.name Qwen/Qwen3-0.6B \ --data.type sft --data.name /tmp/trace-converter-e2e-20260825/dataset \ --data.subsets '["default"]' --data.splits '["train"]' \ --data.seq-len 2048 --data.batch-size 4 --data.micro-batch-size 1 \ --deployment.gpus-per-node 2 --deployment.num-train-gpus 1The run completed all five steps. Final loss was 0.7764, the NaN count was zero, and peak GPU memory was 10.7 GiB. No Hub or Prime platform uploads occurred.
Additional checks
load_dataset.private=True, while--publicpassesprivate=False.Breaking
scripts/export_sft.pyis removed. Useuv run python tools/convert_traces_to_hf_dataset.py <traces.jsonl> --name <dir-or-repo-id>.--min-rewardor--drop-truncated. Apply filters in a separate script.--localto write a local dataset.--publicto create a public dataset.--pushflag is removed because Hub upload is now the default.🤖 Generated with Claude Code
Note
Low Risk
Changes are limited to offline export tooling and CLI workflows; no in-repo training or runtime code is modified in this diff.
Overview
Removes
scripts/export_sft.pyand addstools/convert_traces_to_hf_dataset.pyas the path from eval/traintraces.jsonlto Hugging Face datasets.The new converter reads one episode per line (
WireEpisode) instead of per-trace wire rows, emits one row per branch for every agent trace (no--min-reward,--drop-truncated, or empty-branch skipping), and keepsmessagesplus JSONtoolsfor SFT while adding top-level filter fields (reward,stop_condition,has_error,is_truncated, etc.) and JSON metadata for task, run, agent, errors, timing, and usage.Output behavior changes: Hub upload is the default via required
--name; use--localto write<name>/<subset>/<split>.parquetand updateREADME.mddataset-card configs forload_dataset.--publiccontrols visibility on new Hub repos;--pushis gone.Reviewed by Cursor Bugbot for commit 8834b7a. Bugbot is set up for automated code reviews on this repo. Configure here.