Skip to content

feat: add data shuffle option #334

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions examples/configs/dpo.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ policy:
data:
dataset_name: "HelpSteer3"
max_input_seq_length: ${policy.max_total_sequence_length}
shuffle: true
logger:
log_dir: "logs" # Base directory for all logs
wandb_enabled: false # Make sure you do a ``wandb login [Your API key]'' before running
Expand Down
1 change: 1 addition & 0 deletions examples/configs/grpo_math_1B.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ data:
prompt_file: "examples/prompts/cot.txt"
system_prompt_file: null
dataset_name: "OpenMathInstruct-2"
shuffle: true

env:
math:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ policy:
data:
dataset_name: "HelpSteer3"
max_input_seq_length: ${policy.max_total_sequence_length}
shuffle: true

logger:
log_dir: "logs"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ policy:
data:
dataset_name: "HelpSteer3"
max_input_seq_length: ${policy.max_total_sequence_length}
shuffle: true

logger:
log_dir: "logs"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ policy:
data:
dataset_name: "HelpSteer3"
max_input_seq_length: ${policy.max_total_sequence_length}
shuffle: true

logger:
log_dir: "logs"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ policy:
data:
dataset_name: "HelpSteer3"
max_input_seq_length: ${policy.max_total_sequence_length}
shuffle: true
logger:
log_dir: "logs"
wandb_enabled: true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ data:
prompt_file: examples/prompts/cot.txt
system_prompt_file: null
dataset_name: OpenMathInstruct-2
shuffle: true
env:
math:
num_workers: 8
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ data:
prompt_file: examples/prompts/cot.txt
system_prompt_file: null
dataset_name: OpenMathInstruct-2
shuffle: true

env:
math:
num_workers: 8
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ data:
prompt_file: examples/prompts/cot.txt
system_prompt_file: null
dataset_name: OpenMathInstruct-2
shuffle: true
env:
math:
num_workers: 8
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ data:
prompt_file: examples/prompts/cot.txt
system_prompt_file: null
dataset_name: OpenMathInstruct-2
shuffle: true
env:
math:
num_workers: 8
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ data:
prompt_file: examples/prompts/cot.txt
system_prompt_file: null
dataset_name: OpenMathInstruct-2
shuffle: true
env:
math:
num_workers: 8
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ data:
prompt_file: examples/prompts/cot.txt
system_prompt_file: null
dataset_name: OpenMathInstruct-2
shuffle: true
env:
math:
num_workers: 8
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ data:
prompt_file: examples/prompts/cot.txt
system_prompt_file: null
dataset_name: OpenMathInstruct-2
shuffle: true
env:
math:
num_workers: 8
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ data:
dataset_name: squad
add_bos: true
add_eos: true
shuffle: true
logger:
log_dir: logs/sft-llama3.1-8b-instruct-1n8g-fsdp1
wandb_enabled: true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ data:
dataset_name: squad
add_bos: true
add_eos: true
shuffle: true
logger:
log_dir: logs/sft-llama3.1-8b-instruct-1n8g-fsdp2tp1-long
wandb_enabled: true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ data:
dataset_name: squad
add_bos: true
add_eos: true
shuffle: true
logger:
log_dir: logs/sft-llama3.1-8b-instruct-1n8g-fsdp2tp2sp
wandb_enabled: true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ data:
dataset_name: squad
add_bos: true
add_eos: true
shuffle: true
logger:
log_dir: logs/sft-llama3.2-1b-1n8g-fsdp2tp1
wandb_enabled: true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ data:
dataset_name: squad
add_bos: true
add_eos: true
shuffle: true
logger:
log_dir: logs/sft-qwen2.5-32b-4n8g-fsdp2tp8sp-actckpt
wandb_enabled: true
Expand Down
1 change: 1 addition & 0 deletions examples/configs/sft.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ data:
dataset_name: "squad"
add_bos: true
add_eos: true
shuffle: true

logger:
log_dir: "logs" # Base directory for all logs
Expand Down
2 changes: 1 addition & 1 deletion nemo_rl/algorithms/dpo.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ def setup(
train_dataloader = StatefulDataLoader(
train_dataset,
batch_size=policy_config["train_global_batch_size"],
shuffle=True,
shuffle=data_config["shuffle"],
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we add seeding if we're shuffling? I don't want subsequent runs to randomly repeat data.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

collate_fn=partial(
dpo_collate_fn,
tokenizer=tokenizer,
Expand Down
2 changes: 1 addition & 1 deletion nemo_rl/algorithms/grpo.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ def setup(
dataloader = StatefulDataLoader(
dataset,
batch_size=grpo_config["num_prompts_per_step"],
shuffle=False,
shuffle=data_config["shuffle"],
collate_fn=rl_collate_fn,
)
if last_checkpoint_path is not None:
Expand Down
2 changes: 1 addition & 1 deletion nemo_rl/algorithms/sft.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ def setup(
train_dataloader = StatefulDataLoader(
train_dataset,
batch_size=policy_config["train_global_batch_size"],
shuffle=True,
shuffle=data_config["shuffle"],
collate_fn=rl_collate_fn,
drop_last=True,
)
Expand Down
1 change: 1 addition & 0 deletions nemo_rl/data/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ class DataConfig(TypedDict):
val_dataset_name: Optional[str]
add_bos: Optional[bool]
add_eos: Optional[bool]
shuffle: Optional[bool]


class MathDataConfig(DataConfig):
Expand Down