Commit Graph
1 Commits
Author SHA1 Message Date
Niko1221 8c2afbc2bf fix(inkling): the GGUF loader gives the mapped pages of a tensor back once it is copied, halving peak RSS (UD-IQ4_XS 28 -> 14 GiB, UD-Q4_K_XL 32 -> 15 GiB)
The GGUF is mmapped read-only (strata::GgufFile) and every tensor is copied out of the mapping: the trunk into the arena, each expert into a
VRAM upload buffer or the host expert arena. The mapped pages stayed in the resident set after the copy, so the file (15.7 GB UD-IQ4_XS,
17.6 GB UD-Q4_K_XL) sat next to the copies. Peak RSS was 28-36 GiB with 7-13 GiB of experts in RAM, which does not fit a 32 GB machine.

- strata/core/mapped_pages.hpp: release_mapped_pages(p, n) drops the whole pages inside [p, p + n) from the process (madvise MADV_DONTNEED on
  Linux, VirtualUnlock to trim the working set on Windows; rounded inward so a neighbour's page is never dropped). The pages stay in the OS
  page cache, reclaimable, and fault back in on a later read, so only the double count goes. STRATA_INK_KEEP_MAPPED_PAGES=1 turns it off.
- ink_gguf_loader.h: read_expert_body releases the gate/up/down source ranges after copying them (both the NVFP4 -> SF4 repack and the GGUF_RAW
  copy); the trunk, drafter and vision tensors (every tensor without _exps) are released once sec1_arena holds them.
- tests/core/mapped_pages_test.cpp: a 64 MB mapping touched in full drops from 67 MB to 3.5 MB resident, unaligned ends round inward, and the
  data reads back unchanged (Linux, -O0 and -O2).
- The .strata and safetensors loaders read with fread / ifstream and never map the file: SQ-10 / SQ-20 peaked at 3.3 / 13.5 GiB on the 12 GB
  card, which is the plan's RAM share plus the trunk and the CUDA runtime.

Measured on an RTX 3060 12 GB (planner-sized plans, ctx 32768, drafter off, same plan before and after): UD-IQ4_XS peak RSS 28.4 -> 13.8 GiB,
UD-Q4_K_XL 31.8 -> 15.5 GiB; first-prompt, 128-token, 8000-token tokens identical on every step; decode 11.5 / 7.7 -> 11.4 / 7.9 tok/s and
8.2 / 6.2 -> 8.3 / 6.2 tok/s (unchanged), prefill 217 -> 216 and 195 -> 195 tok/s.
2026-11-23 14:38:15 +01:00