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

Method from_string

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

Source from the content-addressed store, hash-verified

614
615 @staticmethod
616 def from_string(s):
617 parts = s.split("@")
618 if len(parts) < 6:
619 raise ValueError(f"Invalid key string: {s}")
620 request_configs = None
621 if len(parts) >= 7:
622 request_configs = {}
623 for kv in parts[6:]:
624 kvs = kv.split("%", 1)
625 if len(kvs) != 2:
626 raise ValueError(f"Invalid key string: {s}")
627 request_configs["lmcache.tag." + kvs[0]] = kvs[1]
628 return LayerCacheEngineKey(
629 model_name=parts[0],
630 world_size=int(parts[1]),
631 worker_id=int(parts[2]),
632 chunk_hash=int(parts[3], 16),
633 dtype=STR_DTYPE_TO_TORCH_DTYPE[parts[4]],
634 request_configs=request_configs,
635 layer_id=int(parts[5]),
636 )
637
638
639@dataclass

Callers

nothing calls this directly

Calls 1

LayerCacheEngineKeyClass · 0.85

Tested by

no test coverage detected