[PR #2823] [CLOSED] Q36: release the GGUF mapping and stop zeroing the overwritten arena #4283

Closed
opened 2026-11-07 15:34:33 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Niko1221/Strata/pull/2823
Author: @ggeorgovassilis
Created: 10/17/2026
Status: ❌ Closed

Base: main ← Head: dev


📝 Commits (10+)

  • 7156cf9 Qwen3.6: opt-in int8 (q8_0) K/V cache behind --kv int8
  • 3a9e6c8 Qwen3.6: opt-in single staging buffer and staging placement fixes
  • 58ccab1 Add Docker build/run scripts and a run.sh test
  • 21bf82c docs: record that STRATA_KQ256 does not cover Q5_K down (tried, measured, dropped)
  • 98a66d4 docs: the Q36 memory-compaction plan (mapping, arena, kcompactd)
  • 2b9f769 Q36: memory compaction - mem report, release the mapping, padding-only memset
  • 91edaaa docs: the 754 open upstream PRs screened against the 8 GB laptop
  • 68add05 docs: upstream PR scan - corrections and an implementation plan
  • 70d7531 tools: strata_profile.py, one command that says where the time goes on this PC (prompt phases, decode window split, hit rate per turn)
  • 2d8da65 setup: pin -DSTRATA_Q6K_EXPERTS=ON in the CUDA engine build

📊 Changes

33 files changed (+6928 additions, -55 deletions)

View changed files

📝 CMakeLists.txt (+23 -2)
📝 Dockerfile (+1 -1)
➕ bench/results/2026-10-15-profile-rtx-5070-ti-swift-1-5-iq3-s/README.md (+55 -0)
➕ bench/results/2026-10-15-profile-rtx-5070-ti-swift-1-5-iq3-s/results.json (+1978 -0)
➕ docker/Dockerfile (+171 -0)
➕ docker/build.sh (+65 -0)
➕ docker/entrypoint.py (+242 -0)
➕ docker/run.sh (+292 -0)
📝 docs/COMMUNITY_BENCHMARKS.md (+6 -0)
📝 docs/DETAILS.md (+64 -0)
➕ docs/Q36_INT8_KV.md (+229 -0)
➕ docs/Q36_LOAD_TIME.md (+172 -0)
➕ docs/Q36_MEMORY_COMPACTION.md (+393 -0)
📝 docs/QUANTS.md (+8 -0)
➕ docs/UPSTREAM_PR_SCAN.md (+373 -0)
📝 include/strata/artifact/gguf_reader.hpp (+31 -0)
➕ include/strata/kernels/q36_kv_q8.hpp (+61 -0)
➕ include/strata/platform/mem_report.hpp (+104 -0)
📝 setup.py (+5 -2)
📝 src/artifact/gguf_reader_test.cpp (+61 -0)

...and 13 more files

📄 Description

Summary

Implements the Q36 memory-compaction plan (docs/Q36_MEMORY_COMPACTION.md): the engine reports its own memory/compaction counters, releases the GGUF mapping after load, and stops zeroing the 18.75 GiB expert arena it immediately overwrites. The original goal - quiet the kcompactd churn - was already met by host settings; the measured engine win is ~18.5 GiB of RAM returned to the OS at no decode cost.

What changed

  • include/strata/platform/mem_report.{hpp,cpp} (new) + src/platform/mem_report_test.cpp: read /proc/meminfo, /proc/vmstat and the THP mode into the engine's own log, behind STRATA_MEM_REPORT (off by default). A row the kernel does not export prints -, not 0.
  • include/strata/artifact/gguf_reader.hpp: GgufFile::release_pages()/released() and GgufModel::release_pages()/released() — madvise(MADV_DONTNEED) then posix_fadvise(POSIX_FADV_DONTNEED) (fadvise cannot drop pages that are still mapped).
  • src/qwen35/q36_engine.cu: release_model_mapping() after place_experts(), on by default; STRATA_Q36_RELEASE_MAPPING=0 reverts. A guard makes expert_blob() fail loudly if it is ever called after the release. The arena memset now zeroes only the stride padding and the kMmqTail tail (plus an NVFP4 scale tail) instead of the whole 18.75 GiB.
  • tests/core/expert_blob_padding_test.cpp (new): the padding-only zeroing is byte-identical to the whole memset.

Extra Notes

Measured on an RTX 4060 Max-Q 8 GiB, Ryzen 7 7735HS, 62 GB, 32K, --kv int8 --mtp 2:

Cached MemFree decode tok/s
before 47.27 GiB 3.47 GiB ~10
after 28.75 GiB 22.03 GiB ~10

Mlocked stayed 104 KiB throughout - cudaHostAlloc on this driver (580.178.04) is memfd/shm-backed, not mlocked, so the plan's "un-pin the arena" phase and its dependent were dropped.

Built: CPU suite 44/44, CUDA build, and the native-expert parity suite on the card (14/14). HIP and SYCL builds were not run here (no ROCm/SYCL on this box).


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Niko1221/Strata/pull/2823 **Author:** [@ggeorgovassilis](https://github.com/ggeorgovassilis) **Created:** 10/17/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `dev` --- ### 📝 Commits (10+) - [`7156cf9`](https://github.com/Niko1221/Strata/commit/7156cf910b5f30c38ffcd944a96c08fb0109ec7f) Qwen3.6: opt-in int8 (q8_0) K/V cache behind --kv int8 - [`3a9e6c8`](https://github.com/Niko1221/Strata/commit/3a9e6c888a645331a0bf2179897f43cdaebf43ba) Qwen3.6: opt-in single staging buffer and staging placement fixes - [`58ccab1`](https://github.com/Niko1221/Strata/commit/58ccab14faa3d154b1515f7e61929a0de5355172) Add Docker build/run scripts and a run.sh test - [`21bf82c`](https://github.com/Niko1221/Strata/commit/21bf82c118c4a0ccf34f9da65e5f7c15b1d3bcf9) docs: record that STRATA_KQ256 does not cover Q5_K down (tried, measured, dropped) - [`98a66d4`](https://github.com/Niko1221/Strata/commit/98a66d44f7e368abfd825a59700a275201644e91) docs: the Q36 memory-compaction plan (mapping, arena, kcompactd) - [`2b9f769`](https://github.com/Niko1221/Strata/commit/2b9f769830ee74b154bb1433c10b47921c2a1e40) Q36: memory compaction - mem report, release the mapping, padding-only memset - [`91edaaa`](https://github.com/Niko1221/Strata/commit/91edaaa373e80a55d25f168dc9fdb8ef3c6b6c72) docs: the 754 open upstream PRs screened against the 8 GB laptop - [`68add05`](https://github.com/Niko1221/Strata/commit/68add05d7446762da5987d3929a2b1836f5cb20e) docs: upstream PR scan - corrections and an implementation plan - [`70d7531`](https://github.com/Niko1221/Strata/commit/70d75311868c7ab5c2e508f28492bc3f3f121075) tools: strata_profile.py, one command that says where the time goes on this PC (prompt phases, decode window split, hit rate per turn) - [`2d8da65`](https://github.com/Niko1221/Strata/commit/2d8da65986b61b9d1aee005a5bff406f0a11afc9) setup: pin -DSTRATA_Q6K_EXPERTS=ON in the CUDA engine build ### 📊 Changes **33 files changed** (+6928 additions, -55 deletions) <details> <summary>View changed files</summary> 📝 `CMakeLists.txt` (+23 -2) 📝 `Dockerfile` (+1 -1) ➕ `bench/results/2026-10-15-profile-rtx-5070-ti-swift-1-5-iq3-s/README.md` (+55 -0) ➕ `bench/results/2026-10-15-profile-rtx-5070-ti-swift-1-5-iq3-s/results.json` (+1978 -0) ➕ `docker/Dockerfile` (+171 -0) ➕ `docker/build.sh` (+65 -0) ➕ `docker/entrypoint.py` (+242 -0) ➕ `docker/run.sh` (+292 -0) 📝 `docs/COMMUNITY_BENCHMARKS.md` (+6 -0) 📝 `docs/DETAILS.md` (+64 -0) ➕ `docs/Q36_INT8_KV.md` (+229 -0) ➕ `docs/Q36_LOAD_TIME.md` (+172 -0) ➕ `docs/Q36_MEMORY_COMPACTION.md` (+393 -0) 📝 `docs/QUANTS.md` (+8 -0) ➕ `docs/UPSTREAM_PR_SCAN.md` (+373 -0) 📝 `include/strata/artifact/gguf_reader.hpp` (+31 -0) ➕ `include/strata/kernels/q36_kv_q8.hpp` (+61 -0) ➕ `include/strata/platform/mem_report.hpp` (+104 -0) 📝 `setup.py` (+5 -2) 📝 `src/artifact/gguf_reader_test.cpp` (+61 -0) _...and 13 more files_ </details> ### 📄 Description ## Summary Implements the Q36 memory-compaction plan (`docs/Q36_MEMORY_COMPACTION.md`): the engine reports its own memory/compaction counters, releases the GGUF mapping after load, and stops zeroing the 18.75 GiB expert arena it immediately overwrites. The original goal - quiet the `kcompactd` churn - was already met by host settings; the measured engine win is ~18.5 GiB of RAM returned to the OS at no decode cost. ## What changed - `include/strata/platform/mem_report.{hpp,cpp}` (new) + `src/platform/mem_report_test.cpp`: read `/proc/meminfo`, `/proc/vmstat` and the THP mode into the engine's own log, behind `STRATA_MEM_REPORT` (off by default). A row the kernel does not export prints `-`, not 0. - `include/strata/artifact/gguf_reader.hpp`: `GgufFile::release_pages()`/`released()` and `GgufModel::release_pages()`/`released()` — `madvise(MADV_DONTNEED)` then `posix_fadvise(POSIX_FADV_DONTNEED)` (fadvise cannot drop pages that are still mapped). - `src/qwen35/q36_engine.cu`: `release_model_mapping()` after `place_experts()`, on by default; `STRATA_Q36_RELEASE_MAPPING=0` reverts. A guard makes `expert_blob()` fail loudly if it is ever called after the release. The arena memset now zeroes only the stride padding and the `kMmqTail` tail (plus an NVFP4 scale tail) instead of the whole 18.75 GiB. - `tests/core/expert_blob_padding_test.cpp` (new): the padding-only zeroing is byte-identical to the whole memset. ## Extra Notes Measured on an RTX 4060 Max-Q 8 GiB, Ryzen 7 7735HS, 62 GB, 32K, `--kv int8 --mtp 2`: | | Cached | MemFree | decode tok/s | |---|---|---|---| | before | 47.27 GiB | 3.47 GiB | ~10 | | after | 28.75 GiB | 22.03 GiB | ~10 | `Mlocked` stayed 104 KiB throughout - `cudaHostAlloc` on this driver (580.178.04) is memfd/shm-backed, not mlocked, so the plan's "un-pin the arena" phase and its dependent were dropped. Built: CPU suite 44/44, CUDA build, and the native-expert parity suite on the card (14/14). HIP and SYCL builds were not run here (no ROCm/SYCL on this box). --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-07 15:34:33 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Niko1221/Strata#4283
No description provided.