Skip to content

feat(pdf_analyst_qa): standardize task data as flat rows plus PDF media - #6475

Merged
wprazuch merged 2 commits into
mainfrom
jseppanen/pdf-analyst-qa-row-tasks
Nov 24, 2026
Merged

wprazuch merged 2 commits into
mainfrom
jseppanen/pdf-analyst-qa-row-tasks

Conversation

@jseppanen

@jseppanen jseppanen commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

What does this PR do?

pdf_analyst_qa datasets are now plain JSONL rows plus the PDFs they reference, matching the rows-and-media layout of other environments.

Previously, a dataset was a bundle that split each task across four places: the JSONL row, tasks/<task_id>.json (the reference answer), workspaces/<workspace_id>/documents.json (which PDFs the task may see), and document_store/ (the PDFs, read and hashed by the server from a local dataset_root). The rows were unusable without the bundle, which had to be copied by hand to every cluster running the environment. This split bought nothing—the policy sees only responses_create_params.input, and the reference stays out of the sandbox whether the server reads it from a file or from the row—and it made the data cumbersome to share.

Each row now carries two flat task fields:

  • reference: the task record (question, reference answer, answer format, and grading metadata), verbatim.
  • documents: the selected PDFs, each with path (relative to pdf_analyst_qa_document_prefix in the bucket), target (its path under /workspace/docs), and sha256.

The server builds the sandbox manifest from the row and reads no local files. dataset_root and pdf_analyst_qa_dataset_root are removed.

Validation checks are retained or moved into the row schema:

  • At seed time, the server still rejects any reference answer that does not grade as correct and format-compliant against itself.
  • Before a sandbox slot is allocated, the new PdfAnalystQaTaskRow (the seed model and TaskData) rejects rows with a reference whose task_id or workspace_id does not match the row, duplicate targets, absolute or .. paths, non-PDF paths, or malformed checksums.
  • The sandbox still verifies every copied PDF against the row's sha256. The server-side read-only check on local PDFs is gone along with the local store; publishing the PDFs is now the data pipeline's job.

The example moves to data/example/: gym_input.jsonl (one self-contained row) and document_store/ (its PDF). prepare_example.py is removed because there is nothing left to copy.

Validation

  • uv run --extra dev pytest environments/pdf_analyst_qa/tests resources_servers/pdf_analyst_qa/tests: 102 passed. New and updated tests cover building the manifest from the row, rejecting nine malformed rows before allocation, and verifying the example row's checksum against its PDF.
  • pre-commit run --files <changed files>: passed (ruff, ruff-format, guardwords, verified flag, environment list).
  • Rows from our bundle converter, after staging, validate against TaskData with normalize_task_fields (tested on a small bundle, and on 32 rows of the full 11,603-task conversion in the rollouts below, none rejected).

Rollouts

  • Gym rollouts (this commit, aac57f253c26). 32 converted rows (16 Treasury, 16 financial) through pdf_analyst_qa_agent with OpenCode 1.17.11 and vLLM serving an SFT checkpoint, reading PDFs from the combined S3 prefix. 32/32 rollouts completed, 0 failures, and no rows were rejected by input validation. The sandboxes copied and SHA-256-verified 5,990 PDFs. Reward was 9/32. Median rollout time was 171 s, and the slowest took 261 s.
  • NeMo RL GRPO. The PR was cherry-picked onto the Gym revision that our NeMo RL branch pins (6a2763beca; no conflicts, 102 tests pass) and run with the nemo_gym environment on 3 nodes (1 generation, 2 training) at 64k context, for one GRPO step of 4 prompts × 4 rollouts from an SFT checkpoint. All 16 rollouts were scored through NeMo RL, with 0 data failures and 0 infrastructure drops; 12 finished within the context limit. One rollout earned reward 1, and the optimizer step completed with a nonzero gradient (loss 0.035, grad norm 0.135). Getting there took fixes in NeMo RL setup, Megatron-Bridge, and the smoke config, but none in this PR.

Compatibility and benchmark impact

Breaking for existing datasets: bundle-based rows (carrying only task_id, workspace_id, and prompt_version) are rejected at seed time, and configs that set pdf_analyst_qa_dataset_root must drop it. Converting a bundle is mechanical: embed tasks/<task_id>.json as reference, and combine documents.json with each PDF's sha256 as documents, where path names the PDF under the bucket prefix. Runs that pin an earlier Gym revision are unaffected. Grading and rewards are unchanged, so there is no benchmark impact.

Checklist

  • I have read the contributing guidelines.
  • The change is focused; unrelated "drive-by" edits are tracked as separate issues/PRs.
  • Tests added or updated and pass locally, or N/A for docs-only / non-code changes (so CI unit/server checks pass when applicable).
  • Documentation added or updated, or N/A with justification.
  • Pre-commit checks pass locally (pre-commit run --all-files) (so CI lint/format checks pass). Run on the changed files only.
  • New source files include the required Apache-2.0 SPDX header.
  • All commits have DCO sign-off (git commit -s) (so the DCO check passes).

The dataset bundle split each task across four places: the JSONL row,
tasks/<task_id>.json, workspaces/<workspace_id>/documents.json, and
document_store/. The rows meant nothing without the bundle, and the
bundle had to be copied to a local dataset root on every cluster that
runs the environment. That is complexity without a purpose: the policy
sees only the request, and the reference is just as hidden from the
sandbox whether the server reads it from a file or from the row. It
also makes the data cumbersome to share, since a dataset cannot travel
as plain rows plus media like other environments' data.

A dataset is now the JSONL rows plus the PDFs they name. Each row
carries everything the resources server needs as flat task fields:
`reference` (the task record with the reference answer) and `documents`
(each selected PDF's path under the bucket prefix, its sandbox target
and sha256). The server builds the sandbox manifest from the row and no
longer reads tasks/, workspaces/ or document_store/ from a local
dataset root, so `dataset_root` and `pdf_analyst_qa_dataset_root` are
removed.

The seed still rejects a reference that does not grade as correct and
format-compliant against itself. The new `PdfAnalystQaTaskRow` (the
seed model and `TaskData`) also checks that the reference matches the
row's task and workspace, that document targets are unique, and that
paths are relative PDF paths. The sandbox still checks every copied PDF
against the row's sha256.

The example moves to data/example/ as one self-contained row and its
PDF; prepare_example.py is removed.

Signed-off-by: Jarno Seppänen <[email protected]>
@copy-pr-bot

copy-pr-bot Bot commented Nov 19, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@svcnvidia-nemo-ci svcnvidia-nemo-ci added risk:mid Autobot PR risk: mid feature New capabilities, enhancements, or enablement work area:environment Individual environments, benchmarks, verifiers, and environment-specific resources servers labels Nov 19, 2026
@jseppanen
jseppanen marked this pull request as ready for review November 20, 2026 13:01
@copy-pr-bot

copy-pr-bot Bot commented Nov 20, 2026

Copy link
Copy Markdown

/ok to test

@jseppanen, there was an error processing your request: E1

See the following link for more information: https://docs.gha-runners.nvidia.com/cpr/e/1/

@jseppanen
jseppanen requested review from a team November 20, 2026 13:02
@jseppanen

Copy link
Copy Markdown
Contributor Author

/ok to test aac57f2

@svcnvidia-nemo-ci svcnvidia-nemo-ci added the needs-review PR is ready for code review and waiting on a reviewer label Nov 20, 2026

@svcnvidia-nemo-ci svcnvidia-nemo-ci left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

SHIP WITH CARE

RISK: Required real rollout validation is still pending

The PR description still lists the planned 32-rollout smoke as pending. Session initialization now reads references from rows, and the manifest builder uses a different bucket-relative layout. The reported 102 passing unit tests do not show converted rows and published PDFs working through a real OpenCode/model session. AGENTS.md requires representative real smoke rollouts for behavior-changing environment work. This is a validation gap, not a demonstrated runtime defect.

Could you complete the planned smoke on this head using converted flat rows, PDFs under pdf_analyst_qa_document_prefix, and no local dataset_root? Attach the resolved configuration and rollout artifacts, identify the model and dataset, and record the inspected agent/verifier outcomes. Acceptance is evidence that selected PDFs stage successfully, the agent can read them, verification completes, and sandboxes are released. Inspect the model input to confirm the reference stays hidden. Diagnose infrastructure failures separately from scored model failures and rerun affected coverage after fixing deployment problems.

Keep grading unchanged while validating the migration. The existing correct/wrong/retry test must retain unmasked rewards of 1 for 23 and 0 for 24, stable verification retries, and masking for a missing session. Keep the document-copy test accepting matching checksums and rejecting mismatches. A reward-profile comparison is not required for this training environment.

I reviewed the changed files and their affected contract, dispatch, and sandbox paths statically. I did not execute tests or rollouts in this read-only review.

Review generated by codex. This was a full review. Request a full review with /review reset=true.

@yaoyu-33
yaoyu-33 requested a review from wprazuch November 20, 2026 14:37
@jseppanen

Copy link
Copy Markdown
Contributor Author

Thanks. This review ran before the PR description was updated; the real-rollout smoke test it requests is complete, and the results are now in the description under Rollouts. Here are the details for each acceptance point:

  • Smoke test on this head, flat rows, PDFs under the prefix, no dataset_root. Thirty-two converted rows (16 Treasury, 16 financial) ran through pdf_analyst_qa_agent on aac57f253c26 with OpenCode 1.17.11 and vLLM serving an SFT checkpoint of our model. The rows came from the published dataset, and every PDF was read from pdf_analyst_qa_document_prefix; the config sets no dataset_root.
  • PDFs stage, the agent reads them, and verification completes. All 32 rollouts completed with 0 failures, and input validation rejected 0 rows. The sandboxes copied 5,990 PDFs, each matching its row's sha256. Every rollout read PDFs via tool calls (733 tool calls total, 7–57 per rollout), and all 32 were verified: 9/32 correct and 24/32 format-compliant.
  • The reference stays hidden. I checked all 32 rollouts. The model input (responses_create_params.input) contains only the instructions and the question, with no reference fields. Across all 733 tool outputs, no reference field names, answer-program IDs, or task, reference, or manifest files appear; directory listings show the task's PDFs and the agent's own scratch files. The gold answer string appears in 9 tool outputs, always as the agent's own computation (for example, a python3 -c print), text extracted from a PDF, or a PDF filename containing a year.
  • Sandboxes are released. This PR does not change release_session_state. Its existing tests still pass: test_correct_wrong_and_retry_verification asserts that the sandbox stops once, while test_failed_stop_keeps_capacity_and_close_can_retry and test_cancelled_initialization_releases_partial_allocation cover the failure paths. Because the smoke test ran with a concurrency of 32 (all rollouts at once), it did not exercise slot reuse.
  • Infrastructure failures vs. scored failures. The Gym smoke test had no infrastructure failures. Separately, this PR was cherry-picked onto NeMo RL's pinned Gym revision without conflicts and ran in NeMo RL GRPO for 1 step of 4 prompts × 4 rollouts: 16/16 rollouts were scored, with 0 data failures and 0 infrastructure drops. One rollout earned a reward of 1, and the optimizer step completed with a nonzero gradient. The setup issues encountered along the way were all in NeMo RL and Megatron-Bridge, not in this PR. In an earlier 32k-context attempt, 7 of 8 rollouts hit the context limit and scored 0; those were policy truncations, not environment failures.
  • Grading is unchanged. test_correct_wrong_and_retry_verification is identical to main (reward 1 for "23", 0 for "24", the same reward on a retried verify, and masking for a missing session). test_document_copy_checks_contents_and_protects_selected_pdfs is also unchanged and still accepts matching checksums and rejects mismatches. All 102 pdf_analyst_qa tests pass on this head.

The resolved config and rollout files are stored internally; I can share specific records if helpful.

@jseppanen

Copy link
Copy Markdown
Contributor Author

/ok to test f990e4a

@github-actions github-actions Bot added the sla:review-overdue Review response is over the one-business-day SLA label Nov 23, 2026
@wprazuch
wprazuch added this pull request to the merge queue Nov 24, 2026
@github-actions

Copy link
Copy Markdown
Contributor

🔄 Merge queue validation started! You can track the progress here: https://github.com/NVIDIA-NeMo/Gym/actions/runs/45372519800

@github-actions github-actions Bot removed the sla:review-overdue Review response is over the one-business-day SLA label Nov 24, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Nov 24, 2026
@wprazuch
wprazuch added this pull request to the merge queue Nov 24, 2026
@github-actions

Copy link
Copy Markdown
Contributor

🔄 Merge queue validation started! You can track the progress here: https://github.com/NVIDIA-NeMo/Gym/actions/runs/45377527146

Merged via the queue into main with commit 2fa4dae Nov 24, 2026
126 of 146 checks passed
@wprazuch
wprazuch deleted the jseppanen/pdf-analyst-qa-row-tasks branch November 24, 2026 11:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:environment Individual environments, benchmarks, verifiers, and environment-specific resources servers feature New capabilities, enhancements, or enablement work needs-review PR is ready for code review and waiting on a reviewer risk:mid Autobot PR risk: mid

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants