[Misc] Split model loader (#17712)

Signed-off-by: Jee Jee Li <pandaleefree@gmail.com>
This commit is contained in:
Jee Jee Li
2025-05-07 12:42:26 +08:00
committed by GitHub
parent 8d84d836d1
commit 822de7fb94
21 changed files with 1681 additions and 1566 deletions
@@ -0,0 +1,23 @@
# SPDX-License-Identifier: Apache-2.0
from abc import ABC, abstractmethod
import torch.nn as nn
from vllm.config import LoadConfig, ModelConfig, VllmConfig
class BaseModelLoader(ABC):
"""Base class for model loaders."""
def __init__(self, load_config: LoadConfig):
self.load_config = load_config
@abstractmethod
def download_model(self, model_config: ModelConfig) -> None:
"""Download a model so that it can be immediately loaded."""
raise NotImplementedError
@abstractmethod
def load_model(self, *, vllm_config: VllmConfig) -> nn.Module:
"""Load a model with the given configurations."""
raise NotImplementedError