Skip to main content

open_checkpoint

Function open_checkpoint 

Source
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:

  1. a directory is a Safetensors shard directory;
  2. a file starting with the GGUF magic is GGUF;
  3. a *.safetensors file or *.safetensors.index.json is Safetensors;
  4. a *.gguf file without the magic is handed to the GGUF parser, which reports the bad header;
  5. 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}