From fbb8a27317815344da90d5c33f0563aaaabc8071 Mon Sep 17 00:00:00 2001 From: Wanqiang Date: Fri, 16 Jan 2026 21:19:09 +0800 Subject: [PATCH 1/2] Use `Parallel.spawn_kwargs` as kwargs to the backend when appropriate --- ignite/distributed/launcher.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/ignite/distributed/launcher.py b/ignite/distributed/launcher.py index 324533c618c5..e9564cc2715b 100644 --- a/ignite/distributed/launcher.py +++ b/ignite/distributed/launcher.py @@ -232,6 +232,7 @@ def __init__( self.backend = backend self._spawn_params = None + self._pg_init_kwargs = None self.init_method = init_method if self.backend is not None: @@ -239,6 +240,11 @@ def __init__( self._spawn_params = self._setup_spawn_params( nproc_per_node, nnodes, node_rank, master_addr, master_port, init_method, **spawn_kwargs ) + else: + self._pg_init_kwargs = spawn_kwargs + if "init_method" in self._pg_init_kwargs: + raise ValueError("Argument 'init_method' should not be specified in 'spawn_kwargs'") + # The logger will be setup after the idist.initialize() call self._logger = None @@ -319,7 +325,7 @@ def training(local_rank, config, **kwargs): def __enter__(self) -> "Parallel": if self.backend is not None and self._spawn_params is None: - idist.initialize(self.backend, init_method=self.init_method) + idist.initialize(self.backend, init_method=self.init_method, **(self._pg_init_kwargs or dict())) # The logger can be setup from now since idist.initialize() has been called (if needed) self._logger = setup_logger(__name__ + "." + self.__class__.__name__) From 1f1b035cecc86c13af41ad1b43330d7b31dc9a84 Mon Sep 17 00:00:00 2001 From: Wanqiang Date: Fri, 16 Jan 2026 21:34:10 +0800 Subject: [PATCH 2/2] Remove unreachable check --- ignite/distributed/launcher.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/ignite/distributed/launcher.py b/ignite/distributed/launcher.py index e9564cc2715b..7fceb07cda5a 100644 --- a/ignite/distributed/launcher.py +++ b/ignite/distributed/launcher.py @@ -242,8 +242,6 @@ def __init__( ) else: self._pg_init_kwargs = spawn_kwargs - if "init_method" in self._pg_init_kwargs: - raise ValueError("Argument 'init_method' should not be specified in 'spawn_kwargs'") # The logger will be setup after the idist.initialize() call