MCPcopy Create free account
hub / github.com/LMCache/LMCache / from_string

Method from_string

lmcache/utils.py:489–508  ·  view source on GitHub ↗
(s)

Source from the content-addressed store, hash-verified

487
488 @staticmethod
489 def from_string(s):
490 parts = s.split("@")
491 if len(parts) < 5:
492 raise ValueError(f"Invalid key string: {s}")
493 request_configs = None
494 if len(parts) >= 6:
495 request_configs = {}
496 for kv in parts[5:]:
497 kvs = kv.split("%", 1)
498 if len(kvs) != 2:
499 raise ValueError(f"Invalid key string: {s}")
500 request_configs["lmcache.tag." + kvs[0]] = kvs[1]
501 return CacheEngineKey(
502 model_name=parts[0],
503 world_size=int(parts[1]),
504 worker_id=int(parts[2]),
505 chunk_hash=int(parts[3], 16),
506 dtype=STR_DTYPE_TO_TORCH_DTYPE[parts[4]],
507 request_configs=request_configs,
508 )
509
510 def to_dict(self):
511 # Note(Kuntai): this is used for serializing CacheEngineKey via msgpack.

Calls 1

CacheEngineKeyClass · 0.85