[Bugfix][Kimi-K3] Refresh DSpark context KV cache pointers after the KV cache is re-bound (#58814)
Signed-off-by: Oxana Korzh <okorzh@amd.com> Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
b0d2b854f6
commit
94d1462924
@@ -376,7 +376,12 @@ class K3DSparkModel(nn.Module):
|
|||||||
self,
|
self,
|
||||||
cache_layers: list[MultiHeadLatentAttention],
|
cache_layers: list[MultiHeadLatentAttention],
|
||||||
) -> bool:
|
) -> bool:
|
||||||
if not hasattr(self, "_layers_share_kv_block_layout"):
|
key = tuple(cl.kv_cache.data_ptr() for cl in cache_layers)
|
||||||
|
if getattr(self, "_kv_cache_ptrs_key", None) != key:
|
||||||
|
assert not torch.cuda.is_current_stream_capturing()
|
||||||
|
self._kv_cache_ptrs_key = key
|
||||||
|
if hasattr(self, "_context_cache_ptrs"):
|
||||||
|
del self._context_cache_ptrs
|
||||||
ref_cache = cache_layers[0].kv_cache
|
ref_cache = cache_layers[0].kv_cache
|
||||||
self._layers_share_kv_block_layout = all(
|
self._layers_share_kv_block_layout = all(
|
||||||
cl.kv_cache.size(1) == ref_cache.size(1)
|
cl.kv_cache.size(1) == ref_cache.size(1)
|
||||||
|
|||||||
Reference in New Issue
Block a user