nvalchemi.distributed.JitAdapter#
- class nvalchemi.distributed.JitAdapter(module_path, attr_name, replacement=None, mode='eager', install_site='')[source]#
Replace a
@torch.jit.script-decorated module-level helper so a ShardTensor can cross it safely on the distributed path.Two modes:
mode="marshal": wrap the original scripted op withmake_marshaller()at install time — unwrap ShardTensor→local, run the scripted op, rewrap. Keeps the op scripted/fused; no hand-written copy.mode="eager": swap inreplacement(a hand-written plain-Python equivalent so ShardTensor__torch_function__fires inside it). The author keeps that copy in sync with upstream.
- Parameters:
module_path (str)
attr_name (str)
replacement (Callable[[...], Any] | None)
mode (Literal['eager', 'marshal'])
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
JitAdapterfromto_dict()output.- Parameters:
d (dict[str, Any])
- Return type:
- install()[source]#
Swap in the replacement at
module.attr.mode="marshal": build amake_marshaller()around the current attribute (the original scripted op) — no hand-written copy needed.mode="eager": swap inself.replacement.replacement=Noneis the declaration-only form: the entry is in the spec for diagnostics, but the wrapper’sdistributed_setuphook swaps the attribute (it closes over per-run partition metadata). The registry no-ops here.- Return type:
dict[str, Any]