lmcache-cli 0.5.8rc3.dev0__py3-none-any.whl → 0.5.9.dev0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
lmcache/_version.py CHANGED
@@ -18,7 +18,7 @@ version_tuple: tuple[int | str, ...]
18
18
  commit_id: str | None
19
19
  __commit_id__: str | None
20
20
 
21
- __version__ = version = '0.5.8rc3.dev0'
22
- __version_tuple__ = version_tuple = (0, 5, 8, 'rc3', 'dev0')
21
+ __version__ = version = '0.5.9.dev0'
22
+ __version_tuple__ = version_tuple = (0, 5, 9, 'dev0')
23
23
 
24
- __commit_id__ = commit_id = 'g831e05028'
24
+ __commit_id__ = commit_id = 'g651617efc'
@@ -294,7 +294,7 @@ class LookupMixin:
294
294
  if stale_hashes:
295
295
  with self._pending_fp_lock:
296
296
  truly_evict: list[bytes] = []
297
- for h in stale_hashes:
297
+ for h in dict.fromkeys(stale_hashes):
298
298
  if h in self._pending_fp_hashes:
299
299
  continue
300
300
  n = self._stale_strike.get(h, 0) + 1
@@ -163,9 +163,9 @@ class BlendTokenRangeMatcher:
163
163
  full poly-hash verify that rejects bucket collisions. Thread-safe.
164
164
 
165
165
  Returns:
166
- One result per unique reused chunk (cur_st = first query
167
- position, old_st = stored position); empty if the query is
168
- shorter than one chunk or nothing matched.
166
+ One result per non-overlapping occurrence of each reused chunk
167
+ (old_st = stored position); empty if the query is shorter than
168
+ one chunk or nothing matched.
169
169
  """
170
170
  if len(token_ids) < self.chunk_size:
171
171
  return []
@@ -183,12 +183,12 @@ class BlendTokenRangeMatcher:
183
183
  cids_at_pos = self._table_id[rolling & self._mask]
184
184
  hit_positions = np.nonzero(cids_at_pos >= 0)[0]
185
185
 
186
- seen_cids: set[int] = set()
186
+ next_free: dict[int, int] = {} # cid -> end of its last match
187
187
  results: list[CBMatchResult] = []
188
188
  for pos in hit_positions:
189
189
  pos = int(pos)
190
190
  cid = int(cids_at_pos[pos])
191
- if cid in seen_cids:
191
+ if pos < next_free.get(cid, 0):
192
192
  continue
193
193
  if int(rolling[pos]) != self._chunk_poly_hash[cid]:
194
194
  continue # bucket-only collision
@@ -198,7 +198,7 @@ class BlendTokenRangeMatcher:
198
198
  old_st = self._token_hash_to_start.get(th)
199
199
  if old_st is None:
200
200
  continue
201
- seen_cids.add(cid)
201
+ next_free[cid] = pos + self.chunk_size
202
202
  results.append(
203
203
  CBMatchResult(
204
204
  old_st=old_st,
@@ -541,12 +541,13 @@ class RetrieveMixin:
541
541
  The number of object keys whose release was enqueued.
542
542
  """
543
543
  applied_ids = {id(r) for r in applied}
544
- release_keys = [
545
- all_obj_keys[i * n_read + g]
546
- for i, r in enumerate(cb_match_result)
547
- if id(r) in applied_ids
548
- for g in range(n_read)
549
- ]
544
+ # Repeated chunks share keys: release a key once, when every match
545
+ # reading it was applied.
546
+ done: dict[ObjectKey, bool] = {}
547
+ for i, r in enumerate(cb_match_result):
548
+ for k in all_obj_keys[i * n_read : (i + 1) * n_read]:
549
+ done[k] = done.get(k, True) and id(r) in applied_ids
550
+ release_keys = [k for k, ok in done.items() if ok]
550
551
  if release_keys:
551
552
  if l1_owners is None:
552
553
  submit_callback_to_stream(
@@ -895,8 +896,10 @@ class RetrieveMixin:
895
896
  # cb.scatter opens mid-try; track it so a failure closes the span.
896
897
  scatter_open = False
897
898
  try:
899
+ # Repeated chunks share keys: read each once, expand per match.
900
+ unique_keys = list(dict.fromkeys(all_obj_keys))
898
901
  with self._ctx.storage_manager.read_prefetched_results(
899
- all_obj_keys, l1_owners=l1_owners
902
+ unique_keys, l1_owners=l1_owners
900
903
  ) as memory_objs:
901
904
  _stage_ms["fetch"] = (time.perf_counter() - _stage_t) * 1000
902
905
  if memory_objs is None:
@@ -928,6 +931,8 @@ class RetrieveMixin:
928
931
  False,
929
932
  )
930
933
 
934
+ obj_of = dict(zip(unique_keys, memory_objs, strict=True))
935
+ memory_objs = [obj_of[k] for k in all_obj_keys]
931
936
  # Per-token scatter handles any cur_st. Each match owns n_read
932
937
  # consecutive memory objects (chunk-major).
933
938
  if len(memory_objs) != len(cb_match_result) * n_read:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: lmcache-cli
3
- Version: 0.5.8rc3.dev0
3
+ Version: 0.5.9.dev0
4
4
  Summary: A LLM serving engine extension to reduce TTFT and increase throughput, especially under long-context scenarios.
5
5
  Author-email: LMCache Team <lmcacheteam@gmail.com>
6
6
  License-Expression: Apache-2.0
@@ -1,5 +1,5 @@
1
1
  lmcache/__init__.py,sha256=OBuoAiWmEQobnW2d2BGOEFso4RvwxPr-t1aVRN1JXeo,862
2
- lmcache/_version.py,sha256=7IzkNTdzLAs5qrKaTZzLPYiftGgNXlWuwsvPzq_20eM,551
2
+ lmcache/_version.py,sha256=neK5wGwr3lhyH8l8GZHibPnrTCo5MwZc1y2wR6C0E2s,541
3
3
  lmcache/banner.py,sha256=w4LOBKdDDBYF0pdLHFSP1ioUbnkwGGRxTMzBOIaMKiM,4143
4
4
  lmcache/connections.py,sha256=5bSguAPmkJCRpgjkZd0ugGna6Zfm0pXG9vo-RGVXeFg,4965
5
5
  lmcache/lmcache_native.pyi,sha256=T6szN6PjlDZbDwDEE06z6PRudhrsVArs16vh3dJTw4c,14737
@@ -593,13 +593,13 @@ lmcache/v1/multiprocess/modules/p2p_controller.py,sha256=Q7en1xCX77MqiOuF4OfuRMc
593
593
  lmcache/v1/multiprocess/modules/server_transfer.py,sha256=gHukoGuQjcie5hLAXavVuriX04FP83LWw9e0jDKLmvQ,28007
594
594
  lmcache/v1/multiprocess/modules/blend/__init__.py,sha256=k1qkKYd-SXteGFBHmjKJXvuSp3w_RMHvS4lDfZQsGU4,1614
595
595
  lmcache/v1/multiprocess/modules/blend/fingerprint_eviction.py,sha256=_P0K2BFsfDPWR779zOwtNNIXT4kwLzVKPlenxJy5N6s,7670
596
- lmcache/v1/multiprocess/modules/blend/lookup.py,sha256=RPthQxZqRdMWuKqcZtxzFmHGaWNw3bUoRbo7KMEew5M,36348
597
- lmcache/v1/multiprocess/modules/blend/matcher.py,sha256=0JhaaI_RQkkoROvCqgV_7Cza0HdJ__O4HMA9hMPQTfg,11561
596
+ lmcache/v1/multiprocess/modules/blend/lookup.py,sha256=-5R-1oN8CNWOW0fIEwNN9YXC3gTtSUytvfAidL4wpsM,36363
597
+ lmcache/v1/multiprocess/modules/blend/matcher.py,sha256=UH4cjGqjfyX7VtHGgiACKVzGXuZJcVveCX9ksaWllyE,11624
598
598
  lmcache/v1/multiprocess/modules/blend/module.py,sha256=iyPz56-WFbkk8X0KcyPQqsxJBgFpzTWwMM42r3dc3iQ,14556
599
599
  lmcache/v1/multiprocess/modules/blend/read_set.py,sha256=NXkeIRNxjR1iGU_yF57bRk1bgeVRcBC2ZddkCIveVsA,4149
600
600
  lmcache/v1/multiprocess/modules/blend/registration.py,sha256=pB0PCb3ON3sI2sB3SUntOcrNELyxppXsH6nMtVGD5IU,9729
601
601
  lmcache/v1/multiprocess/modules/blend/reorder.py,sha256=MDIo_i4gwHx9owajlL1gSjDC94X56yrZFDXZ5h_AK6I,12668
602
- lmcache/v1/multiprocess/modules/blend/retrieve.py,sha256=dILnKxSgfmhe0kejkC01wqH_Om8yyrZHaUjnOgOyK1k,49325
602
+ lmcache/v1/multiprocess/modules/blend/retrieve.py,sha256=KHFs0gQDbTb2xSiRaQXcogkMszEHbKv5odVqlG6qp4o,49808
603
603
  lmcache/v1/multiprocess/modules/blend/rope.py,sha256=qWJuQB0OgdCz_juZwMrxUB4kGV7FnvTPhmPSVNpX7fA,8217
604
604
  lmcache/v1/multiprocess/modules/blend/store.py,sha256=zka5s2kkrjGac1K0cjIQr-nRgrIylut4sWLphLoDGNo,11063
605
605
  lmcache/v1/multiprocess/object_group_transfer/__init__.py,sha256=lQ4WyQ94AvzBDMWkaOM7tDnoHcnO21RfJlq02weRzXM,1362
@@ -753,9 +753,9 @@ lmcache/v1/utils/frozen_dict.py,sha256=AqViVKvXjcTFmY3D3JfPC-I9WfKyDDUqpihUH9Biu
753
753
  lmcache/v1/utils/json_utils.py,sha256=WFrdauddZP8xuOqKqkhFlYyt3cNH-krNtVCRe4jIxeY,1724
754
754
  lmcache/v1/utils/router_discovery.py,sha256=yZR3oTovQesNQzfa6EboyYPj798WVvUxZRJ6l4L-9bk,1867
755
755
  lmcache/v1/utils/subclass_discovery.py,sha256=U9tlPTSlSB37_GqAmc6TzogoDDh5XydlOekjvVvaM80,10292
756
- lmcache_cli-0.5.8rc3.dev0.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
757
- lmcache_cli-0.5.8rc3.dev0.dist-info/METADATA,sha256=E_wrXVjmWhWomRvpslewf37cZx1cQs_rfICRbWv72g0,12466
758
- lmcache_cli-0.5.8rc3.dev0.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
759
- lmcache_cli-0.5.8rc3.dev0.dist-info/entry_points.txt,sha256=Axef26i3pyPHL-zuNZWCubmM74zLa9tQnoMU1JrAZUg,50
760
- lmcache_cli-0.5.8rc3.dev0.dist-info/top_level.txt,sha256=7KnuVYNl7HkrnKK3wAN5qJJQSOcCv-l0TW4bzvH_SaU,8
761
- lmcache_cli-0.5.8rc3.dev0.dist-info/RECORD,,
756
+ lmcache_cli-0.5.9.dev0.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
757
+ lmcache_cli-0.5.9.dev0.dist-info/METADATA,sha256=6rsZOnmfvWKS-dJl0PBpkXOGwLyPUMHL-cUXVObFdWs,12463
758
+ lmcache_cli-0.5.9.dev0.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
759
+ lmcache_cli-0.5.9.dev0.dist-info/entry_points.txt,sha256=Axef26i3pyPHL-zuNZWCubmM74zLa9tQnoMU1JrAZUg,50
760
+ lmcache_cli-0.5.9.dev0.dist-info/top_level.txt,sha256=7KnuVYNl7HkrnKK3wAN5qJJQSOcCv-l0TW4bzvH_SaU,8
761
+ lmcache_cli-0.5.9.dev0.dist-info/RECORD,,