-
-
Notifications
You must be signed in to change notification settings - Fork 5.9k
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
[Core][Model][Frontend] Model architecture plugins #7438
Conversation
👋 Hi! Thank you for contributing to the vLLM project. Once the PR is approved and ready to go, please make sure to run full CI as it is required to merge (or just use auto-merge). To run full CI, you can do one of these:
🚀 |
Will take a look after #7426 |
I think the model class also needs to implement from typing import Protocol, runtime_checkable
from typing_extensions import TypeVar
# Currently, T = torch.Tensor for all models except Medusa, which has T = List[torch.Tensor]
T = TypeVar("T", default=torch.Tensor)
@runtime_checkable
class SupportsVllm(Protocol[T]):
def __init__(
self,
config: PreTrainedConfig,
*,
# In vllm.model_executor.model_loader, the model is always constructed by passing these via kwargs
cache_config: Optional[CacheConfig],
quant_config: Optional[QuantizationConfig],
) -> None:
...
def forward(
self,
input_ids: torch.Tensor,
positions: torch.Tensor,
kv_caches: List[torch.Tensor],
attn_metadata: AttentionMetadata,
intermediate_tensors: Optional[IntermediateTensors] = None,
) -> T:
...
def compute_logits(
self,
hidden_states: T,
sampling_metadata: SamplingMetadata,
) -> Optional[T]:
"""Return `None` if rank > 0."""
...
def sample(
self,
logits: T,
sampling_metadata: SamplingMetadata,
) -> SamplerOutput:
"""Only called on rank 0."""
... |
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.
I feel this is quite complicated, but actually we just need one line ModelRegistry.register_model
.
I would prefer it remains a general plugin.
I think we need to come up with a new plugin type, only when it is very difficult to achieve through existing one.
I can see what you are saying, I think it would be acceptable to enable this functionality with general plugins, but I don't see much downside to supporting this specific type of plugin, as it should be used quite frequently. Regardless of how we support this, I believe we should at least add the |
I will only accept PRs that bring evident benefit. No downside is not a good pitch. I try to avoid the codebase being too swollen.
I don't understand this. With |
I didn't realize In this case, it's really simple to create a general purpose plugin to achieve the goal, so it's not necessary to create a specific plugin type. But I do believe in most cases, unless very simple to implement, we should lean towards specific plugin types to make the plugin system more robust. Do you agree? Furthermore, can you think of a plugin type that could already be implemented in the existing state of vLLM? |
Solves #7124 (also relevant for #7131).
This pull request implements support for external model architecture plugins.
As discussed in #7131, vLLM should support both "general purpose" plugins which allow arbitrary modifications, but in addition it should allow simple plugin interfaces for parts in the vLLM architecture which might change a lot.
Using this pull request we can simply create a separate package implementing a model architecture, and install it in the same environment as vLLM.
If the model architecture plugin overrides an existing architecture you can use the
--model-architecture-override
option to specify the name of the new architecture to use.Code for a mock
OPT
architecture implementationSetup.py
fileTodo list