Unverified Commit 0bfa394a authored by Yuanhang Sun's avatar Yuanhang Sun Committed by GitHub
Browse files

[Fix]: HiCache hasher failed when EAGLE mode enabled (#12025)

parent e04340bf
......@@ -19,7 +19,13 @@ def get_hash_str(token_ids: List[int], prior_hash: str = None) -> str:
hasher.update(bytes.fromhex(prior_hash))
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()
......
......@@ -3,8 +3,9 @@ import atexit
import json
import logging
import threading
from collections import OrderedDict
from pathlib import Path
from typing import Dict, List, Optional, OrderedDict, Tuple
from typing import Dict, List, Optional, Tuple
import orjson
import requests
......@@ -136,7 +137,7 @@ class GlobalMetadataState:
num_pages = data["num_pages"]
rank_meta = RankMetadata(num_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
logging.info(
f"Successfully loaded metadata for {len(self.ranks)} ranks."
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment