Skip to content

Commit 307db26

Browse files
guptaakacopybara-github
authored andcommitted
Set max_slice_restarts to 1000000 in Shared Pathways Service deployment
This change configures the max_slice_restarts parameter to 1000000 when deploying the shared Pathways service. Using a very high backOffLimit for the worker pods keeps the jobset from failing on multiple client reconnections. FUTURE_COPYBARA_INTEGRATE_REVIEW=#288 from AI-Hypercomputer:add-gke-test-extras-dependencies 672c861 PiperOrigin-RevId: 952331464
1 parent 1089127 commit 307db26

3 files changed

Lines changed: 58 additions & 6 deletions

File tree

pathwaysutils/experimental/shared_pathways_service/deploy_pathways_service.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
import dataclasses
55
import logging
66
import math
7-
import os
87
from typing import Any
98
from absl import app
109
from absl import flags
@@ -142,7 +141,6 @@ def calculate_vms_per_slice(topology: str, chips_per_vm: int) -> int:
142141
) from e
143142

144143

145-
146144
def deploy_jobset(jobset_yaml: dict[str, Any]) -> None:
147145
"""Deploys the JobSet to the current Kubernetes cluster."""
148146
try:
@@ -185,6 +183,9 @@ def run_deployment(
185183
topology=topology,
186184
num_slices=num_slices,
187185
shared_pathways_service=True,
186+
# TODO(b/496958026): Remove this once go/sps-worker-pod-stability is
187+
# implemented
188+
max_slice_restarts=1000000,
188189
)
189190

190191
# If custom server_image is provided, mutate the templates to use it.

pathwaysutils/proxy_backend.py

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,27 @@
1313
# limitations under the License.
1414
"""Register the IFRT Proxy as a backend for JAX."""
1515

16+
import os
1617
import jax
1718
from jax.extend import backend
1819
from jax.extend.backend import ifrt_proxy
1920

2021

2122
def register_backend_factory() -> None:
23+
"""Registers the IFRT Proxy backend factory with JAX."""
24+
25+
def make_client():
26+
options = ifrt_proxy.ClientConnectionOptions()
27+
timeout_secs = os.environ.get("PATHWAYS_PROXY_CONNECTION_TIMEOUT_SECS")
28+
if timeout_secs:
29+
options.connection_timeout_in_seconds = int(timeout_secs)
30+
return ifrt_proxy.get_client(
31+
jax.config.read("jax_backend_target"),
32+
options,
33+
)
34+
2235
backend.register_backend_factory(
2336
"proxy",
24-
lambda: ifrt_proxy.get_client(
25-
jax.config.read("jax_backend_target"),
26-
ifrt_proxy.ClientConnectionOptions(),
27-
),
37+
make_client,
2838
priority=-1,
2939
)

pathwaysutils/test/proxy_backend_test.py

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
# limitations under the License.
1414
"""Tests for the proxy backend module."""
1515

16+
import os
1617
from unittest import mock
1718

1819
from absl.testing import absltest
@@ -54,6 +55,46 @@ def test_proxy_backend_registration(self):
5455
proxy_backend.register_backend_factory()
5556
self.assertIn("proxy", backend.backends())
5657

58+
def test_proxy_backend_registration_with_timeout(self):
59+
mock_get_client = self.enter_context(
60+
mock.patch.object(
61+
ifrt_proxy,
62+
"get_client",
63+
return_value=mock.MagicMock(),
64+
)
65+
)
66+
self.enter_context(
67+
mock.patch.dict(
68+
os.environ, {"PATHWAYS_PROXY_CONNECTION_TIMEOUT_SECS": "42"}
69+
)
70+
)
71+
proxy_backend.register_backend_factory()
72+
self.assertIn("proxy", backend.backends())
73+
mock_get_client.assert_called_once()
74+
args, _ = mock_get_client.call_args
75+
self.assertEqual(args[0], "grpc://localhost:12345")
76+
options = args[1]
77+
self.assertEqual(options.connection_timeout_in_seconds, 42)
78+
79+
def test_proxy_backend_registration_without_timeout(self):
80+
mock_get_client = self.enter_context(
81+
mock.patch.object(
82+
ifrt_proxy,
83+
"get_client",
84+
return_value=mock.MagicMock(),
85+
)
86+
)
87+
self.enter_context(mock.patch.dict(os.environ))
88+
os.environ.pop("PATHWAYS_PROXY_CONNECTION_TIMEOUT_SECS", None)
89+
90+
proxy_backend.register_backend_factory()
91+
self.assertIn("proxy", backend.backends())
92+
mock_get_client.assert_called_once()
93+
args, _ = mock_get_client.call_args
94+
self.assertEqual(args[0], "grpc://localhost:12345")
95+
options = args[1]
96+
self.assertNotEqual(options.connection_timeout_in_seconds, 42)
97+
5798

5899
if __name__ == "__main__":
59100
absltest.main()

0 commit comments

Comments
 (0)