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

set hostNetwork to True for TPUGKEJob #641

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
set hostNetwork to True for TPUGKEJob
  • Loading branch information
samos123 committed Aug 8, 2024
commit f89b67b2b9ad3de26fd35f5808f5ef8e4553f362
37 changes: 22 additions & 15 deletions axlearn/cloud/gcp/job.py
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,7 @@ def _build_pod(self) -> Nested[Any]:
annotations, selector, volumes, tolerations = {}, {}, [], []

if cfg.gcsfuse_mount:
# GCS Fuse does not work with hostNetwork True.
# Mount a GCS bucket as a volume.
annotations.update(
{
Expand Down Expand Up @@ -563,23 +564,29 @@ def _build_pod(self) -> Nested[Any]:
}
)

pod_spec = dict(
# NOTE: Don't set hostNetwork or dnsPolicy for compat with Workload Identity.
terminationGracePeriodSeconds=60,
# Fail if any pod fails, and allow retries to happen at JobSet level.
restartPolicy="Never",
nodeSelector={
"cloud.google.com/gke-tpu-accelerator": system.gke_accelerator,
"cloud.google.com/gke-tpu-topology": system.topology,
**selector,
},
tolerations=tolerations,
containers=[self._build_container()],
serviceAccountName=cfg.service_account,
volumes=volumes,
)

if not cfg.gcsfuse_mount:
pod_spec["hostNetwork"] = True
pod_spec["dnsPolicy"] = "ClusterFirstWithHostNet"

return dict(
metadata=dict(annotations=annotations),
spec=dict(
# NOTE: Don't set hostNetwork or dnsPolicy for compat with Workload Identity.
terminationGracePeriodSeconds=60,
# Fail if any pod fails, and allow retries to happen at JobSet level.
restartPolicy="Never",
nodeSelector={
"cloud.google.com/gke-tpu-accelerator": system.gke_accelerator,
"cloud.google.com/gke-tpu-topology": system.topology,
**selector,
},
tolerations=tolerations,
containers=[self._build_container()],
serviceAccountName=cfg.service_account,
volumes=volumes,
),
spec=pod_spec,
)

def _build_job(self) -> Nested[Any]:
Expand Down