Skip to content

gguf: optional mmap-backed reader + K-quant dequant (blocks the corinth-canal consumer) #45

Description

@rmems

Mirror of rmems/corinth-canal#144. Follow-up to the closed #7; blocks rmems/corinth-canal#115.

Why this exists

#7 ("adopt/enhance as canonical GGUF parser by extracting from corinth-canal") is closed as Done,
but its sibling on the consumer side — rmems/corinth-canal#115, "migrate GGUF parser layer to
engram-parser dep" — is not implementable against v0.2.0. The extraction landed; the adoption
cannot follow. Filing so that gap is tracked somewhere rather than sitting invisible behind a
closed issue.

Blocker 1 — whole-file read vs mmap

src/gguf/mod.rs:38-45:

/// The full file contents are read into memory (no mmap; zero-dep by design)
...
let bytes = fs::read(path_ref).map_err(|e| ParserError::Io { ... })?;

GgufLayout owns a Vec<u8> of the entire checkpoint.

corinth does the opposite and has to: it mmaps the file (src/moe/gguf/map.rs) and then
CUDA-host-registers page-aligned tensor ranges (src/moe/gguf/cuda_register.rs) so the GPU can
DMA directly from the mapping. These are multi-GB MoE checkpoints — 8.9 GB ZAYA1-8B-Q8_0, 14 GB
Kimi-VL-A3B-Q6_K, and larger. Reading them into an owned Vec<u8> is not a performance nuance; it
defeats the purpose of the mapping layer and would make host-register impossible.

I recognise [dependencies] is deliberately empty and that memmap2 contradicts the zero-dep
stance. That is exactly why this needs a decision rather than a patch.

Blocker 2 — F16-only dequantization

$ grep -rn "pub fn dequantize" src/
src/gguf/tensor.rs:504:    pub fn dequantize_f16(&self, bytes: &[u8]) -> Result<Vec<f32>>

corinth needs Q8_0, Q5_K, Q6_K, and IQ3_M (src/moe/gguf/map.rs, src/moe/gguf/dequant.rs) —
that ladder is the entire basis of its synapse-source selection, and the local model inventory is
predominantly Q8_0/Q6_K.

Why header-only adoption isn't a useful compromise

Taking this crate for just header/KV/tensor-directory parsing would replace corinth's
src/moe/gguf/metadata.rs — about 335 lines — with a dependency that reads the whole checkpoint
into RAM in order to parse a header
. Strictly worse than the status quo.

Options

  1. Optional mmap feature (default off, zero-dep path preserved) plus K-quant dequant behind a
    feature or in the core. Keeps the crate's stated design intact for existing users while making a
    real consumer possible.
  2. Decline, and record that engram-parser is zero-dep by construction and will not serve
    mmap-backed consumers. Then moe: migrate GGUF parser layer to engram-parser dep (extract useful code from experimental ref impl) corinth-canal#115 should be closed won't-do, and sharing
    happens the [engram-parser] GH#10 — safetensors: coordinate ecosystem / sibling parser extraction from corinth-canal (separate from GGUF #7; one-way copy, no dep on corinth-canal) #10 way — one-way copy, no dependency. That is a legitimate outcome; [engram-parser] GH#10 — safetensors: coordinate ecosystem / sibling parser extraction from corinth-canal (separate from GGUF #7; one-way copy, no dep on corinth-canal) #10 already
    establishes that pattern for safetensors.

Either is fine. What is not fine is #115 sitting open indefinitely against an API that cannot
satisfy it.

Acceptance

Context

Part of a three-repo dependency review this week; all three reached the same shape — the influence
gradient runs corinth → siblings, so upstream first, adopt second. See
rmems/corinth-canal#143 (axon-encoder / neuromod), #144 (this), #145 (myelin-accelerator, mirrored
as Limen-Neural/myelin-accelerator#27).

Activity

  1. added
    modularizationWork to make repos more modular and overlapping
    apiAPI changes or trait work
    extractionMain extraction coming from rmems/corinth-canal
    on Aug 3, 2026
  2. linear-code commented on Aug 3, 2026

    @linear-code
  3. self-assigned this
    on Aug 7, 2026
  4. removed
    apiAPI changes or trait work
    on Aug 8, 2026
  5. added this to the 0.2.0 milestone on Aug 23, 2026
  6. rmems commented on Sep 15, 2026

    @rmems
    OwnerAuthor

    Cursor agent — cortex-tensor consume follow-up rmems/cortex-tensor#47 is blocked on this issue (mmap + K-quant). Docs/freeze retarget (no consume implementation): rmems/cortex-tensor#48.

  7. rmems commented on Sep 15, 2026

    @rmems
    OwnerAuthor

    Option 1 is the decision. Surface shipped in #73. Follow-up parity/CI for the multi-GB mmap acceptance item: #75 (sparse 2 GiB mapping + packed K-quant dequant from mmap). Real on-disk pilots stay #[ignore] behind ENGRAM_GGUF.

    Pointer on closed #7 posted so the extraction→adoption gap stays traceable. Corinth consume remains #115.

    Linear twin: RM-367.

  8. rmems commented on Sep 15, 2026

    @rmems
    OwnerAuthor

    Option 1 is the recorded decision (corinth-canal#144 / RM-237): optional mmap + K-quant dequant, zero-dep default preserved.

    This issue shipped in #73. corinth-canal#115 is now unblocked and re-scoped to consume load_gguf_mmap plus packed Q8_0/Q5_K/Q6_K/IQ3_M; CUDA host-register stays in the consumer. Docs: rmems/corinth-canal#207

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

extractionMain extraction coming from rmems/corinth-canalmodularizationWork to make repos more modular and overlapping

Projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions