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

CPU and GPU device returns different result #1695

Open
william-trustlab opened this issue Sep 13, 2022 · 3 comments
Open

CPU and GPU device returns different result #1695

william-trustlab opened this issue Sep 13, 2022 · 3 comments

Comments

@william-trustlab
Copy link

When I encode text with device = "cpu", I get slightly different results from device="gpu".

from sentence_transformers import SentenceTransformer
model = SentenceTransformer("all-mpnet-base-v2")
cpu_embs = model.encode("this is a test", device="cpu")
gpu_embs = model.encode("this is a test", device="cuda:0")
cpu_embs.eq(gpu_embs) == False

From investigation, this is a result of floating point arithmetic errors (the diffs are on the order of 1e-6). Is this an issue with sentence-transformers, or with the underlying pytorch?

@nreimers
Copy link
Member

It is normal, you can ignore it

@william-trustlab
Copy link
Author

Would it be possible to add this to the documentation? It isn't clear that this is an effect.

FWIW, this does have a quality impact for modeling that uses these features.

@poornaprudhvigu-kore
Copy link

Ideally this minor floating point changes wouldn't impact the accuracy.

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

No branches or pull requests

3 participants