nvalchemi.distributed.distributed_method#
- nvalchemi.distributed.distributed_method(body)[source]#
Decorate a
MethodAdapterbody that only diverges under domain decomposition.Removes the boilerplate guard repeated across method adapters so the body holds only the distributed behavior. The wrapped replacement runs the original method verbatim whenever the live context is not distributed (single-process, or any call outside a distributed forward), and otherwise invokes
bodywith the live context already in hand. Gating onis_distributed(notis_halo) keeps the body policy-agnostic: it fires under any strategy (halo, graph-parallel, graph-replicate), and its cross-rank steps are expressed through the policy-dispatched intent verbs.- Parameters:
body (callable) – The halo behavior, called as
body(ctx, original, instance, *args, **kwargs)wherectxis the liveDistributedContextandoriginalis the unpatched method.- Returns:
An
(original, instance, *args, **kwargs)replacement suitable forMethodAdapter.- Return type:
callable
Examples
>>> @distributed_method ... def _refresh_block(ctx, original, block, x, *args, **kwargs): ... return original(block, refresh_neighbors(x), *args, **kwargs)