Repository navigation
[Mypy Fix] Mypy fix for "vllm/model_executor/models/[tT]" #53466
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
Merged
Merged
Changes from 1 commit
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
0c4bb0e
[Mypy Fix] Mypy fix for "vllm/model_executor/models/[tT]"
ZHIHANCHEN03 8e3e891
Address review: drop explanatory comments
ZHIHANCHEN03 fa3165f
Merge branch 'main' into fix/mypy-models-t
mergify[bot] fa00c39
Merge branch 'main' into fix/mypy-models-t
mergify[bot] File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -28,7 +28,7 @@ | |||||||||
| from vllm.config import VllmConfig | ||||||||||
| from vllm.model_executor.models.llama import LlamaForCausalLM, LlamaModel | ||||||||||
|
|
||||||||||
| from .llama import LlamaDecoderLayer | ||||||||||
| from .llama import LlamaAttention, LlamaDecoderLayer, LlamaMLP | ||||||||||
| from .utils import AutoWeightsLoader, PPMissingLayer, WeightsMapper | ||||||||||
|
|
||||||||||
|
|
||||||||||
|
|
@@ -46,7 +46,9 @@ class TeleChat2Model(LlamaModel): | |||||||||
| def __init__(self, *, vllm_config: VllmConfig, prefix: str = ""): | ||||||||||
| hf_config = vllm_config.model_config.hf_config | ||||||||||
|
|
||||||||||
| vllm_config.model_config.hf_config.attribute_map = { | ||||||||||
| # `attribute_map` is a ClassVar on `PretrainedConfig`; shadowing it on the | ||||||||||
| # instance is intentional here so LlamaModel can read TeleChat2's fields. | ||||||||||
| vllm_config.model_config.hf_config.attribute_map = { # type: ignore[misc] | ||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
comment not needed |
||||||||||
| "num_hidden_layers": "n_layer", | ||||||||||
| "num_attention_heads": "n_head", | ||||||||||
| "intermediate_size": "ffn_hidden_size", | ||||||||||
|
|
@@ -63,11 +65,16 @@ def __init__(self, *, vllm_config: VllmConfig, prefix: str = ""): | |||||||||
| # Telechat2's gate_up_proj and qkv_proj don't have bias | ||||||||||
| # see: https://github.com/vllm-project/vllm/pull/10311#issuecomment-2490297566 | ||||||||||
| for layer in self.layers: | ||||||||||
| if not isinstance(layer, PPMissingLayer): | ||||||||||
| layer.self_attn.qkv_proj.bias = None | ||||||||||
| layer.self_attn.qkv_proj.skip_bias_add = True | ||||||||||
| layer.mlp.gate_up_proj.bias = None | ||||||||||
| layer.mlp.gate_up_proj.skip_bias_add = True | ||||||||||
| if isinstance(layer, PPMissingLayer): | ||||||||||
| continue | ||||||||||
| self_attn = layer.self_attn | ||||||||||
| mlp = layer.mlp | ||||||||||
| assert isinstance(self_attn, LlamaAttention) | ||||||||||
| assert isinstance(mlp, LlamaMLP) | ||||||||||
| self_attn.qkv_proj.register_parameter("bias", None) | ||||||||||
| self_attn.qkv_proj.skip_bias_add = True | ||||||||||
| mlp.gate_up_proj.register_parameter("bias", None) | ||||||||||
| mlp.gate_up_proj.skip_bias_add = True | ||||||||||
|
|
||||||||||
| def _split_key_value( | ||||||||||
| self, weights: Iterable[tuple[str, torch.Tensor]] | ||||||||||
|
|
||||||||||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comment not needed