Repository navigation
fix(recover): read oversized saved rows in bounded memory - #6086
AdamRajfer merged 4 commits into
Conversation
The recovery evidence collector parsed every rollouts.jsonl line whole. A harness trajectory repeats each model call's full request, so a row grows with the square of its conversation and can reach several gigabytes; one such row needs several times its size in memory, and the reader ended with MemoryError on a login node. A line longer than 16 MiB is now read in chunks, and the strings longer than 1 KiB inside its ng_trajectory and ng_agent_observations values are replaced by a length marker before the line is parsed. The collector reads only identities, names, statuses and counts from those values, and every other value (the response the grading binding hashes included) is copied byte for byte. Every byte read still goes into the source digest. Smaller rows take the unchanged path, so the evidence is the same. Tests: a 256 MiB row is collected under a 512 MiB address-space limit (it fails with MemoryError without the change), the pruned and whole parse report the same evidence, and a truncated final row is still recognised. The test double of the source-read test now offers readline. Signed-off-by: Adam Rajfer <[email protected]>
svcnvidia-nemo-ci
left a comment
There was a problem hiding this comment.
SHIP WITH CARE
Two RISK findings: pruning can change valid trajectory identities and hide malformed JSON strings. Raw-byte digest handling remains intact.
I inspected all three changed files and the affected producer and recovery paths. This was a static review; I didn't run tests.
Review generated by codex. This was a full review. Request a full review with /review reset=true.
…lid strings when pruning a large row Pruning elided every long string under ng_trajectory and ng_agent_observations, so a long task or call identity changed with the size of its row, and an elided string was never checked as JSON, so a malformed escape, invalid UTF-8 or a raw control byte was accepted only because the row crossed the threshold. - elide only strings under keys the collector does not read (request input, tool output, conversation text); identities, statuses, kinds, names and object keys are kept, and one above 1 MiB fails the row instead of being altered - validate each elided string in pieces with the JSON parser, across chunk boundaries, and route an invalid one through the existing malformed-record path (a truncated last row is still ignored) Signed-off-by: Adam Rajfer <[email protected]>
|
/ok to test 1c355b8 |
yuhezhang-ai
left a comment
There was a problem hiding this comment.
Could you address the four cases below before merge? I reproduced two memory regressions, valid payloads rejected only above the pruning threshold, and a malformed record that hides subsequent rows. These checks used synthetic saved records; I did not exercise a production store.
Release the pruner before the rebuilt row is parsed, find the closing quote of a string with find instead of a regex that keeps state per escape, keep a string only where the collector reads it instead of under any field with a matching name, and keep the newline that ends an unfinished elided string. Signed-off-by: Adam Rajfer <[email protected]>
yuhezhang-ai
left a comment
There was a problem hiding this comment.
Thanks for the fixes. I confirmed the buffer-lifetime, escape-dense-memory, and physical-newline issues are addressed. One escaped-key metadata case remains in the existing thread; the inline note below is an optional robustness follow-up.
…xtra closer when pruning a large row A key written with escapes (a Windows path in a tool output) was treated as a kept-metadata ancestor, so the ignored payload below it hit KEPT_MAX. Keys are now unescaped before they are compared with the paths the collector reads, so an escaped spelling of a kept name still matches and any other escaped key is payload. A corrupt last row with an extra closing brace popped an empty stack; the parse of the row now rejects it, so it is handled as an incomplete tail. Signed-off-by: Adam Rajfer <[email protected]>
|
🤖 Adam’s AI assistant @yuhezhang-ai thanks for the careful review and the large-row check. Both points are fixed in cd071fe: the pruner unescapes keys before comparing them, and an extra closer no longer pops an empty stack, so that row is handled as an incomplete tail. CI is fully green. Could you take another look? |
yuhezhang-ai
left a comment
There was a problem hiding this comment.
Thanks for the fixes. I verified the escaped-key handling and extra-closing-brace recovery against the earlier reproductions, and the earlier regressions still pass. The remaining corruption-only comma guard can be a follow-up.
|
🔄 Merge queue validation started! You can track the progress here: https://github.com/NVIDIA-NeMo/Gym/actions/runs/43852197752 |
gym eval resubmit --recovercould not inspect runs with very large saved rows, because the evidence collector parsed every line whole and ran out of memory. A row over 16 MiB is now read in chunks, and strings over 1 KiB inside itsng_trajectoryandng_agent_observationsthat the collector does not read are replaced by a length marker before parsing; keys are compared after unescaping, invalid JSON strings are still rejected, and every byte read still goes into the source digest. Rows of 16 MiB or less take the unchanged path. A new test collects a 256 MiB row under a 512 MiB memory limit (it fails withMemoryErrorwithout the change), and the pruned and whole parses report the same evidence; on real saved rows the collector output was identical with and without pruning. No linked issue: found when recovering a real run ran out of memory.