-
Notifications
You must be signed in to change notification settings - Fork 515
Add DATASET_COMBOS for grouped calibration datasets #1508
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
Changes from all commits
df6040d
10f3cfd
0202e73
936a374
fb32476
6a752ce
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 | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -109,10 +109,12 @@ def _join_messages_content(sample: dict) -> str: | |||||||||||||||||||||
| "chat_key": "messages", | ||||||||||||||||||||||
| }, | ||||||||||||||||||||||
| "nemotron-sft-agentic-v2": { | ||||||||||||||||||||||
| # Skips ``search`` split: heterogeneous messages schema fails streaming cast. | ||||||||||||||||||||||
| # Only ``search`` streams cleanly: ``interactive_agent`` has a heterogeneous | ||||||||||||||||||||||
| # tools schema (string vs list) that breaks pyarrow JSON inference, and | ||||||||||||||||||||||
| # ``tool_calling`` contains at least one malformed JSON row in a later shard. | ||||||||||||||||||||||
| "config": { | ||||||||||||||||||||||
| "path": "nvidia/Nemotron-SFT-Agentic-v2", | ||||||||||||||||||||||
| "split": ["interactive_agent", "tool_calling"], | ||||||||||||||||||||||
| "split": ["search"], | ||||||||||||||||||||||
| }, | ||||||||||||||||||||||
| "preprocess": _join_messages_content, | ||||||||||||||||||||||
| "chat_key": "messages", | ||||||||||||||||||||||
|
|
@@ -195,6 +197,42 @@ def _join_messages_content(sample: dict) -> str: | |||||||||||||||||||||
| }, | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| # Named groups of registered datasets, expanded in ``get_dataset_dataloader``. | ||||||||||||||||||||||
| # Useful when callers want a single ``--dataset`` token that fans out to several | ||||||||||||||||||||||
| # entries; per-dataset ``num_samples`` is split evenly across the members. | ||||||||||||||||||||||
| DATASET_COMBOS: dict[str, list[str]] = { | ||||||||||||||||||||||
| "cnn_nemotron_v2_mix": ["cnn_dailymail", "nemotron-post-training-dataset-v2"], | ||||||||||||||||||||||
| "nemotron-post-training-v3": [ | ||||||||||||||||||||||
| "nemotron-sft-instruction-following-chat-v2", | ||||||||||||||||||||||
| "nemotron-science-v1", | ||||||||||||||||||||||
| "nemotron-competitive-programming-v1", | ||||||||||||||||||||||
| "nemotron-sft-agentic-v2", | ||||||||||||||||||||||
| "nemotron-math-v2", | ||||||||||||||||||||||
| "nemotron-sft-swe-v2", | ||||||||||||||||||||||
| "nemotron-sft-multilingual-v1", | ||||||||||||||||||||||
| ], | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
|
|
||||||||||||||||||||||
| def _validate_dataset_combos() -> None: | ||||||||||||||||||||||
| """Validate DATASET_COMBOS at import time: fail loud on typos / collisions.""" | ||||||||||||||||||||||
| overlap = set(DATASET_COMBOS) & set(SUPPORTED_DATASET_CONFIG) | ||||||||||||||||||||||
| if overlap: | ||||||||||||||||||||||
| raise ValueError( | ||||||||||||||||||||||
| f"DATASET_COMBOS keys collide with SUPPORTED_DATASET_CONFIG: {sorted(overlap)}" | ||||||||||||||||||||||
| ) | ||||||||||||||||||||||
| for combo_name, members in DATASET_COMBOS.items(): | ||||||||||||||||||||||
| if not members: | ||||||||||||||||||||||
| raise ValueError(f"DATASET_COMBOS['{combo_name}'] must contain at least one dataset.") | ||||||||||||||||||||||
| unknown = [m for m in members if m not in SUPPORTED_DATASET_CONFIG] | ||||||||||||||||||||||
| if unknown: | ||||||||||||||||||||||
| raise ValueError( | ||||||||||||||||||||||
| f"DATASET_COMBOS['{combo_name}'] references unknown datasets: {unknown}" | ||||||||||||||||||||||
| ) | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
|
|
||||||||||||||||||||||
| _validate_dataset_combos() | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| __all__ = [ | ||||||||||||||||||||||
| "create_forward_loop", | ||||||||||||||||||||||
| "download_hf_dataset_as_jsonl", | ||||||||||||||||||||||
|
|
@@ -349,6 +387,13 @@ def get_dataset_samples( | |||||||||||||||||||||
| Returns: | ||||||||||||||||||||||
| Samples: The list of samples. | ||||||||||||||||||||||
| """ | ||||||||||||||||||||||
| if dataset_name in DATASET_COMBOS: | ||||||||||||||||||||||
| raise ValueError( | ||||||||||||||||||||||
| f"'{dataset_name}' is a DATASET_COMBOS entry, not a single dataset. " | ||||||||||||||||||||||
| "Use ``get_dataset_dataloader`` to expand combos, or pass one of " | ||||||||||||||||||||||
| f"its members: {DATASET_COMBOS[dataset_name]}" | ||||||||||||||||||||||
| ) | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| # Local JSONL: load via HF's ``json`` builder and route through the same | ||||||||||||||||||||||
| # auto-preprocess path as unregistered HF datasets so chat / prompt / text | ||||||||||||||||||||||
| # columns are handled consistently with a downloaded HF dataset. Never | ||||||||||||||||||||||
|
|
@@ -560,6 +605,34 @@ def get_dataset_dataloader( | |||||||||||||||||||||
| "dataset_name and num_samples must be the same length" | ||||||||||||||||||||||
| ) | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| # Reject inputs that include both a combo and one of its member datasets | ||||||||||||||||||||||
| # (e.g. ``["cnn_dailymail", "cnn_nemotron_v2_mix"]``), since the combo would sample the | ||||||||||||||||||||||
| # plain entry a second time with a smaller per-member quota. | ||||||||||||||||||||||
| plain_inputs = {n for n in dataset_name if n not in DATASET_COMBOS} | ||||||||||||||||||||||
| for ds_name in dataset_name: | ||||||||||||||||||||||
| if ds_name in DATASET_COMBOS: | ||||||||||||||||||||||
| overlap = plain_inputs & set(DATASET_COMBOS[ds_name]) | ||||||||||||||||||||||
| if overlap: | ||||||||||||||||||||||
| raise ValueError( | ||||||||||||||||||||||
| f"--dataset includes both combo '{ds_name}' and its " | ||||||||||||||||||||||
| f"member(s) {sorted(overlap)}; remove one to avoid " | ||||||||||||||||||||||
| "double-sampling." | ||||||||||||||||||||||
| ) | ||||||||||||||||||||||
|
Comment on lines
+616
to
+620
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.
Suggested change
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. a nit suggestion
Collaborator
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. Also remove --, seems to be referring to |
||||||||||||||||||||||
|
|
||||||||||||||||||||||
| expanded_names: list[str] = [] | ||||||||||||||||||||||
| expanded_num_samples: list[int] = [] | ||||||||||||||||||||||
| for ds_name, n in zip(dataset_name, num_samples): | ||||||||||||||||||||||
| if ds_name in DATASET_COMBOS: | ||||||||||||||||||||||
| members = DATASET_COMBOS[ds_name] | ||||||||||||||||||||||
| base, remainder = divmod(n, len(members)) | ||||||||||||||||||||||
| for i, member in enumerate(members): | ||||||||||||||||||||||
| expanded_names.append(member) | ||||||||||||||||||||||
| expanded_num_samples.append(base + (1 if i < remainder else 0)) | ||||||||||||||||||||||
| else: | ||||||||||||||||||||||
| expanded_names.append(ds_name) | ||||||||||||||||||||||
| expanded_num_samples.append(n) | ||||||||||||||||||||||
| dataset_name, num_samples = expanded_names, expanded_num_samples | ||||||||||||||||||||||
|
Comment on lines
+624
to
+634
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. Skip zero-allocated combo members before loading datasets. When a combo gets fewer samples than its member count, Lines 625-633 still enqueue members with Proposed fix expanded_names: list[str] = []
expanded_num_samples: list[int] = []
for ds_name, n in zip(dataset_name, num_samples):
+ if n <= 0:
+ continue
if ds_name in DATASET_COMBOS:
members = DATASET_COMBOS[ds_name]
base, remainder = divmod(n, len(members))
for i, member in enumerate(members):
- expanded_names.append(member)
- expanded_num_samples.append(base + (1 if i < remainder else 0))
+ alloc = base + (1 if i < remainder else 0)
+ if alloc <= 0:
+ continue
+ expanded_names.append(member)
+ expanded_num_samples.append(alloc)
else:
expanded_names.append(ds_name)
expanded_num_samples.append(n)
dataset_name, num_samples = expanded_names, expanded_num_samples
+
+ if not dataset_name:
+ raise ValueError("No positive sample allocations were produced from --dataset/--calib_size.")Also applies to: 637-640 🤖 Prompt for AI Agents |
||||||||||||||||||||||
|
|
||||||||||||||||||||||
| all_samples = [] | ||||||||||||||||||||||
| for ds_name, num_sample in zip(dataset_name, num_samples): | ||||||||||||||||||||||
| samples = get_dataset_samples( | ||||||||||||||||||||||
|
|
@@ -617,7 +690,7 @@ def get_supported_datasets() -> list[str]: | |||||||||||||||||||||
|
|
||||||||||||||||||||||
| print("Supported datasets:", get_supported_datasets()) | ||||||||||||||||||||||
| """ | ||||||||||||||||||||||
| return list(SUPPORTED_DATASET_CONFIG.keys()) | ||||||||||||||||||||||
| return list(SUPPORTED_DATASET_CONFIG.keys()) + list(DATASET_COMBOS.keys()) | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
|
|
||||||||||||||||||||||
| @contextmanager | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
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.
nemotron-agentic-v1 also has tool_calling split which is correctly structured if you are interested to use it. Its also much larger than nemotron-sft-agentic-v2's tool_calling split
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.
maybe next run. RIght now we pick these 7 datasets for GLM5.1