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

This commit is contained in:
2025-10-24 23:53:13 +08:00
committed by GitHub
parent e04340bf48
commit 0bfa394aff
2 changed files with 10 additions and 3 deletions

View File

@@ -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()

View File

@@ -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."