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

Wrong results when running inference with pytorch and MPS backend #5442

Open
tonytorm opened this issue Feb 22, 2024 · 1 comment
Open

Wrong results when running inference with pytorch and MPS backend #5442

tonytorm opened this issue Feb 22, 2024 · 1 comment

Comments

@tonytorm
Copy link

tonytorm commented Feb 22, 2024

just writing little code as the issue is very easy to recreate

device_gpu = torch.device("mps")
model = bundle.get_model(with_star=False).to(device_gpu, non_blocking=False)
with torch.inference_mode():
emission, _ = model(waveform.to(device_gpu))

this produces completely wrong emissions, the same code provides very precise results if ran on the cpu device (at more and less half the speed unfortunately)

I am gonna report the same issue on the pytorch github as I'm not capable of understanding where the the actual problem is located, loading the model to cpu or gpu provides same result (in terms of the model object data) but the inferences return 2 substantially different results.

@tonytorm
Copy link
Author

Hey, I got news, the issue is within the components.py auxiliary script of the wav2vec2 model, specifically in the forward function, I'll link you to a similar issue that was raised in the pytorch git which led to a workaround too.

pytorch/pytorch#98212

the problem appears to be related to non-contiguous tensors

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant