pub fn open_checkpoint(path: impl AsRef<Path>) -> Result<AnyCheckpoint>Expand description
Open any supported checkpoint, reading GGUF into memory and serving Safetensors with bounded per-tensor reads.
Detection, in order:
- a directory is a Safetensors shard directory;
- a file starting with the
GGUFmagic is GGUF; - a
*.safetensorsfile or*.safetensors.index.jsonis Safetensors; - a
*.gguffile without the magic is handed to the GGUF parser, which reports the bad header; - anything else is
ParserError::UnsupportedFormat.
Safetensors input without the safetensors feature returns
ParserError::FeatureDisabled; no other backend is substituted.
Examples found in repository?
examples/inspect_checkpoint.rs (line 62)
52fn open(args: &Args) -> Result<AnyCheckpoint> {
53 if args.mmap {
54 #[cfg(feature = "mmap")]
55 return engram_parser::open_checkpoint_mmap(&args.path);
56 #[cfg(not(feature = "mmap"))]
57 return Err(engram_parser::ParserError::FeatureDisabled {
58 path: args.path.clone(),
59 feature: "mmap",
60 });
61 }
62 open_checkpoint(&args.path)
63}