Skip to content

Fix DeepSeek4HyperHead missing from maxtext.layers.mhc - #4772

Closed
olufiyin19 wants to merge 1 commit into
test-pipeline-ckpt-validationfrom
fix-validation-pipeline-deepseek4-284b-dag_verify_checkpoint_shape-manual__b6345457-checkpoint_shape_validation
Closed

Fix DeepSeek4HyperHead missing from maxtext.layers.mhc#4772
olufiyin19 wants to merge 1 commit into
test-pipeline-ckpt-validationfrom
fix-validation-pipeline-deepseek4-284b-dag_verify_checkpoint_shape-manual__b6345457-checkpoint_shape_validation

Conversation

@olufiyin19

Copy link
Copy Markdown
Collaborator

Fix DeepSeek4HyperHead missing from maxtext.layers.mhc

@google-cla

google-cla Bot commented Aug 7, 2026

Copy link
Copy Markdown

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@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 adds a mock failure log for checkpoint validation and implements the DeepSeek4HyperHead class in src/maxtext/layers/mhc.py to collapse hyper-connection streams. Feedback suggests sharding the first dimension of the self.hc_fn parameter along the "activation_embed" axis to prevent potential out-of-memory (OOM) issues caused by replicating the entire weight matrix across all devices.

Comment thread src/maxtext/layers/mhc.py
in_axis=0,
out_axis=1,
),
out_sharding=(None, None),

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

The parameter self.hc_fn is currently initialized with out_sharding=(None, None), which replicates the entire weight matrix across all devices. Since its first dimension is self.hc_mult * config.emb_dim (which can be quite large), replicating it can lead to significant memory overhead and potential OOMs during training. Sharding the first dimension along the "activation_embed" axis is more efficient and aligns with how other projection weights (like self.res_alpha, self.pre_alpha, and self.post_alpha) are sharded in this file.

Suggested change
out_sharding=(None, None),
out_sharding=("activation_embed", None),

@olufiyin19 olufiyin19 closed this Aug 8, 2026
@olufiyin19
olufiyin19 deleted the fix-validation-pipeline-deepseek4-284b-dag_verify_checkpoint_shape-manual__b6345457-checkpoint_shape_validation branch August 8, 2026 00:30
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