Skip to content

fix the use of targets_segmentation in MTP - #4756

Merged
copybara-service[bot] merged 1 commit into
mainfrom
aireen/fix_mtp
Aug 7, 2026
Merged

copybara-service[bot] merged 1 commit into
mainfrom
aireen/fix_mtp

Conversation

@aireenmei

@aireenmei aireenmei commented Aug 6, 2026 •

Copy link
Copy Markdown
Collaborator

Description

b/542651398
targets_segmentation contains segment IDs [1, 1, 2, 2, 2, ...]. When used as a loss mask, it should be converted to binary first. In contrast, the segment IDs in inputs_segmentation should be preserved for attention boundary.

Tests

added unit test

Checklist

Before submitting this PR, please make sure (put X in square brackets):

  • I have performed a self-review of my code. For an optional AI review, add the gemini-review label.
  • I have necessary comments in my code, particularly in hard-to-understand areas.
  • I have run end-to-end tests tests and provided workload links above if applicable.
  • I have made or will make corresponding changes to the doc if needed, including adding new documentation pages to the relevant Table of Contents (toctree directive) as explained in our documentation.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code Review

This pull request updates the multi-token prediction (MTP) layer to normalize the target mask to binary validity (target_mask != 0) before rolling. This ensures that packed datasets using positive integer segment IDs are not treated as numerical weights. Additionally, a corresponding unit test has been added to verify this behavior. There are no review comments, so no feedback is provided.

@codecov

codecov Bot commented Aug 6, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@parambole parambole left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM

@copybara-service
copybara-service Bot merged commit af3b398 into main Aug 7, 2026
74 of 75 checks passed
@copybara-service
copybara-service Bot deleted the aireen/fix_mtp branch August 7, 2026 06:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants