Unverified Commit 1361ab9e authored by Lianmin Zheng's avatar Lianmin Zheng Committed by GitHub
Browse files

Lazily import lora backends (#4225)

parent 5c7dd14b
from .base_backend import BaseLoRABackend
from .flashinfer_backend import FlashInferLoRABackend
from .triton_backend import TritonLoRABackend
from sglang.srt.lora.backend.base_backend import BaseLoRABackend
def get_backend_from_name(name: str) -> BaseLoRABackend:
"""
Get corresponding backend class from backend's name
"""
backend_mapping = {
"triton": TritonLoRABackend,
"flashinfer": FlashInferLoRABackend,
}
if name == "triton":
from sglang.srt.lora.backend.triton_backend import TritonLoRABackend
if name in backend_mapping:
return backend_mapping[name]
return TritonLoRABackend
elif name == "flashinfer":
from sglang.srt.lora.backend.flashinfer_backend import FlashInferLoRABackend
raise Exception(
f"No supported lora backend called {name}. It should be one of {list(backend_mapping.keys())}"
)
return FlashInferLoRABackend
else:
raise ValueError(f"Invalid backend: {name}")
__all__ = [
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment