@@ -93,8 +93,6 @@ def __init__(
9393 tpu_type : str ,
9494 topology : str ,
9595 num_slices : int ,
96- user_pod_template : Mapping [str , Any ] | None = None ,
97- main_container_name : str = "main" ,
9896 max_restarts : int = 0 ,
9997 max_slice_restarts : int = 0 ,
10098 termination_grace_period_seconds : int | None = None ,
@@ -114,8 +112,6 @@ def __init__(
114112 tpu_type: TPU type (e.g., "v5e").
115113 topology: TPU topology (e.g., "2x2").
116114 num_slices: Number of slices.
117- user_pod_template: Optional user pod template for the head job.
118- main_container_name: Name of the main container in user_pod_template.
119115 max_restarts: Maximum number of restarts for the JobSet.
120116 max_slice_restarts: Maximum number of slice restarts.
121117 termination_grace_period_seconds: Optional termination grace period.
@@ -124,12 +120,8 @@ def __init__(
124120 elastic_slices: Number of elastic slices.
125121 labels: Optional labels for the JobSet.
126122 annotations: Optional annotations for the JobSet.
123+ shared_pathways_service: Whether to run only RM for Shared Pathways Service.
127124 """
128- if shared_pathways_service and user_pod_template :
129- raise ValueError (
130- "Cannot enable shared_pathways_service when user_pod_template is"
131- " provided."
132- )
133125 self ._shared_pathways_service = shared_pathways_service
134126
135127 self ._name = name
@@ -166,8 +158,6 @@ def __init__(
166158 num_slices = num_slices ,
167159 instance_type = instance_type ,
168160 image_tag = image_tag ,
169- user_pod_template = user_pod_template ,
170- main_container_name = main_container_name ,
171161 elastic_slices = elastic_slices ,
172162 shared_pathways_service = shared_pathways_service ,
173163 )
@@ -185,7 +175,7 @@ def __init__(
185175 )
186176
187177 self ._success_policy = None
188- if user_pod_template or shared_pathways_service :
178+ if shared_pathways_service :
189179 self ._success_policy = {
190180 "operator" : "All" ,
191181 "targetReplicatedJobs" : [PATHWAYS_HEAD_JOB_NAME ],
@@ -205,8 +195,6 @@ def _build_head_job_template(
205195 num_slices : int ,
206196 instance_type : str ,
207197 image_tag : str ,
208- user_pod_template : Mapping [str , Any ] | None ,
209- main_container_name : str ,
210198 elastic_slices : int ,
211199 shared_pathways_service : bool ,
212200 ) -> client .V1JobTemplateSpec :
@@ -217,9 +205,8 @@ def _build_head_job_template(
217205 num_slices: Number of slices.
218206 instance_type: TPU instance type (e.g., "tpuv5:2x2").
219207 image_tag: Version tag for Pathways images.
220- user_pod_template: Optional user pod template for the head job.
221- main_container_name: Name of the main container in user_pod_template.
222208 elastic_slices: Number of elastic slices.
209+ shared_pathways_service: Whether to run only RM for Shared Pathways Service.
223210
224211 Returns:
225212 The head job template.
@@ -318,74 +305,20 @@ def _build_head_job_template(
318305 ),
319306 )
320307
321- api_client = client .ApiClient ()
322-
323- if user_pod_template :
324- user_template_obj = _deserialize_dict (
325- api_client , user_pod_template , client .V1PodTemplateSpec
326- )
327- head_pod_spec = user_template_obj .spec
328- head_pod_spec .host_network = True
329- head_pod_spec .dns_policy = "ClusterFirstWithHostNet"
330-
331- rm_container .restart_policy = "Always" # pyrefly: ignore[missing-attribute]
332- proxy_container .restart_policy = "Always" # pyrefly: ignore[missing-attribute]
333-
334- init_containers = head_pod_spec .init_containers or []
335- init_containers .extend ([rm_container , proxy_container ])
336- head_pod_spec .init_containers = init_containers
337-
338- # Inject JAX env vars into main container.
339- jax_env = [
340- client .V1EnvVar (
341- name = "PATHWAYS_HEAD" ,
342- value_from = client .V1EnvVarSource (
343- field_ref = client .V1ObjectFieldSelector (
344- field_path = (
345- "metadata.labels['jobset.sigs.k8s.io/coordinator']"
346- )
347- )
348- ),
349- ),
350- client .V1EnvVar (name = "JAX_PLATFORMS" , value = "proxy" ),
351- client .V1EnvVar (name = "XCLOUD_ENVIRONMENT" , value = "GCP" ),
352- client .V1EnvVar (
353- name = "JAX_BACKEND_TARGET" ,
354- value = f"grpc://$(PATHWAYS_HEAD):{ PATHWAYS_PROXY_PORT } " ,
355- ),
356- ]
357- containers = head_pod_spec .containers or []
358- for c in containers :
359- if c .name == main_container_name :
360- env = c .env or []
361- env .extend (jax_env )
362- c .env = env
363- break
364- head_pod_spec .containers = containers
365-
366- annotations = user_pod_template .get ("metadata" , {}).get ("annotations" , {})
367- labels = user_pod_template .get ("metadata" , {}).get ("labels" , {})
368- else :
369- # Headless mode.
370- containers = [rm_container ]
371- if not shared_pathways_service :
372- containers .append (proxy_container )
373- head_pod_spec = client .V1PodSpec (
374- host_network = True ,
375- dns_policy = "ClusterFirstWithHostNet" ,
376- containers = containers ,
377- )
378- annotations = {}
379- labels = {}
308+ containers = [rm_container ]
309+ if not shared_pathways_service :
310+ containers .append (proxy_container )
380311
381- if not head_pod_spec .restart_policy :
382- head_pod_spec .restart_policy = "Never"
312+ head_pod_spec = client .V1PodSpec (
313+ host_network = True ,
314+ dns_policy = "ClusterFirstWithHostNet" ,
315+ containers = containers ,
316+ restart_policy = "Never" ,
317+ )
383318
384- # Default annotations
385319 job_annotations = {
386320 "alpha.jobset.sigs.k8s.io/exclusive-topology" : "kubernetes.io/hostname"
387321 }
388- job_annotations .update (annotations )
389322
390323 head_job_template = client .V1JobTemplateSpec (
391324 metadata = client .V1ObjectMeta (annotations = job_annotations ),
@@ -396,7 +329,7 @@ def _build_head_job_template(
396329 parallelism = 1 ,
397330 template = client .V1PodTemplateSpec (
398331 metadata = client .V1ObjectMeta (
399- annotations = job_annotations , labels = labels
332+ annotations = job_annotations , labels = {}
400333 ),
401334 spec = head_pod_spec ,
402335 ),
0 commit comments