core.safe_globals#
Module Contents#
Classes#
Restricted unpickler for FP8 extra-state checkpoints.
Only allows the narrow set of types that |
Functions#
Register megatron-core safe classes with torch serialization. |
|
Safe version (weights_only=True) of |
Data#
API#
- core.safe_globals.SAFE_GLOBALS#
None
- core.safe_globals.register_safe_globals()#
Register megatron-core safe classes with torch serialization.
- core.safe_globals.safe_load_from_bytes(b)#
Safe version (weights_only=True) of
torch.storage._load_from_bytes.
- class core.safe_globals.SafeUnpickler#
Bases:
pickle.UnpicklerRestricted unpickler for FP8 extra-state checkpoints. Only allows the narrow set of types that
_encode_extra_statecan produce: plain Python containers, numeric scalars, and the PyTorch tensor/storage primitives used bypickle.dumps(tensor). Any attempt to instantiate a class outside this allowlist raisespickle.UnpicklingError, preventing arbitrary code execution via a crafted checkpoint.Initialization
Initialize self. See help(type(self)) for accurate signature.
- _SAFE_CLASSES: frozenset#
‘frozenset(…)’
- find_class(module: str, name: str)#