[Fix]: HiCache hasher failed when EAGLE mode enabled (#12025)
This commit is contained in:
@@ -19,7 +19,13 @@ def get_hash_str(token_ids: List[int], prior_hash: str = None) -> str:
|
|||||||
hasher.update(bytes.fromhex(prior_hash))
|
hasher.update(bytes.fromhex(prior_hash))
|
||||||
|
|
||||||
for t in token_ids:
|
for t in token_ids:
|
||||||
hasher.update(t.to_bytes(4, byteorder="little", signed=False))
|
if isinstance(t, tuple):
|
||||||
|
# EAGLE bigram mode: hash both elements to uniquely identify the bigram
|
||||||
|
for elem in t:
|
||||||
|
hasher.update(elem.to_bytes(4, byteorder="little", signed=False))
|
||||||
|
else:
|
||||||
|
# Regular mode: single integer token
|
||||||
|
hasher.update(t.to_bytes(4, byteorder="little", signed=False))
|
||||||
|
|
||||||
return hasher.hexdigest()
|
return hasher.hexdigest()
|
||||||
|
|
||||||
|
|||||||
@@ -3,8 +3,9 @@ import atexit
|
|||||||
import json
|
import json
|
||||||
import logging
|
import logging
|
||||||
import threading
|
import threading
|
||||||
|
from collections import OrderedDict
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import Dict, List, Optional, OrderedDict, Tuple
|
from typing import Dict, List, Optional, Tuple
|
||||||
|
|
||||||
import orjson
|
import orjson
|
||||||
import requests
|
import requests
|
||||||
@@ -136,7 +137,7 @@ class GlobalMetadataState:
|
|||||||
num_pages = data["num_pages"]
|
num_pages = data["num_pages"]
|
||||||
rank_meta = RankMetadata(num_pages)
|
rank_meta = RankMetadata(num_pages)
|
||||||
rank_meta.free_pages = data["free_pages"]
|
rank_meta.free_pages = data["free_pages"]
|
||||||
rank_meta.key_to_index = dict(data["key_to_index"])
|
rank_meta.key_to_index = OrderedDict(data["key_to_index"])
|
||||||
self.ranks[rank_id] = rank_meta
|
self.ranks[rank_id] = rank_meta
|
||||||
logging.info(
|
logging.info(
|
||||||
f"Successfully loaded metadata for {len(self.ranks)} ranks."
|
f"Successfully loaded metadata for {len(self.ranks)} ranks."
|
||||||
|
|||||||
Reference in New Issue
Block a user