latest (dev)
Copy
Latest development documentation · Updated 2026-10-08
tensorplay.distributed.algorithms API
Classes 3
Join
classFull reference ↗- class tensorplay.distributed.algorithms.Join(joinables: list[Joinable], enable: bool = True, throw_on_early_termination: bool = False, **kwargs)[source]
This class defines the generic join context manager, which allows custom hooks to be called after a process joins.
These hooks should shadow the collective communications of non-joined processes to prevent hanging and erroring and to ensure algorithmic correctness. Refer to
JoinHookfor details about the hook definition.Warning
The context manager requires each participating
Joinableto call the methodnotify_join_context()before its own per- iteration collective communications to ensure correctness.- Parameters:
joinables (List[Joinable]) – a list of the participating
Joinables; their hooks are iterated over in the given order.enable (bool) – a flag enabling uneven input detection; setting to
Falsedisables the context manager’s functionality and should only be set when the user knows the inputs will not be uneven (default:True).throw_on_early_termination (bool) – a flag controlling whether to throw an exception upon detecting uneven inputs (default:
False).
- static notify_join_context(joinable: Joinable)[source]
Notifies the join context manager that the calling process has not yet joined.
Then, if
throw_on_early_termination=True, checks if uneven inputs have been detected (i.e. if one process has already joined) and throws an exception if so.This method should be called from a
Joinableobject before its per-iteration collective communications. For example, this should be called at the beginning of the forward pass inDistributedDataParallel.Only the first
Joinableobject passed into the context manager performs the collective communications in this method, and for the others, this method is vacuous.
Joinable
classFull reference ↗- class tensorplay.distributed.algorithms.Joinable[source]
This defines an abstract base class for joinable classes.
A joinable class (inheriting from
Joinable) should implementjoin_hook(), which returns aJoinHookinstance, in addition tojoin_device()andjoin_process_group()that return device and process group information, respectively.- abstract property join_device
Return the device from which to perform collective communications needed by the join context manager.
- abstract property join_process_group: Any
Returns the process group for the collective communications needed by the join context manager itself.
JoinHook
classFull reference ↗- class tensorplay.distributed.algorithms.JoinHook[source]
This defines a join hook, which provides two entry points in the join context manager.
Entry points : a main hook, which is called repeatedly while there exists a non-joined process, and a post-hook, which is called once all processes have joined.
To implement a join hook for the generic join context manager, define a class that inherits from
JoinHookand overridemain_hook()andpost_hook()as appropriate.
Help improve this page
Found an error, an unclear step, or a missing example?
tensorplay.cuda.tunable API
Complete API reference for tensorplay.cuda.tunable, including signatures, parameters, examples and members.
tensorplay.distributed.algorithms.ddp_comm_hooks.ddp_zero_hook API
Complete API reference for tensorplay.distributed.algorithms.ddp_comm_hooks.ddp_zero_hook, including signatures, parameters, examples and members.

