From 4080e82244f72dd8c60a1e89928c568e2dc5dd1c Mon Sep 17 00:00:00 2001 From: Lianmin Zheng Date: Sun, 11 Aug 2024 04:53:51 -0700 Subject: [PATCH] Fix the case where r.prefix_indices is None (#1031) --- python/sglang/srt/managers/policy_scheduler.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/python/sglang/srt/managers/policy_scheduler.py b/python/sglang/srt/managers/policy_scheduler.py index e252c2737..925b74b91 100644 --- a/python/sglang/srt/managers/policy_scheduler.py +++ b/python/sglang/srt/managers/policy_scheduler.py @@ -35,13 +35,12 @@ class PolicyScheduler: self.tree_cache = tree_cache def calc_priority(self, waiting_queue: List[Req]): - if self.policy in ["lpm", "dfs-weight"]: - # Compute matched prefix length - for r in waiting_queue: - # NOTE: the prefix_indices must always be aligned with last_node - r.prefix_indices, r.last_node = self.tree_cache.match_prefix( - rid=r.rid, key=r.adjust_max_prefix_ids() - ) + # Compute matched prefix length + for r in waiting_queue: + # NOTE: the prefix_indices must always be aligned with last_node + r.prefix_indices, r.last_node = self.tree_cache.match_prefix( + rid=r.rid, key=r.adjust_max_prefix_ids() + ) if self.policy == "lpm": # Longest Prefix Match