From 98c3b168da468724fa748f8a6f25dccb9499fa93 Mon Sep 17 00:00:00 2001 From: Marceli Fylcek Date: Thu, 2 Jan 2025 12:58:26 +0200 Subject: [PATCH 1/2] Pad to bmin if value is less --- vllm_hpu_extension/bucketing.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/vllm_hpu_extension/bucketing.py b/vllm_hpu_extension/bucketing.py index 8a2fe2d9..6249826b 100644 --- a/vllm_hpu_extension/bucketing.py +++ b/vllm_hpu_extension/bucketing.py @@ -259,4 +259,8 @@ def find_bucket(value: int, config: Tuple[int, int, int]) -> int: bmin, bstep, _ = config next_step = round_up(value, bstep) next_pow = next_pow2(value, bmin) - return max(bmin, min(next_step, next_pow)) + found_bucket = min(next_step, next_pow) + if value > bmin: + return found_bucket + else: + return bmin From 1b56a51d8d28214147ba4cbd6db428e97a16ae58 Mon Sep 17 00:00:00 2001 From: Marceli Fylcek Date: Thu, 2 Jan 2025 13:24:10 +0200 Subject: [PATCH 2/2] Simplify --- vllm_hpu_extension/bucketing.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/vllm_hpu_extension/bucketing.py b/vllm_hpu_extension/bucketing.py index 6249826b..5d52bbeb 100644 --- a/vllm_hpu_extension/bucketing.py +++ b/vllm_hpu_extension/bucketing.py @@ -257,10 +257,10 @@ def round_up(value: int, k: int) -> int: def find_bucket(value: int, config: Tuple[int, int, int]) -> int: bmin, bstep, _ = config - next_step = round_up(value, bstep) - next_pow = next_pow2(value, bmin) - found_bucket = min(next_step, next_pow) - if value > bmin: - return found_bucket - else: + if value <= bmin: return bmin + else: + next_step = round_up(value, bstep) + next_pow = next_pow2(value, bmin) + return min(next_step, next_pow) +