Skip to content

[Loader V1] modify layername for DeepSeekV3 #3336

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

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions fastdeploy/model_executor/models/deepseek_v3.py
Original file line number Diff line number Diff line change
Expand Up @@ -539,7 +539,7 @@ def __init__(
prefix="deepseek_v3.embed_tokens",
)

self.decoder_layers = nn.LayerList(
self.layers = nn.LayerList(
[
DeepSeekV3DecoderLayer(
fd_config,
Expand All @@ -564,7 +564,7 @@ def load_state_dict(self, state_dict):
self.norm.load_state_dict(state_dict)
for i in range(self.num_layers):
logger.info(f"Start load layer {i}")
self.decoder_layers[i].load_state_dict(state_dict)
self.layers[i].load_state_dict(state_dict)

def forward(
self,
Expand All @@ -578,7 +578,7 @@ def forward(

residual = None
for i in range(self.num_layers):
hidden_states, residual = self.decoder_layers[i](
hidden_states, residual = self.layers[i](
forward_meta,
hidden_states,
residual,
Expand Down Expand Up @@ -658,12 +658,11 @@ def load_weights(self, weights_iterator) -> None:

for loaded_weight_name, loaded_weight in weights_iterator:
loaded_weight_name = loaded_weight_name.replace("deepseek_v3", "model")
loaded_weight_name = loaded_weight_name.replace("layers", "decoder_layers")

for param_name, weight_name, shard_id in stacked_params_mapping:
if weight_name not in loaded_weight_name:
continue
if "mlp.experts." in loaded_weight_name and loaded_weight_name not in params_dict:
if "mlp.experts." in loaded_weight_name:
continue
model_param_name = loaded_weight_name.replace(weight_name, param_name)

Expand Down
Loading