Skip to content

revert(mtp): drop shared BaseMTPModel base, keep per-model is_mtp_draft_model (revert #1337)#1339

Merged
sufubao merged 2 commits into
ModelTC:mainfrom
sufubao:revert-mtp-base-mixin
Jun 9, 2026
Merged

revert(mtp): drop shared BaseMTPModel base, keep per-model is_mtp_draft_model (revert #1337)#1339
sufubao merged 2 commits into
ModelTC:mainfrom
sufubao:revert-mtp-base-mixin

Conversation

@sufubao

@sufubao sufubao commented Jun 9, 2026

Copy link
Copy Markdown
Collaborator

Reverts the BaseMTPModel shared-base refactor from #1337 — per review feedback that consolidating the existing MTP models onto a shared base class isn't the right tradeoff.

What this does

  1. Revert refactor(mtp): extract BaseMTPModel mixin shared by existing MTP draft models #1337 — restores the deepseek / mistral / glm4_moe_lite / qwen3_moe MTP models to their original standalone (inline) wiring, and removes lightllm/models/base_mtp_model.py and its unit test.
  2. Keep the one needed bit — re-adds is_mtp_draft_model = True as an explicit class marker on each of the four models (previously inherited from BaseMTPModel). The MTP decode CUDA-graph / padding paths use this marker to detect a draft model, so detection keeps working without the shared base.

Net result: the four MTP models are standalone again, each carrying its own wiring plus a one-line marker — no shared base class.

Testing

  • pre-commit (black 21.12b0 + flake8 6.1.0) clean.

sufubao added 2 commits June 9, 2026 09:31
Re-add the is_mtp_draft_model = True class marker (previously supplied by the reverted BaseMTPModel base) directly on each standalone MTP draft model, so the decode CUDA-graph / padding paths still detect them. Keeps the models self-contained with no shared base class.

@gemini-code-assist gemini-code-assist Bot left a comment

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.

Code Review

This pull request refactors the MTP draft models by removing the "BaseMTPModel" mixin class and inlining its initialization and manager-sharing logic directly into the individual model classes ("Deepseek3MTPModel", "Glm4MoeLiteMTPModel", "MistralMTPModel", and "Qwen3MOEMTPModel"). The review feedback recommends removing redundant explicit "return" statements from the newly added initializer and setup methods across these models to comply with PEP 8 guidelines and improve code readability.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment on lines +16 to +37
def __init__(self, kvargs: dict):
self._pre_init(kvargs)
super().__init__(kvargs)
return

def _pre_init(self, kvargs: dict):
self.main_model: TpPartBaseModel = kvargs.pop("main_model")
self.mtp_previous_draft_models: List[TpPartBaseModel] = kvargs.pop("mtp_previous_draft_models")
return

def _init_custom(self):
self._cos_cached = self.main_model._cos_cached
self._sin_cached = self.main_model._sin_cached
return

def _init_req_manager(self):
self.req_manager = self.main_model.req_manager
return

def _init_mem_manager(self):
self.mem_manager = self.main_model.mem_manager
return

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.

medium

According to PEP 8 and standard Python idioms, explicit return statements at the end of functions that do not return a value (such as __init__ and other initializer/setter methods) are redundant and should be omitted. Removing them improves code readability and ensures consistency with Glm4MoeLiteMTPModel which correctly omits them.

Suggested change
def __init__(self, kvargs: dict):
self._pre_init(kvargs)
super().__init__(kvargs)
return
def _pre_init(self, kvargs: dict):
self.main_model: TpPartBaseModel = kvargs.pop("main_model")
self.mtp_previous_draft_models: List[TpPartBaseModel] = kvargs.pop("mtp_previous_draft_models")
return
def _init_custom(self):
self._cos_cached = self.main_model._cos_cached
self._sin_cached = self.main_model._sin_cached
return
def _init_req_manager(self):
self.req_manager = self.main_model.req_manager
return
def _init_mem_manager(self):
self.mem_manager = self.main_model.mem_manager
return
def __init__(self, kvargs: dict):
self._pre_init(kvargs)
super().__init__(kvargs)
def _pre_init(self, kvargs: dict):
self.main_model: TpPartBaseModel = kvargs.pop("main_model")
self.mtp_previous_draft_models: List[TpPartBaseModel] = kvargs.pop("mtp_previous_draft_models")
def _init_custom(self):
self._cos_cached = self.main_model._cos_cached
self._sin_cached = self.main_model._sin_cached
def _init_req_manager(self):
self.req_manager = self.main_model.req_manager
def _init_mem_manager(self):
self.mem_manager = self.main_model.mem_manager
References
  1. PEP 8 recommends omitting explicit return statements at the end of functions that do not return a value. (link)

Comment on lines +24 to +32
def __init__(self, kvargs: dict):
self._pre_init(kvargs)
super().__init__(kvargs)
return

def _pre_init(self, kvargs: dict):
self.main_model: TpPartBaseModel = kvargs.pop("main_model")
self.mtp_previous_draft_models: List[TpPartBaseModel] = kvargs.pop("mtp_previous_draft_models")
return

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.

medium

According to PEP 8 and standard Python idioms, explicit return statements at the end of functions that do not return a value are redundant and should be omitted. Removing them improves code readability and ensures consistency with Glm4MoeLiteMTPModel.

Suggested change
def __init__(self, kvargs: dict):
self._pre_init(kvargs)
super().__init__(kvargs)
return
def _pre_init(self, kvargs: dict):
self.main_model: TpPartBaseModel = kvargs.pop("main_model")
self.mtp_previous_draft_models: List[TpPartBaseModel] = kvargs.pop("mtp_previous_draft_models")
return
def __init__(self, kvargs: dict):
self._pre_init(kvargs)
super().__init__(kvargs)
def _pre_init(self, kvargs: dict):
self.main_model: TpPartBaseModel = kvargs.pop("main_model")
self.mtp_previous_draft_models: List[TpPartBaseModel] = kvargs.pop("mtp_previous_draft_models")
References
  1. PEP 8 recommends omitting explicit return statements at the end of functions that do not return a value. (link)

Comment on lines +39 to +50
def _init_custom(self):
self._cos_cached = self.main_model._cos_cached
self._sin_cached = self.main_model._sin_cached
return

def _init_req_manager(self):
self.req_manager = self.main_model.req_manager
return

def _init_mem_manager(self):
self.mem_manager = self.main_model.mem_manager
return

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.

medium

According to PEP 8 and standard Python idioms, explicit return statements at the end of functions that do not return a value are redundant and should be omitted. Removing them improves code readability and ensures consistency with Glm4MoeLiteMTPModel.

Suggested change
def _init_custom(self):
self._cos_cached = self.main_model._cos_cached
self._sin_cached = self.main_model._sin_cached
return
def _init_req_manager(self):
self.req_manager = self.main_model.req_manager
return
def _init_mem_manager(self):
self.mem_manager = self.main_model.mem_manager
return
def _init_custom(self):
self._cos_cached = self.main_model._cos_cached
self._sin_cached = self.main_model._sin_cached
def _init_req_manager(self):
self.req_manager = self.main_model.req_manager
def _init_mem_manager(self):
self.mem_manager = self.main_model.mem_manager
References
  1. PEP 8 recommends omitting explicit return statements at the end of functions that do not return a value. (link)

Comment on lines +21 to +42
def __init__(self, kvargs: dict):
self._pre_init(kvargs)
super().__init__(kvargs)
return

def _pre_init(self, kvargs: dict):
self.main_model: TpPartBaseModel = kvargs.pop("main_model")
self.mtp_previous_draft_models: List[TpPartBaseModel] = kvargs.pop("mtp_previous_draft_models")
return

def _init_custom(self):
self._cos_cached = self.main_model._cos_cached
self._sin_cached = self.main_model._sin_cached
return

def _init_req_manager(self):
self.req_manager = self.main_model.req_manager
return

def _init_mem_manager(self):
self.mem_manager = self.main_model.mem_manager
return

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.

medium

According to PEP 8 and standard Python idioms, explicit return statements at the end of functions that do not return a value are redundant and should be omitted. Removing them improves code readability and ensures consistency with Glm4MoeLiteMTPModel.

Suggested change
def __init__(self, kvargs: dict):
self._pre_init(kvargs)
super().__init__(kvargs)
return
def _pre_init(self, kvargs: dict):
self.main_model: TpPartBaseModel = kvargs.pop("main_model")
self.mtp_previous_draft_models: List[TpPartBaseModel] = kvargs.pop("mtp_previous_draft_models")
return
def _init_custom(self):
self._cos_cached = self.main_model._cos_cached
self._sin_cached = self.main_model._sin_cached
return
def _init_req_manager(self):
self.req_manager = self.main_model.req_manager
return
def _init_mem_manager(self):
self.mem_manager = self.main_model.mem_manager
return
def __init__(self, kvargs: dict):
self._pre_init(kvargs)
super().__init__(kvargs)
def _pre_init(self, kvargs: dict):
self.main_model: TpPartBaseModel = kvargs.pop("main_model")
self.mtp_previous_draft_models: List[TpPartBaseModel] = kvargs.pop("mtp_previous_draft_models")
def _init_custom(self):
self._cos_cached = self.main_model._cos_cached
self._sin_cached = self.main_model._sin_cached
def _init_req_manager(self):
self.req_manager = self.main_model.req_manager
def _init_mem_manager(self):
self.mem_manager = self.main_model.mem_manager
References
  1. PEP 8 recommends omitting explicit return statements at the end of functions that do not return a value. (link)

@sufubao sufubao merged commit da9dfb8 into ModelTC:main Jun 9, 2026
1 check passed
@sufubao sufubao deleted the revert-mtp-base-mixin branch June 9, 2026 01:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant