Skip to content

Commit 5f9dd4a

Browse files
huangtingwei9988jianan-gu
authored andcommitted
fix multimodal hash feature (sgl-project#5083)
1 parent 655dbce commit 5f9dd4a

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

python/sglang/srt/managers/schedule_batch.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,8 +198,15 @@ def set_pad_value(self):
198198
Set the pad value after first hashign the data
199199
"""
200200

201+
def tensor_hash(f):
202+
f_list = flatten_nested_list(f)
203+
f_cat = torch.concat(f_list).contiguous().numpy().tobytes()
204+
return hash(f_cat)
205+
201206
def hash_feature(f):
202207
if isinstance(f, list):
208+
if isinstance(f[0], torch.Tensor):
209+
return tensor_hash(f)
203210
return hash(tuple(flatten_nested_list(f)))
204211
elif isinstance(f, np.ndarray):
205212
arr = np.ascontiguousarray(f)

0 commit comments

Comments
 (0)