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: 11 additions & 0 deletions jax/_src/distributed.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,15 @@
),
)

_ENABLE_PREEMPTION_SERVICE = config.bool_state(
name='jax_enable_preemption_service',
default=True,
help=(
"Enables the preemption service. See"
" multihost_utils.reached_preemption_sync_point for details."
),
)

class State:
process_id: int = 0
num_processes: int = 1
Expand Down Expand Up @@ -188,6 +197,8 @@ def shutdown(self):
self.service = None

def initialize_preemption_sync_manager(self):
if not _ENABLE_PREEMPTION_SERVICE.value:
return
if self.preemption_sync_manager is not None:
raise RuntimeError(
'Preemption sync manager should only be initialized once.')
Expand Down
5 changes: 4 additions & 1 deletion jax/experimental/multihost_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,10 @@ def should_save(step_id: int) -> bool:
return False
sync_manager = distributed.global_state.preemption_sync_manager
if sync_manager is None:
raise RuntimeError("Preemption sync manager has not been initialized.")
raise RuntimeError(
"Preemption sync manager has not been initialized. Make sure the"
" 'jax_enable_preemption_service' config is enabled."
)
return sync_manager.reached_sync_point(step_id)


Expand Down
Loading