Refactor eagle bigram key matching (#13714)
This commit is contained in:
@@ -13,7 +13,7 @@
|
||||
# ==============================================================================
|
||||
"""Common utilities."""
|
||||
|
||||
from typing import Any, Optional, Tuple
|
||||
from typing import Any, List, Optional, Tuple
|
||||
|
||||
import torch
|
||||
import triton
|
||||
@@ -241,3 +241,13 @@ def maybe_init_custom_mem_pool(
|
||||
return init_mooncake_custom_mem_pool(device)
|
||||
else:
|
||||
return False, None, None
|
||||
|
||||
|
||||
def convert_to_bigram_key(tokens: List[int]) -> List[Tuple[int, int]]:
|
||||
# EAGLE uses bigram keys in the radix tree since draft sequence is the one-token-shifted version of target
|
||||
# [1, 2, 3, 4] -> [(1,2), (2,3), (3,4)]
|
||||
if len(tokens) and isinstance(tokens[0], tuple):
|
||||
return tokens
|
||||
if len(tokens) < 2:
|
||||
return []
|
||||
return [(tokens[i], tokens[i + 1]) for i in range(len(tokens) - 1)]
|
||||
|
||||
Reference in New Issue
Block a user