Skip to content

feat: Allow to conditionally skip malformed jsonl lines when loading dataset - #1694

Merged
akoumpa merged 3 commits into
NVIDIA-NeMo:mainfrom
titu1994:som/updates2
Apr 6, 2026
Merged

akoumpa merged 3 commits into
NVIDIA-NeMo:mainfrom
titu1994:som/updates2

Conversation

@titu1994

@titu1994 titu1994 commented Apr 6, 2026

Copy link
Copy Markdown
Contributor

What does this PR do ?

Adds a config flag to allow skipping lines in jsonl dataset that are malformed and cant be loaded so that it doesnt crash and instead just skips the sample.

Changelog

  • skip_invalid_samples flag added (defaults to false for backward compat)

Before your PR is "Ready for review"

Pre checks:

  • Make sure you read and followed Contributor guidelines
  • Did you write any new necessary tests?
  • Did you add or update any necessary documentation?

If you haven't finished some of the above items you can still open "Draft" PR.

Additional Information

  • Related to # (issue)

@copy-pr-bot

copy-pr-bot Bot commented Apr 6, 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.

@hemildesai hemildesai changed the title Allow to conditionally skip malformed jsonl lines when loading dataset feat: Allow to conditionally skip malformed jsonl lines when loading dataset Apr 6, 2026
titu1994 added 3 commits April 6, 2026 11:24
This commit introduces the `skip_invalid_samples` parameter to the `_load_openai_messages` function and the `ChatDataset` class. When set to `True`, it allows the loading process to skip malformed JSONL lines and invalid chat samples, enhancing robustness in data handling. Additionally, corresponding tests have been added to verify the new functionality.

Signed-off-by: Somshubra Majumdar <titu1994@gmail.com>
This commit updates the `dataset-overview.md` to include the `skip_invalid_samples` parameter, detailing its functionality for handling malformed JSONL lines. Additionally, the docstring in `ChatDataset` has been expanded to clarify the usage of `skip_invalid_samples`, improving the overall documentation for better user understanding.

Signed-off-by: Somshubra Majumdar <titu1994@gmail.com>
This commit updates the `dataset-overview.md` and the `ChatDataset` class docstring to refine the explanation of the `skip_invalid_samples` parameter. The documentation now specifies that it only skips malformed JSONL lines during loading, while invalid structured rows will still raise errors after loading. Additionally, the test for `skip_invalid_samples` has been renamed to reflect its updated behavior.

Signed-off-by: Somshubra Majumdar <titu1994@gmail.com>
@hemildesai

Copy link
Copy Markdown
Contributor

/ok to test 492717b

@hemildesai

Copy link
Copy Markdown
Contributor

/claude review


rows = tcd._load_openai_messages(str(jsonl), skip_invalid_samples=True)
assert len(rows) == 2
assert rows[0]["messages"][0]["content"] == "ok-1"

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.

Nit: Consider asserting that the warning is actually emitted when lines are skipped (e.g., using caplog). Right now the test verifies the rows are correct but doesn't confirm the logging path works, which is the main observability mechanism for users debugging data issues.

@akoumpa akoumpa 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 a lot @titu1994 !

@akoumpa
akoumpa merged commit 3eb5bc0 into NVIDIA-NeMo:main Apr 6, 2026
54 checks passed
@titu1994
titu1994 deleted the som/updates2 branch April 6, 2026 21:07
linnanwang pushed a commit that referenced this pull request Apr 24, 2026
…dataset (#1694)

* feat: add skip_invalid_samples parameter to chat dataset loading

This commit introduces the `skip_invalid_samples` parameter to the `_load_openai_messages` function and the `ChatDataset` class. When set to `True`, it allows the loading process to skip malformed JSONL lines and invalid chat samples, enhancing robustness in data handling. Additionally, corresponding tests have been added to verify the new functionality.

Signed-off-by: Somshubra Majumdar <titu1994@gmail.com>

* docs: enhance dataset overview and chat dataset loading documentation

This commit updates the `dataset-overview.md` to include the `skip_invalid_samples` parameter, detailing its functionality for handling malformed JSONL lines. Additionally, the docstring in `ChatDataset` has been expanded to clarify the usage of `skip_invalid_samples`, improving the overall documentation for better user understanding.

Signed-off-by: Somshubra Majumdar <titu1994@gmail.com>

* docs: clarify skip_invalid_samples behavior in dataset documentation

This commit updates the `dataset-overview.md` and the `ChatDataset` class docstring to refine the explanation of the `skip_invalid_samples` parameter. The documentation now specifies that it only skips malformed JSONL lines during loading, while invalid structured rows will still raise errors after loading. Additionally, the test for `skip_invalid_samples` has been renamed to reflect its updated behavior.

Signed-off-by: Somshubra Majumdar <titu1994@gmail.com>

---------

Signed-off-by: Somshubra Majumdar <titu1994@gmail.com>
kashif pushed a commit to kashif/Automodel that referenced this pull request May 25, 2026
…dataset (NVIDIA-NeMo#1694)

* feat: add skip_invalid_samples parameter to chat dataset loading

This commit introduces the `skip_invalid_samples` parameter to the `_load_openai_messages` function and the `ChatDataset` class. When set to `True`, it allows the loading process to skip malformed JSONL lines and invalid chat samples, enhancing robustness in data handling. Additionally, corresponding tests have been added to verify the new functionality.

Signed-off-by: Somshubra Majumdar <titu1994@gmail.com>

* docs: enhance dataset overview and chat dataset loading documentation

This commit updates the `dataset-overview.md` to include the `skip_invalid_samples` parameter, detailing its functionality for handling malformed JSONL lines. Additionally, the docstring in `ChatDataset` has been expanded to clarify the usage of `skip_invalid_samples`, improving the overall documentation for better user understanding.

Signed-off-by: Somshubra Majumdar <titu1994@gmail.com>

* docs: clarify skip_invalid_samples behavior in dataset documentation

This commit updates the `dataset-overview.md` and the `ChatDataset` class docstring to refine the explanation of the `skip_invalid_samples` parameter. The documentation now specifies that it only skips malformed JSONL lines during loading, while invalid structured rows will still raise errors after loading. Additionally, the test for `skip_invalid_samples` has been renamed to reflect its updated behavior.

Signed-off-by: Somshubra Majumdar <titu1994@gmail.com>

---------

Signed-off-by: Somshubra Majumdar <titu1994@gmail.com>

This branch was previously deployed

2 inactive deployments
nemo-ci — 492717ba Deployed Apr 6, 2026 by copy-pr-bot[bot] via L2_HF_Transformer #5086
test — 492717ba Deployed Apr 6, 2026 by copy-pr-bot[bot] via cicd-wait-in-queue #5086
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants