pytorch / pytorch/tutorials

cpp extension tutorial: not device agnostic?

Open
#431 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

C++
Dominant language
Python
Stars
9.3k
Forks
4.4k
Avg merge
1d 21h
Merged PRs (30d)
4

Description

Would the kerne calll in lltm_cuda_forward in the tutorial tutorials/advanced_source/cpp_extension.rst fail on multi gpu systems if the inputs are not on the default device, i.e., device:0?

To my understanding, some "magic" takes care of setting the right context if we add functionality do pytorch via custom kernels, see here.
However, it seems like in the tutorial this machinery is not used.
Explicit usage of at::OptionalDeviceGuard should resolve the issue (?) in the tutorial.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in tutorials/advanced_source/cpp_extension.rst at the lltm_cuda_forward kernel call and review how the tutorial handles device selection. Reproduce or inspect the behavior with inputs on a non-default GPU, then confirm whether the tutorial needs a device-context change and update its documented example accordingly.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
documentation
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
40/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.