fn
load_sharded
→OrderedDict or objectload_sharded(path: str | bytes, map_location: str | Callable[[str, str], str] | dict[str, str] | None = None, weights_only: bool = True)Load a sharded checkpoint directory written by save_sharded.
Reads index.json, then deserialises each shard with load
and merges the results into a single OrderedDict preserving key
order. The _metadata attribute, if stored in the index, is
reattached to the merged dictionary.
Parameters
pathstr or bytesDirectory containing
index.json and the per-shard files.map_locationstr, dict, callable, or None= NoneDevice remapping forwarded to each per-shard
load call.weights_onlybool= TrueIf
True (default), restrict deserialisation to a safe type
whitelist.Returns
OrderedDict or objectThe merged state dict; for single-shard non-dict objects, the underlying object as written.
Notes
Shard order is taken from the index file — the function does not rely on filesystem listing order, so reproducibility is preserved across hosts.
Examples
>>> import lucid
>>> sd = lucid.serialization.load_sharded("ckpt_dir")