Repository navigation
feat(data): support dotted import paths in dataset_name - #2642
Merged
yuki-97 merged 5 commits intoJun 5, 2026
Merged
Conversation
yuki-97
reviewed
Jun 1, 2026
lonexreb
added a commit
to lonexreb/RL
that referenced
this pull request
Jun 2, 2026
Addresses @yuki-97's review on PR NVIDIA-NeMo#2642: 1. Move the dotted-path resolver out of `response_datasets/__init__.py` into `nemo_rl/data/datasets/utils.py` as a shared, public helper `resolve_external_dataset_class`, so both response and preference dispatchers can reuse it. 2. Apply the same dispatcher pattern to `nemo_rl/data/datasets/preference_datasets/__init__.py`: `load_preference_dataset` now also accepts dotted import paths, resolved via the shared helper. 3. Restructure both dispatchers into an explicit 3-way branch (registry / dotted path / error) and consolidate the error into a single helpful message naming all three options. 4. Restore the `# load dataset` comment. 5. Copy the "Custom datasets defined outside NeMo RL" docs section to `sft.md`, `dpo.md`, and `rm.md` (the response variant in sft.md, a preference variant in dpo.md and rm.md). 6. Update the unit-test file to import the resolver from its new location and add parallel coverage for `load_preference_dataset` (built-in + external + bad-bare-name + bad-dotted-path). All behavior remains backwards compatible. Signed-off-by: Shubhankar Tripathy <[email protected]>
Contributor
Author
|
Thanks for the review @yuki-97! Just pushed
Let me know if you'd like any further tweaks. |
Contributor
|
/ok to test d5b32bb |
Contributor
|
hi @lonexreb , there's a lint check fail, could you run |
Closes NVIDIA-NeMo#1020. `load_response_dataset` previously rejected any `dataset_name` that was not a key in the built-in `DATASET_REGISTRY`, forcing users to edit nemo_rl to plug in their own dataset class. After this change, a `dataset_name` of the form `my_pkg.my_module.MyDataset` is treated as a fully qualified import path: the dispatcher imports the module via `importlib` and resolves the class. Built-in registry behavior is unchanged. Error messages have been split so users get a precise failure mode: - bare name not in registry and not dotted -> "Unsupported dataset_name" with the full alternatives spelled out - dotted path with unimportable module -> "Could not import module" - dotted path resolving to a non-class -> "is not a class" Added unit tests covering each branch (`tests/unit/data/datasets/ test_response_dataset_registry.py`), and a docs snippet under the GRPO data guide explaining the workflow. Signed-off-by: Shubhankar Tripathy <[email protected]>
Addresses @yuki-97's review on PR NVIDIA-NeMo#2642: 1. Move the dotted-path resolver out of `response_datasets/__init__.py` into `nemo_rl/data/datasets/utils.py` as a shared, public helper `resolve_external_dataset_class`, so both response and preference dispatchers can reuse it. 2. Apply the same dispatcher pattern to `nemo_rl/data/datasets/preference_datasets/__init__.py`: `load_preference_dataset` now also accepts dotted import paths, resolved via the shared helper. 3. Restructure both dispatchers into an explicit 3-way branch (registry / dotted path / error) and consolidate the error into a single helpful message naming all three options. 4. Restore the `# load dataset` comment. 5. Copy the "Custom datasets defined outside NeMo RL" docs section to `sft.md`, `dpo.md`, and `rm.md` (the response variant in sft.md, a preference variant in dpo.md and rm.md). 6. Update the unit-test file to import the resolver from its new location and add parallel coverage for `load_preference_dataset` (built-in + external + bad-bare-name + bad-dotted-path). All behavior remains backwards compatible. Signed-off-by: Shubhankar Tripathy <[email protected]>
The `ruff --select I` import-sort hook in `.pre-commit-config.yaml` moves `from nemo_rl.data.datasets.utils import …` to its correct alphabetical position (after `tulu3`). No functional change. Signed-off-by: Shubhankar Tripathy <[email protected]>
auto-merge was automatically disabled
June 4, 2026 23:15
Head branch was pushed to by a user without write access
lonexreb
force-pushed
the
fix/1020-dotted-import-dataset-classes
branch
from
June 4, 2026 23:15
d5b32bb to
0e90595
Compare
Contributor
Author
|
Thanks @yuki-97 — done:
PR is now 3 commits ahead of |
Contributor
|
/ok to test b007f51 |
yuki-97
previously approved these changes
Jun 5, 2026
yuki-97
reviewed
Jun 5, 2026
Co-authored-by: Yuki Huang <[email protected]> Signed-off-by: Yuki Huang <[email protected]>
Contributor
|
/ok to test 34e44c0 |
yuki-97
approved these changes
Jun 5, 2026
pengdurice
pushed a commit
to pengdurice/RL
that referenced
this pull request
Jun 12, 2026
…2642) Signed-off-by: Shubhankar Tripathy <[email protected]> Co-authored-by: Yuki Huang <[email protected]>
This branch was previously deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #1020.
load_response_datasetpreviously rejected anydataset_namenot in the built-inDATASET_REGISTRY, forcing users to editnemo_rlto plug in their own dataset class. After this change, adataset_nameof the formmy_pkg.my_module.MyDatasetis treated as a fully qualified import path: the dispatcher imports the module viaimportliband resolves the class. Built-in registry behavior is unchanged.```yaml
data:
default:
dataset_name: my_pkg.my_module.MyDataset # importable from PYTHONPATH
```
What changed
nemo_rl/data/datasets/response_datasets/__init__.py— added_resolve_external_dataset_class()helper that resolves dotted-path dataset names viaimportlib.load_response_datasetfalls back to it when the name is not inDATASET_REGISTRY. Error messages are now per-branch so users see a precise failure:Unsupported dataset_namewith full alternativesCould not import modulehas no attributeis not a classtests/unit/data/datasets/test_response_dataset_registry.py— new unit test file covering each branch (built-in lookup unchanged, dotted-path resolution, all four error modes). Uses a throwawaytypes.ModuleTyperegistered insys.modulesso no on-disk fixture modules are required.docs/guides/grpo.md— small section under the data config docs explaining the workflow.Backwards compatibility
Fully backwards compatible. All existing
dataset_namevalues resolve via the registry exactly as before; the dotted-path branch is only reached when the name is not in the registry.Test plan