Skip to content

Commit 220487a

Browse files
Minor changes to deepseek_google_test.py
PiperOrigin-RevId: 817743737
1 parent e6aaca5 commit 220487a

3 files changed

Lines changed: 55 additions & 4 deletions

File tree

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# Copyright 2023–2025 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# https://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
# Tiny version of DeepSeek V3 for testing.
16+
17+
base_emb_dim: 64
18+
base_num_query_heads: 4
19+
base_num_kv_heads: 4
20+
base_mlp_dim: 64
21+
base_moe_mlp_dim: 64
22+
base_num_decoder_layers: 61
23+
first_num_dense_layers: 3
24+
mlp_activations: ["silu","linear"]
25+
vocab_size: 129280
26+
enable_dropout: False
27+
logits_via_embedding: False
28+
normalization_layer_epsilon: 1.0e-6
29+
num_experts: 16
30+
num_experts_per_tok: 8
31+
shared_experts: 1
32+
routed_scaling_factor: 2.5
33+
routed_score_func: "sigmoid"
34+
routed_bias: True
35+
decoder_block: "deepseek"
36+
# MLA
37+
attention_type: "mla"
38+
q_lora_rank: 32
39+
kv_lora_rank: 16
40+
qk_nope_head_dim: 128
41+
qk_rope_head_dim: 64
42+
v_head_dim: 128
43+
mscale: 1.0
44+
# RoPE
45+
rope_type: "yarn"
46+
rope_max_timescale: 10_000 # DeepSeek uses "rope_theta": 10000
47+
max_position_embeddings: 163840
48+
original_max_position_embeddings: 4096
49+
rope_factor: 40
50+
beta_fast: 32

src/MaxText/layers/deepseek_batchsplit.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
"""Alternative DeepSeek model definition with batch-split schedule."""
1818

19-
from flax import linen as nnx
19+
from flax import linen as nn
2020
import jax
2121
import jax.numpy as jnp
2222
from MaxText import common_types
@@ -29,7 +29,7 @@
2929
from MaxText.layers import quantizations
3030

3131

32-
class DeepSeekGenericLayer(nnx.Module):
32+
class DeepSeekGenericLayer(nn.Module):
3333
"""Generic DeepSeek layer with Multi-Head Latent Attention.
3434
3535
This is to be used as a base class for DeepSeek layers with dense/sparse MLPs.
@@ -101,7 +101,7 @@ def logical_axis_names(self):
101101
)
102102

103103
def with_logical_constraint(self, x):
104-
return nnx.with_logical_constraint(x, self.logical_axis_names)
104+
return nn.with_logical_constraint(x, self.logical_axis_names)
105105

106106
def rms_norm_layer(self, name):
107107
return normalizations.rms_norm(
@@ -187,7 +187,7 @@ def mlp(self, x, deterministic):
187187
raise NotImplementedError()
188188

189189
def dropout_layer(self):
190-
return nnx.Dropout(rate=self.config.dropout_rate, broadcast_dims=(-2,))
190+
return nn.Dropout(rate=self.config.dropout_rate, broadcast_dims=(-2,))
191191

192192
def dropout(self, x, deterministic):
193193
return self.with_logical_constraint(

src/MaxText/pyconfig.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -372,6 +372,7 @@ def validate_model_name(s: str) -> bool:
372372
"deepseek2-236b",
373373
"deepseek3-671b",
374374
"deepseek3-test",
375+
"deepseek3-tiny",
375376
"kimi-k2-1t",
376377
"gemma-7b",
377378
"gemma-2b",

0 commit comments

Comments
 (0)