Skip to content

feat(sc): make the training data dump backend pluggable via DebugWriter - #4812

Merged
ZhiyuLi-Nvidia merged 13 commits into
mainfrom
yukih/debug-writer
Oct 28, 2026
Merged

ZhiyuLi-Nvidia merged 13 commits into
mainfrom
yukih/debug-writer

Conversation

@yuki-97

@yuki-97 yuki-97 commented Oct 20, 2026

Copy link
Copy Markdown
Contributor

What does this PR do ?

Splits the single-controller training data dump into a DebugWriter base class and a JsonDebugWriter, and lets async_rl.debug_writer select the writer. No behaviour change by default: the JSONL files are written exactly as before.

What changed

1. Extract DebugWriter from TrainDataDump. add_chunk keeps the validation, per-row assembly and step bookkeeping; the abstract _write_rows and _publish_step hold everything path- and format-specific (part files, the idx splice, the atomic rename). JsonDebugWriter is the old TrainDataDump behind those hooks, and train_data_dump.py becomes single_controller_utils/debug_writer.py.

2. Move json_safe_nonfinite to utils/json_utils.py. logger.py uses it too, and importing it from single_controller_utils would make utils/ depend on algorithms/.

3. Add async_rl.debug_writer.target. A DEBUG_WRITER_REGISTRY name (json by default) wins; any other target containing a dot is imported with hydra.utils.get_class and must subclass DebugWriter. Extra keys go to the constructor after log_dir and shard_id. AdvantageStageConfig carries the config into the advantage actors, so a custom class must be importable in the controller and in every shard process. Both construction sites go through make_debug_writer.

Tests

test_train_data_dump.py is renamed to test_debug_writer.py with only the class name changed. New tests cover make_debug_writer (default and explicit json, an external target with extra kwargs, invalid targets) and that a subclass missing a hook fails at construction.

🤖 Generated with Claude Code

@copy-pr-bot

copy-pr-bot Bot commented Oct 20, 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.

@github-actions github-actions Bot added the Documentation Improvements or additions to documentation label Oct 20, 2026

@yuki-97 yuki-97 left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Self-review via /review-pr-team: 4 agents (rl-expert, bug-finder, design-reviewer, test-agent) + devil's-advocate pass.

Verdict — no findings above the confidence bar. LGTM, no action needed.

Verified clean

  • Behaviour parity with the old TrainDataDump — step/rows bookkeeping, first-chunk replace, part-file naming, idx splice, expected_rows check and atomic publish are unchanged.
  • Registry-then-dotted-path resolution matches the existing DATASET_REGISTRY / ENV_REGISTRY precedent and the repo's hydra get_class usage; bad targets, non-DebugWriter classes and abstract subclasses all fail loudly at construction.
  • The config travels as data into the advantage shards via AdvantageStageConfig, both construction sites go through make_debug_writer, and moving json_safe_nonfinite to utils/json_utils.py avoids a utils -> algorithms import with no cycle and no stale references.
  • The new tests hold under the installed hydra: each invalid-target case raises the stated exception and the missing-hook TypeError match is stable.

Lower-priority notes that are not inline

  • An invalid debug_writer.target is not validated while log_full_train_data is false (documented as ignored); it fails at construction once the flag is on.
  • AdvantageStageConfig.from_master_config carrying debug_writer is not directly asserted by a test.

Generated by Claude Code

@yuki-97
yuki-97 marked this pull request as ready for review October 20, 2026 12:00
@yuki-97 yuki-97 added the CI:Lfast Runs a fast test suite and re-use nightly `main` container (but sync dependencies to PRs version) label Oct 20, 2026
@yuki-97

yuki-97 commented Oct 20, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test a0b6a14

@mikhailshilkov mikhailshilkov 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.

Thanks, this is the hook we need in MF! I plugged an Iceberg writer into it through target plus kwargs and it worked without changes. See a few notes from building on it.

@yuki-97

yuki-97 commented Oct 27, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test 44d64e0

yuki-97 and others added 13 commits October 27, 2026 15:21
…e publishing in _publish_step

Signed-off-by: Yuki Huang <[email protected]>
…ugWriter and JsonDebugWriter classes

Signed-off-by: Yuki Huang <[email protected]>
… json_safe_nonfinite to utils/json_utils

Signed-off-by: Yuki Huang <[email protected]>
…ter, with a registry and dotted-path targets

Signed-off-by: Yuki Huang <[email protected]>
…ipt and publish with receipts

Signed-off-by: Yuki Huang <[email protected]>
…g tensors, extract _validate

Signed-off-by: Yuki Huang <[email protected]>
…f globbing, require receipts in finish_step, add dump/shard path helpers

Signed-off-by: Yuki Huang <[email protected]>
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Signed-off-by: Zhiyu Li <[email protected]>
@ZhiyuLi-Nvidia

Copy link
Copy Markdown
Contributor

/ok to test 9bf3ef2

@ZhiyuLi-Nvidia
ZhiyuLi-Nvidia enabled auto-merge (squash) October 27, 2026 23:25
@ZhiyuLi-Nvidia
ZhiyuLi-Nvidia merged commit 97516b1 into main Oct 28, 2026
94 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CI:Lfast Runs a fast test suite and re-use nightly `main` container (but sync dependencies to PRs version) Documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants