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

torchx/specs,schedulers: add TPU named resources + support in kubernetes_scheduler #473

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

d4l3k
Copy link
Member

@d4l3k d4l3k commented Apr 26, 2022

This adds in TPU support when launching jobs via the kubernetes_scheduler on GKE.

  • Volcano doesn't understand the Kubernetes device plugin so when launching we need to set minAvailable: 0 and schedulerName: default-scheduler which forces Volcano to create the pods without waiting for the resources to be available.
  • It also fixes a race condition in reporting Volcano status where it reports RUNNING before the pods have been created.
  • XLA and torchelastic don't play well together so it requires launching via utils.python.

Closes #410

Test plan:

added unit tests

# imports pytorch
import torch

# imports the torch_xla package
import torch_xla
import torch_xla.core.xla_model as xm

# Creates a random tensor on xla:1 (a Cloud TPU core)
dev = xm.xla_device()
t1 = torch.ones(3, 3, device = dev)
print(t1)

# Creating a tensor on the second Cloud TPU core
second_dev = xm.xla_device(n=2, devkind='TPU')
t2 = torch.zeros(3, 3, device = second_dev)
print(t2)

# Creates random filters and inputs to a 1D convolution
filters = torch.randn(33, 16, 3, device = dev)
inputs = torch.randn(20, 16, 50, device = dev)
t3 = torch.nn.functional.conv1d(inputs, filters)
print(t3)
(torchx) tristanr@tristanr-arch2 ~/D/torchx-proj [2]> torchx run --scheduler kubernetes --wait --log utils.python -h tpu_v3_8 --script tpu.py --image gcr.io/tpu-pytorch/xla:r1.11_3.7

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Apr 26, 2022
@codecov
Copy link

codecov bot commented Apr 26, 2022

Codecov Report

Merging #473 (66e934c) into main (c80650c) will decrease coverage by 0.03%.
The diff coverage is 91.83%.

@@            Coverage Diff             @@
##             main     #473      +/-   ##
==========================================
- Coverage   94.61%   94.57%   -0.04%     
==========================================
  Files          65       66       +1     
  Lines        3863     3911      +48     
==========================================
+ Hits         3655     3699      +44     
- Misses        208      212       +4     
Impacted Files Coverage Δ
torchx/specs/named_resources_aws.py 100.00% <ø> (ø)
torchx/schedulers/kubernetes_scheduler.py 92.76% <80.00%> (-0.57%) ⬇️
torchx/specs/named_resources_tpu.py 94.59% <94.59%> (ø)
torchx/specs/__init__.py 96.29% <100.00%> (+0.14%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update c80650c...66e934c. Read the comment docs.

@facebook-github-bot
Copy link
Contributor

Hi @d4l3k!

Thank you for your pull request.

We require contributors to sign our Contributor License Agreement, and yours needs attention.

You currently have a record in our system, but the CLA is no longer valid, and will need to be resubmitted.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at [email protected]. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add Google Cloud/GCP Scheduler Support + TPUs
2 participants