-
Notifications
You must be signed in to change notification settings - Fork 240
feat: unify nemogym dataset #1807
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
47c6fac
6526659
099d5ec
2c80cf4
043aa06
ec97fff
a19bdd2
c5893d7
b458030
d1428ba
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -44,7 +44,7 @@ class PreferenceDatasetConfig(TypedDict): | |
|
|
||
|
|
||
| class DataConfig(TypedDict): | ||
| max_input_seq_length: int | ||
| max_input_seq_length: int | None | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: # First, let's find the file and inspect the TypedDict definition
find . -name "__init__.py" -path "*/nemo_rl/data/*" -type f
# Then search for AllTaskProcessedDataset class and max_seq_length/max_input_seq_length usage
rg -n "class AllTaskProcessedDataset|max_seq_length|max_input_seq_length" -g'*.py' -C 3Repository: NVIDIA-NeMo/RL Length of output: 28206 🏁 Script executed: # Check AllTaskProcessedDataset.__init__ for validation or safeguards
sed -n '46,70p' nemo_rl/data/datasets/processed_dataset.py
# Check example config files to see how max_input_seq_length is set
find . -name "*.yaml" -path "*/examples/configs/*" -type f | head -10
rg "max_input_seq_length" -g'*.yaml' -A 2 -B 2Repository: NVIDIA-NeMo/RL Length of output: 17681 Add None checks in task data processors or validate max_seq_length at dataset initialization. The type definitions allow 🤖 Prompt for AI Agents |
||
| add_bos: NotRequired[bool] | ||
| add_eos: NotRequired[bool] | ||
| add_generation_prompt: NotRequired[bool] | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| # Copyright (c) 2025, NVIDIA CORPORATION. All rights reserved. | ||
yuki-97 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
|
|
||
| from datasets import Dataset | ||
|
|
||
| from nemo_rl.data.datasets.raw_dataset import RawDataset | ||
|
|
||
|
|
||
| class NemoGymDataset(RawDataset): | ||
| """Simple wrapper around the Nemo Gym dataset.""" | ||
|
|
||
| def __init__(self, data_path: str, repeat: int = 1, **kwargs) -> None: | ||
| self.task_name = "-".join(data_path.split("/")[-2:]).split(".")[0] | ||
| if self.task_name[0] == "-": | ||
| self.task_name = self.task_name[1:] | ||
|
|
||
| # load raw line from jsonl | ||
| # will use `json.loads` to load to dict format at `nemo_gym_data_processor` later since `Dataset` cannot handle nested structure well | ||
| with open(data_path) as f: | ||
| self.dataset = [raw_line for raw_line in f] | ||
|
Comment on lines
+23
to
+31
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Document Suggested fix- def __init__(self, data_path: str, repeat: int = 1, **kwargs) -> None:
+ def __init__(self, data_path: str, repeat: int = 1, **kwargs) -> None:
+ """Initialize the Nemo Gym dataset.
+
+ Args:
+ data_path: Path to the JSONL data file.
+ repeat: Number of times to repeat the dataset.
+ **kwargs: Unused extra args for RawDataset compatibility.
+ """
+ _ = kwargs
self.task_name = "-".join(data_path.split("/")[-2:]).split(".")[0]🧰 Tools🪛 Ruff (0.14.14)[warning] 23-23: Unused method argument: (ARG002) 🤖 Prompt for AI Agents |
||
|
|
||
| # format the dataset | ||
| self.dataset = Dataset.from_dict( | ||
| { | ||
| "extra_env_info": self.dataset, | ||
| "task_name": [self.task_name] * len(self.dataset), | ||
| } | ||
| ) | ||
|
|
||
| # repeat the dataset | ||
| if repeat > 1: | ||
| self.dataset = self.dataset.repeat(repeat) | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bxyu-nvidia @yuki-97 where does the truncation happen in this case? vllm will have max length which should prevent generating beyond that max_length set in the generation config, but does gym know to respect a max seqlength if tacking on an environment or tool output?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm curious as well, and I guess it should be in gym or didn't measure the max length (I saw lots of below warnings when using gym env).
since gym needs to directly pass the raw data (string) to gym env to let it handle all things now, so there's no way for nemorl to get its token_ids and handle the max_length.