[TPU] Optimize kv cache update kernel (#20415)

Signed-off-by: Yifei Teng <tengyifei88@gmail.com>
This commit is contained in:
Yifei Teng
2025-07-15 03:56:43 -07:00
committed by GitHub
parent 33d560001e
commit c586b55667
3 changed files with 63 additions and 16 deletions
+7
View File
@@ -947,6 +947,13 @@ def next_power_of_2(n) -> int:
return 1 << (n - 1).bit_length()
def prev_power_of_2(n: int) -> int:
"""The previous power of 2 (inclusive)"""
if n <= 0:
return 0
return 1 << (n.bit_length() - 1)
def round_up(x: int, y: int) -> int:
return ((x + y - 1) // y) * y