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

allow using on-demand instead of spot only #622

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
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
13 changes: 11 additions & 2 deletions axlearn/cloud/gcp/job.py
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,7 @@ class Config(GKEJob.Config):

accelerator: AcceleratorConfig = AcceleratorConfig()
reservation: Optional[str] = None
enable_ondemand: Optional[bool] = None
enable_tpu_ici_resiliency: Optional[bool] = None
location_hint: Optional[str] = None

Expand All @@ -387,6 +388,13 @@ def define_flags(cls, fv: flags.FlagValues):
"not all TPU types support this flag.",
**common_kwargs,
)
flags.DEFINE_boolean(
"enable_ondemand",
None,
"Allow the job to run using on-demand quota when no reservation is provided. "
"Without this flag a job can only land on spot quota.",
**common_kwargs,
)

@classmethod
def from_flags(cls, fv: flags.FlagValues, **kwargs) -> Config:
Expand Down Expand Up @@ -508,8 +516,9 @@ def _build_pod(self) -> Nested[Any]:
logging.info("Found tier=%s in env. Using reservation=%s", tier, cfg.reservation)
selector.update({"cloud.google.com/reservation-name": cfg.reservation})
else:
Copy link
Contributor

Choose a reason for hiding this comment

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

What about using tier == "1" for spot and tier == "2" for on-demand? You can configure the quota file s.t. there's only on-demand quota like

[[total_resources]]
v5litepod = 0

[[total_resources]]
v5litepod = 0

[[total_resources]]
v5litepod = X

...

Which corresponds to 0 quota for tier 0/1 and X quota on tier 2. More generally we can also make the logic for tier -> selector mapping configurable, for more flexible schemes. WDYT?

logging.info("Found tier=%s in env. Using spot quota", tier)
selector.update({"cloud.google.com/gke-spot": "true"})
if not cfg.enable_ondemand:
logging.info("Found tier=%s in env. Using spot quota", tier)
selector.update({"cloud.google.com/gke-spot": "true"})
Comment on lines +519 to +521
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a unittest that can be updated?

tolerations.append(
{
"key": "cloud.google.com/gke-spot",
Expand Down