MCPcopy Index your code
hub / github.com/microsoft/BitNet / lazy_load_file

Function lazy_load_file

utils/convert.py:987–995  ·  view source on GitHub ↗
(path: Path)

Source from the content-addressed store, hash-verified

985
986@functools.lru_cache(maxsize=None)
987def lazy_load_file(path: Path) -> ModelPlus:
988 fp = open(path, 'rb')
989 first8 = fp.read(8)
990 fp.seek(0)
991 if struct.unpack('<Q', first8)[0] < 16 * 1024 * 1024:
992 # Safetensors format
993 return lazy_load_safetensors_file(fp, path)
994 else:
995 raise ValueError(f"unknown format: {path}. Only safetensors format is supported.")
996
997
998In = TypeVar('In')

Callers 2

load_some_modelFunction · 0.70
mainFunction · 0.70

Calls 1

Tested by

no test coverage detected