Repository navigation
perf(sc): pass jagged token ids and generation logprobs to the dump - #5226
Conversation
The advantage stage padded the jagged token_ids and generation_logprobs columns to dense for TrainChunk.sequences, and the writer then trimmed the padding again. Hand the columns over as fetched; the writer already unbinds jagged and dense columns alike and trims to input_lengths. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Signed-off-by: Zhiyu Li <[email protected]>
Drop the cost narration from the comment in the advantage stage and record the chunk in the test with patch.object(wraps=...) instead of a hand-written wrapper. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Signed-off-by: Zhiyu Li <[email protected]>
…equences prev_logprobs went through the same pad-then-strip round trip as the token ids and generation logprobs, and was padded a second time after the estimator had already padded it. Pass it as the data plane returns it. TrainChunk.sequences now says its columns may be dense or jagged. The jagged-dump test also covers prev_logprobs, through the opd estimator. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Signed-off-by: Zhiyu Li <[email protected]>
|
@mikhailshilkov could you take a review? |
svcnvidia-nemo-ci
left a comment
There was a problem hiding this comment.
LGTM — no qualifying findings in the three changed files.
The raw-column handoff matches the writer’s dense/jagged handling. The new regression checks mixed-length GRPO and OPD dumps.
Validation was static only; I didn’t run tests or lint or verify live CI. One child’s report text wasn’t returned, so I inspected its producer-contract topic directly.
Note: formal approval is not available for this request, so this review is posted as a comment only.
Review generated by codex. This was a full review. Request a full review with /review reset=true.
yuki-97
left a comment
There was a problem hiding this comment.
Thanks for removing the padding round trip from training dumps.
Thanks also for sharing the simulation and end-to-end JSON results; they make the gain and its limits clear.
Scope: Training-dump column handoff, writer compatibility and regression coverage, at 296c912.
Checked:
- Raw token and logprob columns preserve valid row prefixes; dense inputs still work. Dump handoff.
- Validation, shared storage and background JSON writing accept jagged columns. Writer storage handling.
- The mixed-length GRPO and OPD regression checks the real writer handoff and dumped values. Regression coverage.
LGTM — no changes requested. Static review only; tests were not run locally.
Generated by Codex (#4999 version)
|
/ok to test 296c912 |
What
The advantage stage padded the jagged
token_ids,generation_logprobs, andprev_logprobscolumns to dense tensors (tensor_field) before it builtTrainChunk.sequences. The writer then trimmed the padding again toinput_lengths.This PR passes the three columns as the data plane returns them (
data[...]). The same block already passesprompt_idsthis way. TheTrainChunk.sequencesdocstring now says that columns can be dense or jagged.No writer change is needed.
DebugWriter._validate,_share_chunk_storage, andJsonDebugWriter._write_partalready handle jagged tensors throughunbind().Why
Mikhail Shilkov replayed one step (1024 samples, about 300M tokens) through the writer code. Padding and trimming again cost 6-30 s, depending on threads. Building from the jagged tensors took about 2 s.
Result
In a simulation at 305M tokens on one core, the stage plus the Arrow list-column build drops from 54.2 s to 2.2 s.
The simulation uses the row lengths of a real step, repeated 40 times. The token values are random, the Arrow build is my own stand-in for a lake writer, and each number is the median of 3 runs.
An end-to-end run (Qwen3-0.6B, 4096 tokens, 1024 samples per step, 5 steps, JSON writer) shows no gain in total step time. The JSON encoding takes about 12.7 s per 7.6M-token step, and this PR does not change it. The gain should show with writers that take jagged columns directly, such as a Parquet or Iceberg writer.
The same run checks correctness. All 5 dump files have 1024 rows and no row shorter than its
input_lengths. The mean ofexp|prev - gen|in each file matches the trainer'stoken_mult_prob_errorto 4 digits.Test
test_training_dump_takes_jagged_columns_without_paddingruns for thegrpoandopdestimators. A store returns jagged columns with mixed lengths. The test checks that the chunk reaches the writer jagged, and that the dumped rows equal the trimmed values.96 unit tests passed in the nightly-gym container.
Notes
input_lengthsnow raises inDebugWriter._validate. The zero padding used to hide that case. The e2e run had no such row.async_rl.debug_writer.targetnow receive jaggedtoken_ids,generation_logprobs, andprev_logprobs. A writer that assumes dense tensors must change. I did not find one in the repo, but I could not search all external code.🤖 Generated with Claude Code