Skip to content

feat: traces -> hf dataset converter - #3382

Merged
mikasenghaas merged 8 commits into
mainfrom
feat/vf-to-hf
Aug 25, 2026
Merged

feat: traces -> hf dataset converter#3382
mikasenghaas merged 8 commits into
mainfrom
feat/vf-to-hf

Conversation

@mikasenghaas

@mikasenghaas mikasenghaas commented Aug 25, 2026

Copy link
Copy Markdown
Member

Summary

  • Replace scripts/export_sft.py with tools/convert_traces_to_hf_dataset.py.
  • Convert each branch of each agent trace into one dataset row.
  • Export trainable and non-trainable agents without selection or filtering.
  • Add top-level outcome fields for downstream filters, including reward, stop_condition, has_error, and is_truncated.
  • Preserve task, run, agent, error, timing, usage, call, reward, metric, and trace metadata.
  • Push to a private Hugging Face Hub dataset by default, with --public as an explicit opt-out.
  • Use --local to write Parquet files with Hugging Face dataset-card metadata.
  • Preserve existing dataset-card content when local metadata is updated.

Verification

Eval → dataset → SFT

  1. Generated eight GSM8K episodes without uploading the eval:
uv run --project /home/ubuntu/prime-rl eval gsm8k -n 8 -r 1 -c 8 \
    --no-push -o /tmp/trace-converter-e2e-20260825 \
    --run.name trace-converter-gsm8k --run.dir eval

All eight episodes succeeded. Mean reward was 1.0 and the error rate was 0.0.

  1. Converted the trace file into a local Hugging Face dataset:
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 --local

The converter wrote eight branch rows. The dataset loaded through load_dataset.

  1. Trained Qwen3-0.6B on the converted 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 1

The 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

  • Ran the Ruff check and format pre-commit hooks.
  • Converted a separate saved file with 132 episodes and loaded all 132 branch rows with load_dataset.
  • Verified that a non-trainable errored trace still emits its branch row and top-level error fields.
  • Verified that local updates preserve plain, valid-frontmatter, and unclosed-frontmatter README content.
  • Verified that default uploads pass private=True, while --public passes private=False.

Breaking

  • scripts/export_sft.py is removed. Use uv run python tools/convert_traces_to_hf_dataset.py <traces.jsonl> --name <dir-or-repo-id>.
  • The converter no longer accepts --min-reward or --drop-truncated. Apply filters in a separate script.
  • The converter pushes to the Hub by default. Use --local to write a local dataset.
  • New Hub datasets are private by default. Use --public to create a public dataset.
  • The --push flag 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.py and adds tools/convert_traces_to_hf_dataset.py as the path from eval/train traces.jsonl to 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 keeps messages plus JSON tools for 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 --local to write <name>/<subset>/<split>.parquet and update README.md dataset-card configs for load_dataset. --public controls visibility on new Hub repos; --push is gone.

Reviewed by Cursor Bugbot for commit 8834b7a. Bugbot is set up for automated code reviews on this repo. Configure here.

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>
@mikasenghaas mikasenghaas changed the title feat: convert episode traces into HF SFT datasets feat: data converters Aug 25, 2026
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 mikasenghaas changed the title feat: data converters feat: trace -> hf dataset converter Aug 25, 2026
@mikasenghaas mikasenghaas changed the title feat: trace -> hf dataset converter feat: traces -> hf dataset converter Aug 25, 2026
@mikasenghaas
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.

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 2 potential issues.

Fix All in Cursor

❌ 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.

Comment thread tools/convert_traces_to_hf_dataset.py
Comment thread tools/convert_traces_to_hf_dataset.py
Keep README content when it has no valid YAML frontmatter. Continue\nupdating valid metadata without replacing the card body.
Comment thread skills/configs/SKILL.md Outdated
Comment thread tools/convert_traces_to_hf_dataset.py Outdated
@mikasenghaas
mikasenghaas requested a review from samsja August 25, 2026 22:45
@mikasenghaas
mikasenghaas merged commit ef66401 into main Aug 25, 2026
19 checks passed
@mikasenghaas
mikasenghaas deleted the feat/vf-to-hf branch August 25, 2026 23:14
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.

2 participants