-
Notifications
You must be signed in to change notification settings - Fork 582
Fix DeepSeek4HyperHead compilation error #4778
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -438,6 +438,13 @@ def __init__( | |||||
| self.is_gemma4 = self.config.decoder_block == DecoderBlockType.GEMMA4 | ||||||
| self.is_gemma4_small = self.config.decoder_block == DecoderBlockType.GEMMA4_SMALL | ||||||
|
|
||||||
| if config.mhc_expansion_rate > 1 and config.decoder_block == DecoderBlockType.DEEPSEEK4: | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Accessing
Suggested change
|
||||||
| self.hc_head = mhc.DeepSeek4HyperHead( | ||||||
| config=config, | ||||||
| mesh=self.mesh, | ||||||
| rngs=self.rngs, | ||||||
| ) | ||||||
|
|
||||||
| self._init_decoder_layers(decoder_block_classes, rngs, mesh) | ||||||
|
|
||||||
| def _init_decoder_layers(self, decoder_block_classes, rngs, mesh): | ||||||
|
|
@@ -1967,13 +1974,16 @@ def pure_layer_fn(graphdef_in, state_in, y_in, kv_in): | |||||
|
|
||||||
| assert isinstance(y, jax.Array) | ||||||
|
|
||||||
| # After the final transformer layer, `y` holds the raw, un-normalized hidden state. | ||||||
| # After the final transformer layer, `y` holds the raw, un-normalized hidden state. | ||||||
| if getattr(cfg, "mhc_expansion_rate", 1) > 1: | ||||||
| # (batch, length, mhc_expansion_rate, emb_dim) --> (batch, length, emb_dim) | ||||||
| hidden_state = mhc_reduce(y) | ||||||
| if cfg.decoder_block == DecoderBlockType.DEEPSEEK4: | ||||||
| hidden_state = self.hc_head(y) | ||||||
| else: | ||||||
| # (batch, length, mhc_expansion_rate, emb_dim) --> (batch, length, emb_dim) | ||||||
| hidden_state = mhc_reduce(y) | ||||||
| else: | ||||||
| hidden_state = y | ||||||
|
|
||||||
| # When invoking from vLLM with RPA attention, logit computation is deferred to a later stage. | ||||||
| if cfg.attention in ("vllm_rpa", "vllm_batched_rpa"): | ||||||
| logits = None | ||||||
|
|
||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
DenseGenerallayers insideDeepSeek4HyperHeadare initialized without specifying logicalkernel_axes,shard_mode,matmul_precision, andparameter_memory_host_offload. Without these, the weight matrices will not be sharded (replicated instead), which can lead to high memory usage and potential Out-Of-Memory (OOM) errors during large-scale training. Additionally, the layers will not respect the user's configuration for sharding, precision, and offloading. Specifying these parameters ensures proper FSDP sharding and consistency with the rest of the model.