Skip to content

fix(data): report rows that fail request validation during collate - #6418

Open
ananthsub wants to merge 1 commit into
ananthsub/share-dispatch-routingfrom
ananthsub/dataset-row-check
Open

ananthsub wants to merge 1 commit into
ananthsub/share-dispatch-routingfrom
ananthsub/dataset-row-check

Conversation

@ananthsub

@ananthsub ananthsub commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

Stack 2 of 5. Splitting the receiver-based collate check into reviewable pieces: #6499 (routing helpers) → this PR → #6447 (task input modules) → #6448 (gym env validate) → #6449 (collate checks each row against its receiver). This PR does not depend on #6499.

Before and after

Before: collate checks every flat row as a run request but only records which rows fail. It never reports them, so the rows are collated, collation exits 0 in every task_data_validation mode, and the run fails later with HTTP 422.

flowchart LR
    B1["Flat row"] --> B2["Checked as BaseRunRequest"]
    B2 -->|"fails"| B3["Recorded, never reported"]
    B3 --> B4["Collation exits 0 and writes the row"]
    B4 --> B5["At rollout, the server rejects the row with HTTP 422"]
    classDef bad fill:#fde2e1,stroke:#c0392b,color:#000
    class B3,B4,B5 bad
Loading

After: the failing rows follow task_data_validation, and error mode stops collation before any metrics file is written for a failing dataset.

flowchart LR
    A1["Flat row"] --> A2["Checked as BaseRunRequest"]
    A2 -->|"fails"| A3{"task_data_validation"}
    A3 -->|"error"| A4["Collation fails after every dataset is read, no metrics file for the failing dataset"]
    A3 -->|"warn"| A5["Report printed, row left out of metrics"]
    A3 -->|"off"| A6["No report, row left out of metrics"]
    classDef good fill:#dff5e3,stroke:#1e8449,color:#000
    class A3,A4,A5 good
Loading

What changed and why

The common case is a training dataset whose tools are in Chat Completions format ({"type": "function", "function": {"name": ...}}) instead of the flat Responses API format. The task_data.py check doesn't look at tools, so only the request check can catch this. When token capture is on, a 422 at rollout stops the run after the generation for the row is already spent.

  • error fails collation after every dataset is read, and lists each failing file. A dataset with failing rows gets no metrics sidecar, so a rerun after the rows are fixed doesn't hit a conflicting-metrics error.
  • warn prints a report per file and goes on.
  • off reports nothing.

Each report has the shape of the task_data.py report: a count of failing rows, the reasons for the first five, then ... and N more rows, so it stays short on large datasets. A row repeated by num_repeats counts once. Each reason names the first failing field:

data/train.jsonl: 5/10 rows failed request validation (servers reject these rows with HTTP 422).
  row 0: responses_create_params.tools.0.FunctionToolParam.name: Field required (528 validation errors)
  ... and 4 more rows

Rows that fail the request check are left out of the metrics, as before. A row without responses_create_params is not reported: agents such as toolsandbox_agent and aviary_agent fill the request in, and their request models live in their app.py, which data tooling does not import. Its other fields are still checked against a run request with an empty input, and it stays out of the metrics, as before. compute_sample_metrics keeps its signature, and a private sibling returns the rejection reason. The prepare-and-validate docs said invalid rows are silently skipped, which was wrong: they were collated as they were. The docs now describe both row checks, the three settings and a sample report.

Issue

None filed. This came up when two training datasets reached a run with rows the servers rejected with HTTP 422. One had Chat Completions tools, which this change catches. The other had missing task fields, which the task_data.py check already catches.

Validation

pytest -n 12 tests/unit_tests/data tests/unit_tests/environment tests/unit_tests/config
pre-commit run --files <changed files>
  • New unit tests cover error, warn and off, error mode listing every failing file and writing no sidecar, the five-reason cap, counting each repeated row once, rows that are not JSON or not an object, and a row without responses_create_params that collates in error mode but still needs valid controls. They fail on main.
  • gym dataset collate --mode train_preparation on a dataset where half the rows have Chat Completions tools: on main it exits 0 in both modes with no report. With this change it exits 1 with error and the report above, and exits 0 with warn and the same report printed. A rerun after fixing the rows in error mode finds no stale sidecar and exits 0.

Rollout evidence

N/A. The change affects data preparation only; no environment, agent or verifier behavior changes. Collation was run end to end, as listed above.

Compatibility

  • example_validation (the PR gate) resolves to error. No committed example dataset has a row that fails the request check, so the gate stays green.
  • train_preparation still resolves to warn, the mode NeMo RL uses. A training run that wants collation to stop on bad rows passes +task_data_validation=error.

@ananthsub ananthsub added area:data Datasets, preparation, task formats, and materialization area:docs Generic documentation without another dominant domain labels Nov 18, 2026
@copy-pr-bot

copy-pr-bot Bot commented Nov 18, 2026

Copy link
Copy Markdown

Auto-sync is disabled for draft pull requests in this repository. Workflows must be run manually.

Contributors can view more details about this message here.

@svcnvidia-nemo-ci svcnvidia-nemo-ci added risk:high Autobot PR risk: high bug Something isn't working labels Nov 18, 2026
@ananthsub
ananthsub marked this pull request as ready for review November 18, 2026 23:53
@nemo-automation-bot
nemo-automation-bot Bot requested review from a team November 18, 2026 23:54
@github-actions

github-actions Bot commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

@svcnvidia-nemo-ci svcnvidia-nemo-ci added the needs-review PR is ready for code review and waiting on a reviewer label Nov 19, 2026
@yaoyu-33
yaoyu-33 requested a review from init-nikhil November 19, 2026 00:06

@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

I found one RISK: error-mode enforcement rejects supported ToolSandbox and Aviary pointer rows. There is also a documentation NOTE about guarantees that differ between the two validation checks.

I inspected all three changed files and traced the affected collation and runtime contracts. This was a static review; I did not execute tests.

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

Comment thread nemo_gym/data/dataset_preparation.py Resolved
@ananthsub
ananthsub marked this pull request as draft November 19, 2026 00:47
@ananthsub ananthsub changed the title fix(data): report rows that fail request validation during collate fix(data): check collated rows against the server that receives them Nov 19, 2026
@ananthsub
ananthsub force-pushed the ananthsub/dataset-row-check branch from 9fb22c4 to f6c2d54 Compare November 19, 2026 04:29
@ananthsub
ananthsub marked this pull request as ready for review November 19, 2026 04:30
@nemo-automation-bot
nemo-automation-bot Bot requested review from a team November 19, 2026 04:31

@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

Both prior findings still apply: one RISK for supported ToolSandbox and Aviary pointer rows rejected by collation, and one documentation NOTE about validation-mode guarantees.

I verified the earlier counterexamples against the current source and traced receiver selection, runtime request models, and metrics-preservation tests. This was a static follow-up review; I did not execute tests. The previous reviewed tree was unavailable, so I could not compare inter-review changes and did not restart a full-PR review.

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

Comment thread nemo_gym/data/dataset_preparation.py Resolved
@ananthsub
ananthsub force-pushed the ananthsub/dataset-row-check branch from f6c2d54 to 1435e14 Compare November 19, 2026 04:52
@ananthsub
ananthsub marked this pull request as draft November 19, 2026 04:53
@ananthsub ananthsub changed the title fix(data): check collated rows against the server that receives them fix(data): report rows that fail request validation during collate Nov 19, 2026
@ananthsub
ananthsub marked this pull request as ready for review November 19, 2026 06:05

@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

Both findings from review 5969399220 still apply: one RISK for runtime-valid ToolSandbox and Aviary pointer rows rejected by collation, and one documentation NOTE about validation-mode guarantees.

I verified both counterexamples against the current source and checked their runtime contracts and metrics-preservation tests. This was a static follow-up review; I did not execute tests. The previous reviewed tree was unavailable, so I could not compare inter-review changes and did not restart a full-PR review.

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

Comment thread nemo_gym/data/dataset_preparation.py Resolved
@ananthsub
ananthsub force-pushed the ananthsub/dataset-row-check branch from 1435e14 to f9cf1bf Compare November 19, 2026 18:23
@ananthsub

Copy link
Copy Markdown
Contributor Author

/review reset=true

@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

I found one documentation NOTE. The earlier ToolSandbox/Aviary omission failure is fixed, and the validation-mode bullets now distinguish request failures from task-schema early exit and local parsing failures.

I inspected all three changed files and traced the affected request, collation and metrics paths. Two parallel review reports were unavailable, so I inspected those topics directly. This was a full static review; I did not execute tests.

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

@ananthsub
ananthsub force-pushed the ananthsub/dataset-row-check branch from f9cf1bf to 1ef8502 Compare November 19, 2026 19:17
@ananthsub
ananthsub changed the base branch from main to ananthsub/share-dispatch-routing November 19, 2026 19:18
@ananthsub
ananthsub force-pushed the ananthsub/share-dispatch-routing branch from 78b0d96 to 661151e Compare November 19, 2026 22:34
@ananthsub
ananthsub force-pushed the ananthsub/dataset-row-check branch from 1ef8502 to 4e5b287 Compare November 19, 2026 22:34
gym dataset collate checked every row as a run request but only
recorded which rows failed. It never reported them, so the rows were
collated and collation exited 0 in every task_data_validation mode.
The run then hit HTTP 422 later, for example on tools in Chat
Completions format.

Rows that fail the request check now follow task_data_validation:
error raises once after every dataset is read and lists each failing
file, writing no metrics sidecar for it; warn prints a report per
file; off reports nothing. Each report counts the failing rows and
gives the first five reasons, so it stays short on large datasets, and
counts a row repeated by num_repeats once. The prepare-and-validate
docs now describe both row checks.

Signed-off-by: Ananth Subramaniam <[email protected]>
@ananthsub
ananthsub force-pushed the ananthsub/dataset-row-check branch from 4e5b287 to 279a980 Compare November 19, 2026 22:51
@ananthsub

Copy link
Copy Markdown
Contributor Author

/review reset=true

@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

I found no material concerns. The missing-request troubleshooting entry now matches the omission behavior and regression assertions, so the prior NOTE is resolved.

I reviewed all three changed files and traced request validation, metrics preservation, report aggregation and collation failure paths. This was a full static review; I did not execute tests.

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

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:data Datasets, preparation, task formats, and materialization area:docs Generic documentation without another dominant domain bug Something isn't working needs-review PR is ready for code review and waiting on a reviewer risk:high Autobot PR risk: high sla:review-overdue Review response is over the one-business-day SLA

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants