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

Changes to make this compatible with running purely on a GPU #56

Closed
wants to merge 5 commits into from

Conversation

rishsriv
Copy link
Member

@rishsriv rishsriv commented Dec 8, 2023

Not for merging just yet

@rishsriv rishsriv marked this pull request as ready for review December 22, 2023 06:38
Copy link
Collaborator

Choose a reason for hiding this comment

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

Checking if this an improved version of prompt.md? If so, shall we just replace the existing prompt.md with this?

@@ -10,7 +10,7 @@
if os.getenv("TOKENIZERS_PARALLELISM") is None:
os.environ["TOKENIZERS_PARALLELISM"] = "false"

encoder = SentenceTransformer("sentence-transformers/all-MiniLM-L6-v2", device="cpu")
encoder = SentenceTransformer("sentence-transformers/all-MiniLM-L6-v2")
Copy link
Collaborator

Choose a reason for hiding this comment

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

I was thinking of having a variable at the top of pruning.py called user_device, and then passing it to everywhere torch device is required. We can just check and set it once instead of checking/setting every place we create a tensor.

# at the top
user_device = "cuda" if torch.cuda.is_available() else "cpu"
encoder = SentenceTransformer("sentence-transformers/all-MiniLM-L6-v2", device=user_device)
...
query_emb = encoder.encode(query, convert_to_tensor=True, device=user_device)
...
column_emb = column_emb.to(user_device)

The other benefit is that we can easily override user_device in tests to run only on cpu. wdyt?

@rishsriv rishsriv closed this Dec 26, 2023
@rishsriv rishsriv deleted the rishabh/gpu branch February 3, 2024 12:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants