+1








f92d84fcf9
Signed-off-by: tzhouam <tzhouam@connect.ust.hk> Signed-off-by: ZhengWG <zwg0606@gmail.com> Signed-off-by: david6666666 <530634352@qq.com> Signed-off-by: Yueqian Lin <linyueqian@outlook.com> Signed-off-by: nainiu258 <cperfect02@163.com> Signed-off-by: nainiu258 <101917677+nainiu258@users.noreply.github.com> Signed-off-by: JasonJ2021 <jasonj@zju.edu.cn> Signed-off-by: Zhou Taichang <tzhouam@connect.ust.hk> Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com> Co-authored-by: skf <54565339+skf-1999@users.noreply.github.com> Co-authored-by: Zheng Wengang <zwg0606@gmail.com> Co-authored-by: Hongsheng Liu <liuhongsheng4@huawei.com> Co-authored-by: WeiQing Chen <40507679+david6666666@users.noreply.github.com> Co-authored-by: SYLAR <125541396+lishunyang12@users.noreply.github.com> Co-authored-by: Yueqian Lin <linyueqian@outlook.com> Co-authored-by: nainiu258 <101917677+nainiu258@users.noreply.github.com> Co-authored-by: Jason <72191212+JasonJ2021@users.noreply.github.com> Co-authored-by: Yueqian Lin <70319226+linyueqian@users.noreply.github.com>
24 lines
894 B
Python
24 lines
894 B
Python
# SPDX-License-Identifier: Apache-2.0
|
|
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
|
|
"""Shared utilities for omni schedulers."""
|
|
|
|
import numpy as np
|
|
from vllm.v1.outputs import RoutedExpertsLists
|
|
|
|
|
|
def omni_routed_experts_for_request(routed_experts: RoutedExpertsLists, request) -> np.ndarray | None:
|
|
"""Extract per-request routed experts from RoutedExpertsLists using slot_mapping.
|
|
|
|
Matches upstream RoutedExpertsManager.get() pattern — filters routing_data
|
|
rows whose slot_mapping entries belong to this request's block_table.
|
|
"""
|
|
if routed_experts is None:
|
|
return None
|
|
slots = getattr(request, "block_table", None)
|
|
if slots is None:
|
|
return None
|
|
slot_set = set(slots)
|
|
mask = np.isin(routed_experts.slot_mapping, list(slot_set))
|
|
data = routed_experts.routing_data[mask]
|
|
return data if data.size > 0 else None
|