Skip to content
New issue

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

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

Already on GitHub? # to your account

Raise error if overloaded operator applied to tensors on different devices #269

Open
jwallwork23 opened this issue Jan 30, 2025 · 0 comments · May be fixed by #272
Open

Raise error if overloaded operator applied to tensors on different devices #269

jwallwork23 opened this issue Jan 30, 2025 · 0 comments · May be fixed by #272
Assignees
Labels
bug Something isn't working gpu Related to buiding and running on GPU

Comments

@jwallwork23
Copy link
Contributor

          > Now that you explicitly set the device to create the tensor in some overloads I have a question. What happens if we call this with tensors that are on different devices? I presume it fails with a meaningful error message from the C++, but does it provide a useful traceback to where the error originated in the Fortran? I recall sometimes libtorch gives an error report, but no code location making it hard to work out where your Fortran is going wrong.

Making the modifications in the last commit on 248_get-dtype-devicetype_GPU-test - which attempts to assign a tensor on a CUDA device to a tensor on the CPU - I get the output

4: Test command: /home/joewa/software/FTorch/src/build/test/examples/3_MultiGPU/multigpu_infer_fortran "/home/joewa/software/FTorch/src/build/test/examples/3_MultiGPU/saved_multigpu_model_cuda.pt"
4: Working Directory: /home/joewa/software/FTorch/src/build/test/examples/3_MultiGPU
4: Test timeout computed to be: 1500
4: input on rank 0: [  0.0,  1.0,  2.0,  3.0,  4.0]
4: output on rank 0: [*****,  0.0,  0.0,  0.0,*****]
4:  MultiGPU example ran successfully
4/4 Test #4: multigpu_infer_fortran ...........   Passed    8.12 sec

That is, it doesn't raise an error at all. So I guess we should build in errors for when you try to apply operator overloads to tensors on different devices.

Originally posted by @jwallwork23 in #251 (comment)

@jwallwork23 jwallwork23 self-assigned this Jan 30, 2025
@jwallwork23 jwallwork23 added bug Something isn't working gpu Related to buiding and running on GPU labels Jan 30, 2025
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
bug Something isn't working gpu Related to buiding and running on GPU
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant