Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion vllm/models/kimi_k3/nvidia/dspark_mla.py
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,12 @@ def _has_uniform_block_layout(
self,
cache_layers: list[MultiHeadLatentAttention],
) -> bool:
if not hasattr(self, "_layers_share_kv_block_layout"):
key = tuple(cl.kv_cache.data_ptr() for cl in cache_layers)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we just invalidate both caches here when the kv_cache.data_ptr() tuple changes? Since the profiling graphs are discarded and the runtime graphs are recaptured after the real KV cache is bound, it seems like we don't need the in-place copy_() here. Then _get_context_kv_cache_ptrs() can stay unchanged.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good point. I've updated the code.

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
self._layers_share_kv_block_layout = all(
cl.kv_cache.size(1) == ref_cache.size(1)
Expand Down
Loading