Skip to content
Open
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions turboquant/integration/vllm.py
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,7 @@ def free_kv_cache(model_runner) -> int:
continue
attn_module = static_ctx[layer_name]
kv_list = getattr(attn_module, "kv_cache", None)
if kv_list and len(kv_list) > 0:
if kv_list is not None and len(kv_list) > 0:
ptrs_to_free.add(kv_list[0].data_ptr())

for layer_name, state in layer_states.items():
Expand All @@ -482,7 +482,7 @@ def free_kv_cache(model_runner) -> int:
continue
attn_module = static_ctx[layer_name]
kv_list = getattr(attn_module, "kv_cache", None)
if kv_list and len(kv_list) > 0:
if kv_list is not None and len(kv_list) > 0:
old = kv_list[0]
freed += old.nelement() * old.element_size()
kv_list[0] = tiny
Expand Down
4 changes: 2 additions & 2 deletions turboquant/vllm_attn_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ def free_kv_cache(model_runner):
if attn_module is None:
continue
kv_list = getattr(attn_module, "kv_cache", None)
if kv_list and len(kv_list) > 0 and hasattr(kv_list[0], "data_ptr"):
if kv_list is not None and len(kv_list) > 0 and hasattr(kv_list[0], "data_ptr"):
ptrs_to_free.add(kv_list[0].data_ptr())

for layer_name, state in layer_states.items():
Expand All @@ -246,7 +246,7 @@ def free_kv_cache(model_runner):
if attn_module is None:
continue
kv_list = getattr(attn_module, "kv_cache", None)
if kv_list and len(kv_list) > 0:
if kv_list is not None and len(kv_list) > 0:
old = kv_list[0]
freed += old.nelement() * old.element_size()
kv_list[0] = tiny
Expand Down