Skip to content

fix(data): apply the null-content contract to legacy chat turns - #5742

Open
pruprakash wants to merge 1 commit into
mainfrom
pruprakash/fix_data_sharegpt_null_value_content
Open

fix(data): apply the null-content contract to legacy chat turns#5742
pruprakash wants to merge 1 commit into
mainfrom
pruprakash/fix_data_sharegpt_null_value_content

Conversation

@pruprakash

Copy link
Copy Markdown
Contributor

What does this PR do ?

Fixes ShareGPT chat SFT rows with a null value training the model on the literal string None, by applying the documented null-content contract to the legacy from/value branch of normalize_chat_conversation.

Changelog

  • src/megatron/bridge/data/conversation_processing.py: legacy from/value branch converts a null value to ""; docstring widened to both schemas.
  • tests/unit_tests/data/test_conversation_processing.py: 2 tests over the patched branch and null/empty equivalence.

Additional Information

  • Root cause: conversation_processing.py:606-611 applies None -> "" then continues, so the legacy branch at :612-615 copied value into content unconverted. Jinja stringifies None instead of raising, so it reaches the training text silently.
  • Blast radius: any chat SFT run over a ShareGPT-format corpus, every model. Not DeepSeek-specific.
  • Regression? No — broken since null handling landed in 46c42552 ([4/4] fix(data): align thinking-model chat templates and masks #5541); the legacy branch (0845a7dd, fix(data): normalize ShareGPT role aliases #5078) never had it.
  • Verification: red-green in nvcr.io/nvidian/nemo:nightly on EOS at base 4a3f2c2e. RED (job 5901189): 2 failed on content=None vs ''. GREEN (job 5901199): 2 passed, file 110 passed. tests/unit_tests/data/ 796 -> 798 passed, same 2 pre-existing unrelated failures.
  • Not included: the raise at :616 also rejects an assistant turn with tool_calls and no content key, making DeepSeek-V4 tool-call-only support unreachable from build_direct_hf_sft_split. Separate root cause, and the remedy is a maintainer call — reported separately, not fixed here.

normalize_chat_conversation converted null content to an empty string only
on the OpenAI role/content branch. A legacy ShareGPT from/value turn with a
null value kept content=None, and the chat template rendered the literal
string None into the training text.

Adds unit tests covering the change (red-green verified).

Signed-off-by: Pruthviraj Prakash <pruprakash@nvidia.com>
@pruprakash pruprakash self-assigned this Aug 22, 2026
@pruprakash pruprakash added bug Something isn't working area:data Dataset builders, preprocessing, and samplers needs-review PR is ready for code review and waiting on a reviewer qa_rcca_done labels Aug 22, 2026
@copy-pr-bot

copy-pr-bot Bot commented Aug 22, 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.

@claude

claude Bot commented Aug 22, 2026

Copy link
Copy Markdown
Contributor

LGTM — the null value to empty-string conversion for the legacy sharegpt schema correctly mirrors the existing OpenAI null-content handling, and the two new unit tests cover both the direct conversion and cross-schema equivalence.

Suggested test cases

  • test_normalize_chat_conversation_converts_null_legacy_value_to_empty_content
  • test_normalize_chat_conversation_matches_null_and_empty_spellings_across_schemas

No perf tests impacted.

@pruprakash

Copy link
Copy Markdown
Contributor Author

/ok to test 82a8ee1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:data Dataset builders, preprocessing, and samplers bug Something isn't working needs-review PR is ready for code review and waiting on a reviewer qa_rcca_done

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant