Skip to content
Open
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
3 changes: 3 additions & 0 deletions examples/others/lmcache/cpu_offload_lmcache.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,9 @@ def main():
print_output(llm, first_prompt, sampling_params, "first")

time.sleep(1)
# Clear vLLM's internal prefix cache to force the second request
# to fetch cached KVs from LMCache
llm.reset_prefix_cache()
Copy link
Contributor

Choose a reason for hiding this comment

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

high

The reset_prefix_cache method can fail if there are still blocks in use, and it returns a boolean indicating success or failure. The example should check this return value and raise an error if it's False. This will make the example more robust and prevent confusion if the cache reset fails, which would cause the example to not demonstrate the intended LMCache loading behavior.

Suggested change
llm.reset_prefix_cache()
if not llm.reset_prefix_cache():
raise RuntimeError(
"Failed to reset prefix cache. The example may not run as expected."
)


# print the second output
print_output(llm, second_prompt, sampling_params, "second")
Expand Down