Skip to content
Open
Show file tree
Hide file tree
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
11 changes: 8 additions & 3 deletions checkpoint/orbax/checkpoint/_src/multihost/multihost.py
Original file line number Diff line number Diff line change
Expand Up @@ -423,9 +423,14 @@ def reached_preemption(step: int) -> bool:
if is_proxy_pathways_backend():
return False

preemption_sync_point_reached = multihost_utils.reached_preemption_sync_point(
step
)
try:
preemption_sync_point_reached = (
multihost_utils.reached_preemption_sync_point(step)
)
except RuntimeError:
# JAX raises RuntimeError when the preemption service is disabled
# via jax_enable_preemption_service config. Treat as no preemption.
return False
_maybe_log_reached_preemption(step, preemption_sync_point_reached)
return preemption_sync_point_reached

Expand Down
13 changes: 13 additions & 0 deletions checkpoint/orbax/checkpoint/_src/multihost/multihost_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,5 +244,18 @@ def setUp(self):
super().setUp()


class ReachedPreemptionTest(parameterized.TestCase):

@mock.patch.object(multihost, 'is_proxy_pathways_backend', return_value=False)
@mock.patch.object(multihost.multihost_utils, 'reached_preemption_sync_point')
def test_returns_false_when_service_disabled(
self, mock_sync_point, mock_is_proxy
):
mock_sync_point.side_effect = RuntimeError(
'Preemption sync manager has not been initialized.'
)
self.assertFalse(multihost.reached_preemption(step=5))


if __name__ == '__main__':
multiprocess_test.main()