nvalchemi.distributed.PythonAdapter#
- class nvalchemi.distributed.PythonAdapter(module_path, attr_name, replacement=None, install_site='')[source]#
Replace a plain-Python module-level helper with a distributed-aware version.
Unlike
JitAdapter, the helper isn’t@torch.jit.script— it’s a normal Python function whose single-process tensor-layout assumptions break under partition. Canonical case:aimnet.nbops.mol_sumreadingmol_idx[-1] + 1for its output size.replacementmay beNoneif it must be built at install time by the wrapper (e.g. it closes over per-run partition metadata that’s only available inDistributedModel.__enter__). Pass a factory via the wrapper’sdistributed_setuphook or overrideinstall()in a subclass.- Parameters:
module_path (str)
attr_name (str)
replacement (Callable[[...], Any] | None)
install_site (str)
- describe(state='pending', error=None)[source]#
Return an
AdapterStatussnapshot of this adapter.- Parameters:
state (Literal['pending', 'installed', 'restored', 'failed'])
error (str | None)
- Return type:
- classmethod from_dict(d)[source]#
Reconstruct a
PythonAdapterfromto_dict()output.- Parameters:
d (dict[str, Any])
- Return type:
- install()[source]#
Swap in the plain-Python replacement at
module.attr.replacement=None= declaration-only: the wrapper’sdistributed_setupis responsible for swapping the attr. See note onJitAdapter.install()for the rationale.- Return type:
dict[str, Any]