Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix KV cache error in wildguard.py #2

Closed
wants to merge 1 commit into from
Closed
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 wildguard/wildguard.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,12 @@ def __init__(
if ephemeral_model:
self.model = None
else:
self.model = LLM(model=MODEL_NAME)
gpu_name = torch.cuda.get_device_name(0)
if gpu_name == 'NVIDIA GeForce RTX 3090':
Comment on lines +182 to +183
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
gpu_name = torch.cuda.get_device_name(0)
if gpu_name == 'NVIDIA GeForce RTX 3090':
if torch.cuda.get_device_properties(0).total_memory < 30e9:

And to make this work with ephemeral_model=True, you will also need to add a parameter for max_model_len to subprocess_inference_with_vllm and pass it through to create_and_inference_with_vllm.

self.model = LLM(model=MODEL_NAME,max_model_len=30448)
comfzy marked this conversation as resolved.
Show resolved Hide resolved
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
self.model = LLM(model=MODEL_NAME,max_model_len=30448)
self.model = LLM(model=MODEL_NAME, max_model_len=30448)

else:
self.model = LLM(model=MODEL_NAME)


@torch.inference_mode()
def _classify_batch(self, batch: list[dict[str, str]]) -> list[SafetyClassifierOutput]:
Expand Down