Skip to content

Getting Started

Wiki Keeper (Grok Bot) edited this page Oct 15, 2026 · 4 revisions

Getting Started

Wiki hero

Install

Version 0.3.0 is the first public crates.io publication (0.2.0 was development-only and never published).

[dependencies]
engram-parser = "0.3"

with Safetensors:

[dependencies]
engram-parser = { version = "0.3", features = ["safetensors"] }

or Safetensors plus borrowed mmap payloads:

[dependencies]
engram-parser = { version = "0.3", features = ["safetensors", "mmap"] }

Equivalently: cargo add engram-parser@0.3 (add --features as needed).

For a development snapshot, pin an exact Git commit:

[dependencies]
engram-parser = { git = "https://github.com/rmems/engram-parser", rev = "dbc46cf091e3ab5e046ebefe6eda44f1058f5af0" }
Feature Adds Enables
(default) — GGUF parsing, Checkpoint API, MoE analysis, K-quant dequant
mmap optional memmap2 load_gguf_mmap, open_checkpoint_mmap, page-aligned / borrowed slices
safetensors optional upstream safetensors 0.8 header/manifest/discovery + raw payload access

Default builds stay zero-dependency; optional crates activate only under their features.

Format-agnostic Checkpoint

use engram_parser::{Checkpoint, open_checkpoint};

fn main() -> Result<(), engram_parser::ParserError> {
    let ckpt = open_checkpoint("./model.gguf")?;
    println!("format = {:?}", ckpt.format());
    for t in ckpt.tensors() {
        println!("{} {} {:?} {}B", t.name, t.dtype, t.shape.dims(), t.byte_len);
    }
    if let Some(t) = ckpt.tensors().first() {
        let raw = ckpt.tensor_bytes(&t.name)?;
        println!("{}: {} bytes", t.name, raw.len());
    }
    Ok(())
}

See Checkpoint.

GGUF load and MoE extract

use engram_parser::analysis::moe::{extract_expert, list_experts};
use engram_parser::load_gguf;

fn main() -> Result<(), engram_parser::ParserError> {
    let layout = load_gguf("./moe-model.gguf")?;
    println!("architecture = {}", layout.metadata.architecture());

    for (block, expert) in list_experts(&layout) {
        let weights = extract_expert(&layout, block, expert)?;
        if let Some(gate) = &weights.gate {
            println!(
                "blk.{block}.expert{expert}.gate: dims={:?} dtype={:?} bytes={}",
                gate.dims, gate.dtype, gate.bytes.len()
            );
        }
    }
    Ok(())
}

Legacy imports engram_parser::moe::* and crate-root extract_expert / list_experts still compile as compatibility re-exports.

Packed dequant (GGUF)

use engram_parser::{dequantize_packed, dequantize_q8_0};

let values: Vec<f32> = dequantize_q8_0(&packed_bytes, &dims)?;
let values: Vec<f32> = dequantize_packed(dtype, &packed_bytes, &dims)?;

Supported: Q8_0, Q5_K, Q6_K, IQ3_M block layout, plus existing dequantize_f16.

Safetensors (feature)

use engram_parser::safetensors::{inspect_safetensors_checkpoint, open_safetensors_checkpoint};

let manifest = inspect_safetensors_checkpoint("./model.safetensors")?;
let checkpoint = open_safetensors_checkpoint("./model.safetensors")?;
let raw: Vec<u8> = checkpoint.tensor_bytes("a.weight")?; // use a real name from the manifest

Requires --features safetensors. With --features safetensors,mmap, use open_safetensors_checkpoint_mmap for borrowed &[u8]. No Hugging Face config.json policy.

In-memory parse (tests)

use engram_parser::parse_bytes;

let layout = parse_bytes(bytes, "mem://fixture".into())?;

Trusted callers can raise budgets with load_gguf_with_limits / parse_bytes_with_limits / ParseLimits::trusted().

Development

cargo fmt --check
cargo clippy --all-targets --all-features --locked -- -D warnings
cargo build --all-features --locked
cargo test --all-features --locked

# Coverage (optional; matches CI)
cargo llvm-cov --all-targets --all-features --locked --lcov --output-path coverage.lcov

MSRV: Rust 1.97.1. Dev pin: 1.99.0 (rust-toolchain.toml). Edition: 2024.

There is no root Dockerfile or published GHCR image for this crate; .cursor/Dockerfile is for Cursor Cloud Agent environments only.

Next


Last updated: October 14, 2026 Updated by: Wiki Keeper (Grok Bot) Package tip reference: dbc46cf (main)

Clone this wiki locally