Skip to content

Commit 098815f

Browse files
committed
Make @kubernetes inferentia-trainium alias resolution idempotent
1 parent 485be03 commit 098815f

1 file changed

Lines changed: 5 additions & 6 deletions

File tree

metaflow/plugins/kubernetes/kubernetes_decorator.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -403,18 +403,17 @@ def step_init(self, flow, graph, step, decos, environment, flow_datastore, logge
403403
# `trainium` is canonical on @kubernetes (the underlying Neuron device
404404
# plugin advertises a single `aws.amazon.com/neuron` resource for both
405405
# chip families). `inferentia` is provided for API consistency with
406-
# `@batch(inferentia=...)` -- it collapses into `trainium` and is
407-
# popped from the wire format before any runtime translation.
406+
# `@batch(inferentia=...)` -- it collapses into `trainium` here.
408407
if (
409-
self.attributes["inferentia"] is not None
410-
and self.attributes["trainium"] is not None
408+
self.attributes.get("inferentia") is not None
409+
and self.attributes.get("trainium") is not None
411410
):
412411
raise KubernetesException(
413412
"only specify a value for 'inferentia' or 'trainium', not both."
414413
)
415-
if self.attributes["inferentia"] is not None:
414+
if self.attributes.get("inferentia") is not None:
416415
self.attributes["trainium"] = self.attributes["inferentia"]
417-
self.attributes.pop("inferentia", None)
416+
self.attributes["inferentia"] = None
418417

419418
# Validate mutually exclusive: gpu and trainium cannot both be set.
420419
if (

0 commit comments

Comments
 (0)