-
Notifications
You must be signed in to change notification settings - Fork 82
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: KuntaiDu <[email protected]>
- Loading branch information
Showing
14 changed files
with
285 additions
and
163 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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 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
39 changes: 23 additions & 16 deletions
39
src/vllm_router/services/routing_service/affinity/factory.py
This file contains 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 |
---|---|---|
@@ -1,32 +1,39 @@ | ||
|
||
from vllm_router.services.routing_service.affinity.base import BaseAffinity | ||
|
||
import json | ||
from logging import getLogger | ||
|
||
from vllm_router.services.routing_service.affinity.base import BaseAffinity | ||
|
||
logger = getLogger(__name__) | ||
|
||
from vllm_router.services.routing_service.affinity.round_robin_affinity import RoundRobinAffinity | ||
from vllm_router.services.routing_service.affinity.session_based_affinity import SessionBasedAffinity | ||
from vllm_router.services.routing_service.affinity.longest_prefix_affinity import LongestPrefixAffinity | ||
from vllm_router.services.routing_service.affinity.simhash_affinity import SimhashAffinity | ||
from vllm_router.services.routing_service.affinity.longest_prefix_affinity import ( | ||
LongestPrefixAffinity, | ||
) | ||
from vllm_router.services.routing_service.affinity.round_robin_affinity import ( | ||
RoundRobinAffinity, | ||
) | ||
from vllm_router.services.routing_service.affinity.session_affinity import ( | ||
SessionAffinity, | ||
) | ||
from vllm_router.services.routing_service.affinity.simhash_affinity import ( | ||
SimhashAffinity, | ||
) | ||
|
||
affinity_name_to_class = { | ||
"round_robin": RoundRobinAffinity, | ||
"session": SessionBasedAffinity, | ||
"session": SessionAffinity, | ||
"longest_prefix": LongestPrefixAffinity, | ||
"simhash": SimhashAffinity, | ||
} | ||
|
||
def get_affinity(affinity_name: str, affinity_config: Dict[str, Any] = {}, **kwargs) -> BaseAffinity: | ||
|
||
if affinity_name not in affinity_name_to_class: | ||
raise ValueError(f"Invalid affinity name: {affinity_name}") | ||
def get_affinity(routing_affinity_name: str, **kwargs) -> BaseAffinity: | ||
|
||
if routing_affinity_name not in affinity_name_to_class: | ||
raise ValueError(f"Invalid affinity name: {routing_affinity_name}") | ||
|
||
assert kwargs == {}, ("There are extra kwargs forwarded to the affinity " | ||
"factory method. This is likely unintended. " | ||
"Received kwargs: %s" % kwargs) | ||
routing_affinity_config = kwargs | ||
|
||
logger.info(f"Using affinity type: {affinity_name} with config: {affinity_config}") | ||
return affinity_name_to_class[affinity_name](**affinity_config) | ||
logger.info( | ||
f"Using affinity type: {routing_affinity_name} with config: {routing_affinity_config}" | ||
) | ||
return affinity_name_to_class[routing_affinity_name](**routing_affinity_config) |
Oops, something went wrong.