Skip to content

Add separate final normalization for Multi-Token Prediction in DeepSeek models. - #5142

Open
copybara-service[bot] wants to merge 1 commit into
mainfrom
test_975503733
Open

Add separate final normalization for Multi-Token Prediction in DeepSeek models.#5142
copybara-service[bot] wants to merge 1 commit into
mainfrom
test_975503733

Conversation

@copybara-service

Copy link
Copy Markdown
Contributor

Add separate final normalization for Multi-Token Prediction in DeepSeek models.

Description

This change adds the MTP-specific final normalization layer in DeepSeek models. It updates the checkpoint conversion script to load the MTP final norm weight instead of skipping it. It also updates the decoder's output head to skip normalization, allowing the MTP block to apply its own final norm before projecting hidden states to logits.

Tests

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.

@codecov

codecov Bot commented Sep 4, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 81.81818% with 4 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/maxtext/layers/decoders.py 50.00% 1 Missing and 2 partials ⚠️
src/maxtext/layers/nnx_decoders.py 83.33% 0 Missing and 1 partial ⚠️

📢 Thoughts on this report? Let us know!

…ek models.

# Description

This change adds the MTP-specific final normalization layer in DeepSeek models. It updates the checkpoint conversion script to load the MTP final norm weight instead of skipping it. It also updates the decoder's output head to skip normalization, allowing the MTP block to apply its own final norm before projecting hidden states to logits.

# Tests

# 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.

PiperOrigin-RevId: 975503733
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.

1 participant