Skip to content

Conversation

shink
Copy link
Contributor

@shink shink commented Oct 28, 2024

I noticed that some hard-code like "cuda" if torch.cuda.is_available() else "cpu" which can be replaced with torch._C._get_accelerator()

cc: @albanD @guangyey @FFFrog @zeshengzong @noemotiovon

cc @H-Huang @awgu @kwen2501 @wanchaol @fegin @fduwjj @wz337 @wconstab @d4l3k @c-p-i-o

Copy link

pytorch-bot bot commented Oct 28, 2024

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/139032

Note: Links to docs will display an error until the docs builds have been completed.

✅ No Failures

As of commit 20e708d with merge base 07b0d63 (image):
💚 Looks good so far! There are no failures yet. 💚

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@pytorch-bot pytorch-bot bot added oncall: distributed Add this issue/PR to distributed oncall triage queue release notes: distributed (fsdp) release notes category labels Oct 28, 2024
@shink shink changed the title [Device] Replace 'cuda' with 'torch._C._get_accelerator()' [Device] Replace hardcoded devices with 'torch._C._get_accelerator()' Oct 28, 2024
@shink shink marked this pull request as draft October 28, 2024 02:57
@shink shink marked this pull request as ready for review October 28, 2024 06:35
@shink
Copy link
Contributor Author

shink commented Oct 28, 2024

@pytorchbot rebase -b main

@pytorchmergebot
Copy link
Collaborator

@pytorchbot started a rebase job onto refs/remotes/origin/main. Check the current status here

@pytorchmergebot
Copy link
Collaborator

Successfully rebased fix/device/cuda onto refs/remotes/origin/main, please pull locally before adding more changes (for example, via git checkout fix/device/cuda && git pull --rebase)

Comment on lines +61 to +62
device = torch._C._get_accelerator()
mesh = init_device_mesh(device.type, mesh_shape=(default_pg.size(),))
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
device = torch._C._get_accelerator()
mesh = init_device_mesh(device.type, mesh_shape=(default_pg.size(),))
device = torch.accelerator.current_accelerator() if torch.accelerator.is_available() else torch.device("cpu")
mesh = init_device_mesh(device.type, mesh_shape=(default_pg.size(),))

I think torch._C._get_accelerator will be removed in future, refer to #137493.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes I see, will make change after your PR merged

@ezyang
Copy link
Contributor

ezyang commented Oct 28, 2024

@pytorchbot merge

@pytorch-bot pytorch-bot bot added the ciflow/trunk Trigger trunk jobs on your pull request label Oct 28, 2024
@ezyang ezyang added triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module and removed ciflow/trunk Trigger trunk jobs on your pull request labels Oct 28, 2024
@pytorchmergebot
Copy link
Collaborator

Merge started

Your change will be merged once all checks pass (ETA 0-4 Hours).

Learn more about merging in the wiki.

Questions? Feedback? Please reach out to the PyTorch DevX Team

Advanced Debugging
Check the merge workflow status
here

@pytorchmergebot
Copy link
Collaborator

Merge failed

Reason: 1 mandatory check(s) failed. The first few are:

Dig deeper by viewing the failures on hud

Details for Dev Infra team Raised by workflow job

Failing merge rule: Core Maintainers

@shink
Copy link
Contributor Author

shink commented Oct 29, 2024

@pytorchbot rebase -b main

@pytorchmergebot
Copy link
Collaborator

@pytorchbot started a rebase job onto refs/remotes/origin/main. Check the current status here

@pytorchmergebot
Copy link
Collaborator

Successfully rebased fix/device/cuda onto refs/remotes/origin/main, please pull locally before adding more changes (for example, via git checkout fix/device/cuda && git pull --rebase)

@ezyang
Copy link
Contributor

ezyang commented Oct 29, 2024

@pytorchbot merge

@pytorch-bot pytorch-bot bot added the ciflow/trunk Trigger trunk jobs on your pull request label Oct 29, 2024
@pytorchmergebot
Copy link
Collaborator

Merge started

Your change will be merged once all checks pass (ETA 0-4 Hours).

Learn more about merging in the wiki.

Questions? Feedback? Please reach out to the PyTorch DevX Team

Advanced Debugging
Check the merge workflow status
here

rahulsingh-intel pushed a commit to rahulsingh-intel/pytorch that referenced this pull request Oct 29, 2024
…pytorch#139032)

I noticed that some hard-code like `"cuda" if torch.cuda.is_available() else "cpu"` which can be replaced with `torch._C._get_accelerator()`

Pull Request resolved: pytorch#139032
Approved by: https://github.com/ezyang
rahulsingh-intel pushed a commit to rahulsingh-intel/pytorch that referenced this pull request Nov 5, 2024
…pytorch#139032)

I noticed that some hard-code like `"cuda" if torch.cuda.is_available() else "cpu"` which can be replaced with `torch._C._get_accelerator()`

Pull Request resolved: pytorch#139032
Approved by: https://github.com/ezyang
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ciflow/trunk Trigger trunk jobs on your pull request Merged oncall: distributed Add this issue/PR to distributed oncall triage queue open source release notes: distributed (fsdp) release notes category triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants