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: 3 additions & 1 deletion vllm/model_executor/models/deepseek_mtp.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,9 @@ def __init__(self, vllm_config: VllmConfig, prefix: str) -> None:
topk_indices_buffer = None

self.shared_head = SharedHead(
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

high

While the change to add a prefix is correct, I've noticed that the SharedHead class is duplicated. An identical implementation exists in vllm/model_executor/models/glm4_moe_mtp.py. To adhere to the DRY (Don't Repeat Yourself) principle and improve long-term maintainability, this class should be defined in a single, shared location, such as vllm/model_executor/models/utils.py, and then imported where needed. This would prevent future inconsistencies and simplify changes like the one in this PR, as it would only need to be applied once.

config=config, prefix=prefix, quant_config=quant_config
config=config,
prefix=maybe_prefix(prefix, "shared_head"),
quant_config=quant_config,
)
self.mtp_block = DeepseekV2DecoderLayer(
vllm_config,
Expand Down
4 changes: 3 additions & 1 deletion vllm/model_executor/models/glm4_moe_mtp.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,9 @@ def __init__(
self.hnorm = RMSNorm(config.hidden_size, eps=config.rms_norm_eps)
self.eh_proj = nn.Linear(config.hidden_size * 2, config.hidden_size, bias=False)
self.shared_head = SharedHead(
config=config, prefix=prefix, quant_config=quant_config
config=config,
prefix=maybe_prefix(prefix, "shared_head"),
quant_config=quant_config,
)
self.mtp_block = Glm4MoeDecoderLayer(
config=config,
Expand Down
Loading