Skip to content
Closed
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions fastdeploy/model_executor/layers/normalization.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,14 +105,14 @@ def __init__(
self.tp_rank = self.fd_config.parallel_config.tensor_parallel_rank
self.tp_group = self.fd_config.parallel_config.tp_group
is_input_norm = prefix.endswith(".input_layernorm")
self.is_last_norm = prefix.endswith(".norm")
is_last_norm = prefix.endswith(".norm")
self.split_x = (
self.fd_config.parallel_config.use_sequence_parallel_moe
and self.layer_id == self.fd_config.model_config.moe_layer_start_index
and is_input_norm
)
self.allgather_out = self.fd_config.parallel_config.use_sequence_parallel_moe and (
(self.layer_id > self.fd_config.model_config.moe_layer_start_index and is_input_norm)
(self.layer_id > self.fd_config.model_config.moe_layer_start_index and is_input_norm) or is_last_norm
)

self.init_weight()
Expand Down
3 changes: 0 additions & 3 deletions fastdeploy/model_executor/models/deepseek_v3.py
Original file line number Diff line number Diff line change
Expand Up @@ -591,9 +591,6 @@ def forward(
)
out = self.norm(hidden_states, residual, forward_meta=forward_meta)[0]

if self.norm.is_last_norm and self.norm.fd_config.parallel_config.use_sequence_parallel_moe:
out = self.norm.allgather(out, forward_meta.ids_remove_padding.shape[0])

return out


Expand Down
3 changes: 0 additions & 3 deletions fastdeploy/model_executor/models/ernie4_5_moe.py
Original file line number Diff line number Diff line change
Expand Up @@ -449,9 +449,6 @@ def forward(

out = self.norm(hidden_states, residual, forward_meta=forward_meta)[0]

if self.norm.is_last_norm and self.norm.fd_config.parallel_config.use_sequence_parallel_moe:
out = self.norm.allgather(out, forward_meta.ids_remove_padding.shape[0])

if current_platform.is_iluvatar() and forward_meta.attn_backend.mixed:
out = forward_meta.attn_backend.reverse_transpose(out)

Expand Down
7 changes: 2 additions & 5 deletions fastdeploy/model_executor/models/ernie4_5_mtp.py
Original file line number Diff line number Diff line change
Expand Up @@ -326,10 +326,7 @@ def forward(
for i in range(self.num_layers):
hidden_states, residual = self.mtp_block[i](forward_meta, hidden_states, residual)

hidden_states = self.norm(hidden_states, residual, forward_meta=forward_meta)[0]

if self.norm.is_last_norm and self.norm.fd_config.parallel_config.use_sequence_parallel_moe:
hidden_states = self.norm.allgather(hidden_states, forward_meta.ids_remove_padding.shape[0])
hidden_states = self.norm(hidden_states, residual)[0]

return hidden_states

Expand Down Expand Up @@ -429,7 +426,7 @@ def load_weights(self, weights_iterator) -> None:
)
process_weights_after_loading_fn(model_sublayer_name, param)

def compute_logits(self, hidden_states: paddle.Tensor, forward_meta: ForwardMeta):
def compute_logits(self, hidden_states: paddle.Tensor):
"""
compute logits
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -543,9 +543,6 @@ def forward(

out = self.norm(hidden_states, residual, forward_meta=forward_meta)[0]

if self.norm.is_last_norm and self.norm.fd_config.parallel_config.use_sequence_parallel_moe:
out = self.norm.allgather(out, forward_meta.ids_remove_padding.shape[0])

return out


Expand Down
3 changes: 0 additions & 3 deletions fastdeploy/model_executor/models/glm4_moe.py
Original file line number Diff line number Diff line change
Expand Up @@ -370,9 +370,6 @@ def forward(

out = self.norm(hidden_states, residual, forward_meta=forward_meta)[0]

if self.norm.is_last_norm and self.norm.fd_config.parallel_config.use_sequence_parallel_moe:
out = self.norm.allgather(out, forward_meta.ids_remove_padding.shape[0])

return out


Expand Down
8 changes: 2 additions & 6 deletions fastdeploy/model_executor/models/gpt_oss.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,12 +214,8 @@ def forward(self, ids_remove_padding: paddle.Tensor, forward_meta: ForwardMeta):
for i in range(self.num_layers):
hidden_states, residual = self.layers[i](forward_meta, hidden_states, residual)

out = self.norm(hidden_states, residual, forward_meta=forward_meta)[0]

if self.norm.is_last_norm and self.norm.fd_config.parallel_config.use_sequence_parallel_moe:
out = self.norm.allgather(out, forward_meta.ids_remove_padding.shape[0])

return out
hidden_states = self.norm(hidden_states, residual)[0]
return hidden_states


@ModelRegistry.register_model_class(
Expand Down
3 changes: 0 additions & 3 deletions fastdeploy/model_executor/models/qwen3moe.py
Original file line number Diff line number Diff line change
Expand Up @@ -284,9 +284,6 @@ def forward(

out = self.norm(hidden_states, residual, forward_meta=forward_meta)[0]

if self.norm.is_last_norm and self.norm.fd_config.parallel_config.use_sequence_parallel_moe:
out = self.norm.allgather(out, forward_meta.ids_remove_padding.shape[0])

return out


Expand Down
2 changes: 1 addition & 1 deletion fastdeploy/spec_decode/mtp.py
Original file line number Diff line number Diff line change
Expand Up @@ -886,7 +886,7 @@ def _propose(self, step_use_cudagraph: bool = False, is_dummy_run=False):
)

# 4. Compute logits, Sample
logits = self.model.compute_logits(hidden_states, forward_meta=self.forward_meta)
logits = self.model.compute_logits(hidden_states)
if self.enable_logprob and substep == 0:
first_token_logits = self.model.compute_logits(self.model_inputs["first_token_hidden_states"])

Expand Down
Loading