scripts: hugepages-id private MTP staging dir (0700), installer --tools-only; docs: hugepages page draft (mapping facts)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
a8171b2cc0
commit
2725385741
@@ -0,0 +1,41 @@
|
||||
# 5090 decode: huge pages for the resident expert banks (claude/hugepages)
|
||||
|
||||
Date 2026-11-01. RTX 5090 server `rnr5090` (Ryzen 9 9950X3D, 121 GiB, kernel 7.0.0-38), frozen corpus, ~245k context, 5 turns. Base = main fe5910135 (code of 11e021161).
|
||||
Labels: M measured in the run named, E estimate, C code reading.
|
||||
Follows [baseline-pair-5090](baseline-pair-5090.md) section 5 (vanilla 7-8 % slower when its arena gets only partial THP) and [cpu-service-5090](cpu-service-5090.md) section 6.
|
||||
|
||||
## 1. Which host memory the decode reads, and how it is mapped
|
||||
|
||||
| reader | memory | mapping (M: `/proc/<pid>/smaps` of `b05p2-ours`, `runs/baseline-pair-c`, 2026-10-31 23:41Z) |
|
||||
| --- | --- | --- |
|
||||
| CPU expert pool (`cpu.compute`) | the resident bank copy: 144 tensors (gate/up/down x 48 layers) of shard 0 copied into heap `Vec<u8>`s by `load_resident_expert_source` (C: `gguf_resident.rs` `load_resident_tensor`) | one private anonymous VMA of 46.84 GiB RSS (the 144 glibc `mmap` chunks merged), **4 KiB pages, AnonHugePages 0** |
|
||||
| PCIe expert uploads (copy kernel / DMA) | the same banks, registered with `cuMemHostRegister(DEVICEMAP)` (C: `mapped_expert_bank.rs`); the GPU sits behind the AMD IOMMU in **translated `DMA-FQ` mode** (`/sys/kernel/iommu_groups/*/type`), so its reads also walk the IOMMU page table | same VMA |
|
||||
| KAR memfd (holder, 51.5 GiB shmem) | PLE rows only, read with `pread` (C: `qwen4exp_kar_ple.rs` `read_exact_at`) through the kernel's own direct map | mapped read-only once by `leleka-memory` for `mlock`/`mincore` only: **Rss 0**; never dereferenced |
|
||||
| pinned staging / arenas | `cuMemHostAlloc` buffers | 29 shared `/dev/zero` (shmem) mappings, 3.7 GiB RSS, 4 KiB |
|
||||
|
||||
System (M, read only): THP `enabled=madvise`, `defrag=madvise`, `shmem_enabled=never` (also per-size `inherit`), khugepaged `max_ptes_none=511`, `HugePages_Total=0`,
|
||||
`nr_overcommit_hugepages=0`, `CONFIG_READ_ONLY_THP_FOR_FS` not set, ext4 `/data`. Process: `VmPin 0` (the NVIDIA driver does not account its pins there).
|
||||
|
||||
Consequences: the 46.8 GiB the decode actually reads can use THP from userspace (anonymous memory + `MADV_HUGEPAGE`, which `enabled=madvise` honours). The memfd cannot get THP at
|
||||
allocation while `shmem_enabled=never` (MADV_HUGEPAGE on shmem is ignored, `MFD_HUGETLB` needs reserved hugetlbfs pages), but the decode does not read it through a mapping, so
|
||||
it does not matter for this path; `scripts/e2e/decode/owner-shmem-thp.sh` (root, not run) is the switch should a future path map it. The old `LELEKA_BANK_THP=on` knob
|
||||
(claude/decode-parity, "took no effect") only advised the unaligned heap `Vec`.
|
||||
|
||||
## 2. Change (opt-in, off by default)
|
||||
|
||||
`LELEKA_HUGEPAGES=on` (`thp` = skip the hugetlbfs attempt; `LELEKA_BANK_THP=on` now means `thp`), `crates/model-format/src/huge_pages.rs`:
|
||||
|
||||
* each bank in its own 2 MiB-aligned private anonymous mapping (over-allocate 2 MiB, trim) instead of a heap `Vec`;
|
||||
* `MAP_HUGETLB | MAP_HUGE_2MB` only when `HugePages_Free` covers the bank (none on rnr5090; nothing reserved);
|
||||
* otherwise `MADV_HUGEPAGE` + `MADV_POPULATE_WRITE` (fault in before the file is read into it), then the same `read_tensor_into` (same FD, bounds and size fences as the heap copy);
|
||||
* `huge_pages::settle()` after the bank load and the shard page-cache drop, before the banks are page-locked: coverage from `/proc/self/smaps` and `MADV_COLLAPSE` of 2 MiB ranges
|
||||
that fell back (Linux 6.1+, independent of the sysfs knobs; best effort). One log line `leleka-hugepages: ...` per stack start.
|
||||
* budget charge unchanged (`len` bytes; THP uses the same pages as the heap copy).
|
||||
|
||||
## 3. Identity (`runs/hugepages-id`, job `hp-id`)
|
||||
|
||||
PENDING.
|
||||
|
||||
## 4. Paired A/B (`runs/hugepages-ab`, job `hp-ab`)
|
||||
|
||||
PENDING.
|
||||
@@ -13,7 +13,8 @@ LOCK=/data/leleka-e2e/gpu.lock
|
||||
HP=/data/leleka-e2e/hugepages
|
||||
D=/data/leleka-e2e/decode/dt
|
||||
O=/data/leleka-e2e/runs/hugepages-id
|
||||
mkdir -p $O $HP/mtp-staging
|
||||
mkdir -p $O
|
||||
install -d -m 0700 $HP/mtp-staging; chmod 0700 $HP/mtp-staging # the MTP staging directory must be private (0700) or the binding refuses (Metadata)
|
||||
( cd / && sha256sum --quiet -c "$HP/MANIFEST.sha256" ) || { echo "hugepages: MANIFEST.sha256 check failed" >&2; exit 3; }
|
||||
export LD_LIBRARY_PATH=$HOME/cuda-toolkits/cublas-12.9.1.4/lib:$HOME/cuda-toolkits/13.2.2/lib64:${LD_LIBRARY_PATH:-}
|
||||
A=/home/para/work/leleka/models/leleka-gates/assets
|
||||
|
||||
@@ -7,14 +7,16 @@ set -euo pipefail
|
||||
HP=/data/leleka-e2e/hugepages
|
||||
D=/data/leleka-e2e/decode/dt
|
||||
SRC=$(cd "$(dirname "$0")" && pwd)
|
||||
BIN=${1:?directory with the uploaded binaries}
|
||||
BIN=${1:?directory with the uploaded binaries, or --tools-only}
|
||||
mkdir -p "$HP/tools" "$HP/bin-hugepages"
|
||||
chmod -R u+w "$HP/tools" "$HP/bin-hugepages" 2>/dev/null || true
|
||||
chmod u+w "$HP/rt-hugepages" 2>/dev/null || true
|
||||
for f in hugepages-ab.sh hugepages-id.sh hugepages-analyze.py baseline-sampler.py ts-wrap.sh; do install -m 0444 "$SRC/$f" "$HP/tools/$f"; done
|
||||
for b in leleka-inference leleka-daemon leleka-cli strata-next; do install -m 0555 "$BIN/$b" "$HP/bin-hugepages/$b"; done
|
||||
install -m 0444 "$BIN/COMMIT.txt" "$HP/bin-hugepages/COMMIT.txt"
|
||||
install -m 0555 "$BIN/rt-hugepages" "$HP/rt-hugepages"
|
||||
if [ "$BIN" != --tools-only ]; then # --tools-only: refresh the tools and the manifest, keep the installed binaries
|
||||
for b in leleka-inference leleka-daemon leleka-cli strata-next; do install -m 0555 "$BIN/$b" "$HP/bin-hugepages/$b"; done
|
||||
install -m 0444 "$BIN/COMMIT.txt" "$HP/bin-hugepages/COMMIT.txt"
|
||||
install -m 0555 "$BIN/rt-hugepages" "$HP/rt-hugepages"
|
||||
fi
|
||||
chmod a-w "$HP/tools" "$HP/bin-hugepages"
|
||||
{
|
||||
sha256sum "$HP"/tools/* "$HP"/bin-hugepages/* "$HP/rt-hugepages" \
|
||||
|
||||
Reference in New Issue
Block a user