Skip to content
Merged
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
6 changes: 5 additions & 1 deletion python/sglang/srt/models/deepseek_nextn.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,11 @@ def forward(
)

if not forward_batch.forward_mode.is_idle():
hidden_states, _ = self.shared_head.norm(hidden_states, residual)
if residual is not None:
hidden_states, _ = self.shared_head.norm(hidden_states, residual)
else:
hidden_states = self.shared_head.norm(hidden_states)
Comment on lines +110 to +113
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

The conditional logic can be simplified to be more concise. Instead of calling self.shared_head.norm in two different branches, call it once and handle the output based on its type. The RMSNorm.forward method can handle residual being None.

output = self.shared_head.norm(hidden_states, residual)
hidden_states = output[0] if isinstance(output, tuple) else output


return hidden_states


Expand Down
Loading