[PR #4286] [Engine] add opt-in huge-page backing to DeepSeek's registered RAM store #4986

Open
opened 2026-11-07 16:31:48 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Niko1221/Strata/pull/4286
Author: @yhfgyyf
Created: 10/27/2026
Status: 🔄 Open

Base: main ← Head: codex/dsv41-block-pinned-hugepages


📝 Commits (1)

  • c10a381 [Engine] add opt-in huge pages for the DeepSeek registered RAM store

📊 Changes

11 files changed (+918 additions, -9 deletions)

View changed files

📝 CMakeLists.txt (+6 -0)
📝 docs/DEEPSEEK41.md (+9 -0)
➕ docs/benchmarks/dsv41-pcie-20261021/README.md (+138 -0)
➕ docs/benchmarks/dsv41-pcie-20261021/historical_transfer.cpp (+121 -0)
➕ docs/benchmarks/dsv41-pcie-20261021/measurements.csv (+25 -0)
➕ docs/benchmarks/dsv41-pcie-20261021/provenance.json (+316 -0)
➕ docs/benchmarks/dsv41-pcie-20261021/recompute.py (+31 -0)
📝 src/dsv41/ds4_model.cu (+7 -0)
📝 src/dsv41/ds4_store.hpp (+33 -9)
➕ src/dsv41/ds4_store_pages.hpp (+77 -0)
➕ tests/dsv41/store_pages_test.cpp (+155 -0)

📄 Description

Problem and result

The DeepSeek RAM store already registers host-memory chunks for its optional GPU zero-copy path. Its original allocator does not align those chunks to 2 MiB or request and fault huge pages before registration. This allocator observation comes from source inspection of 4b9e05a2; it is not a claim of a reproduced upstream regression.

This change adds opt-in huge-page backing on Linux CUDA, preserves the default path, and accounts for padding in the existing RAM budget. On the submitted revision, a same-day IQ2_XS comparison of the original 64-slot chunks against 40 aligned chunks with 100% THP measured decode 13.64 → 17.17 token/s (+25.84%). Prefill was effectively unchanged: 1046.44 → 1050.65 token/s (+0.40%). These are results for the combined tested configuration, not a claim that the page-size option alone gives this gain.

Open and closed issues/PRs were searched before submission. #4123 covers the broader DeepSeek/Maya engine update; this PR remains limited to the existing RAM-store allocator. No maintainer scope agreement is claimed, and no default changes or broader port are included.

Approach

  • Reserve one contiguous, 2 MiB-aligned arena. Commit a chunk, request MADV_HUGEPAGE, and fault it before the existing CUDA registration callback.
  • Keep complete expert slots inside a registration, include padding in the budget, and bound registrations at 4 GiB minus 2 MiB. This bound is allocation policy, not a CUDA API limit.
  • Preserve device aliases, registration-failure handling, pinned-reader shrink protection, regrowth and cleanup. Reservation failure falls back to the original allocator; THP backing remains best effort.
  • Enable with DS4_STORE_ZC=1 DS4_STORE_HUGE_PAGES=1; the option is off by default. The measured 40-chunk model configuration also used DS4_STORE_CHUNK_SLOTS=256.

Validation

Tested head: c10a381ed169a651b1b565d9eeaf385606136797; parent/control build: 4b9e05a2a806a3fe24f7b2560d98626c37dade35. Both used llama.cpp 3cf03257f219afbe7334045ff7c6a06ac68c627d. The 4,958 head source files and 4,951 parent source files were checked against the local manifests before testing.

Host: RTX PRO 6000 Blackwell 96 GB, active PCIe 5.0 x16, i7-14700KF, 192 GB RAM, Linux 6.8.0-138, NVIDIA 595.104.02, CUDA 13.2.51, GCC 11.4. No inference service or toolchain download ran alongside the measured GPU processes. The original service was restored afterward.

Passed

g++ -std=c++20 -O1 -g -Wall -Wextra -Werror \
  -fsanitize=address,undefined -pthread -Isrc/dsv41 \
  tests/dsv41/store_pages_test.cpp -o store-pages-test
./store-pages-test

cmake -S . -B build-cuda -G Ninja -DCMAKE_BUILD_TYPE=Release \
  -DSTRATA_ENABLE_CUDA=ON -DSTRATA_BUILD_DSV41=ON \
  -DSTRATA_BUILD_TESTS=ON -DCMAKE_CUDA_ARCHITECTURES=120 \
  -DCMAKE_CUDA_COMPILER=/usr/local/cuda-13.2/bin/nvcc \
  -DCUDAToolkit_ROOT=/usr/local/cuda-13.2 \
  -DSTRATA_GGML_DIR="$LLAMA_PINNED"
cmake --build build-cuda --target strata-dsv41 ds4_store_pages_test --parallel 4
ctest --test-dir build-cuda --output-on-failure -R '^ds4_store_pages_test$'

# ROCM_ROOT is the rocm-sdk root; ROCM_LIB_ROOT is the gfx120X library-wheel root.
export LD_LIBRARY_PATH="$ROCM_ROOT/lib:$ROCM_LIB_ROOT/lib${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}"
HIP_PLATFORM=amd HIP_COMPILER=clang HIP_RUNTIME=rocclr \
ROCM_PATH="$ROCM_ROOT" HIP_PATH="$ROCM_ROOT" \
cmake -S . -B build-hip -G Ninja -DCMAKE_BUILD_TYPE=Release \
  -DSTRATA_ENABLE_HIP=ON -DSTRATA_ENABLE_CUDA=OFF \
  -DSTRATA_BUILD_DSV41=ON -DSTRATA_BUILD_TESTS=ON \
  -DCMAKE_HIP_ARCHITECTURES=gfx1201 -DSTRATA_GGML_DIR="$LLAMA_PINNED" \
  -DCMAKE_HIP_COMPILER="$ROCM_ROOT/llvm/bin/clang++" \
  -DCMAKE_HIP_COMPILER_ROCM_ROOT="$ROCM_ROOT" \
  -DCMAKE_PREFIX_PATH="$ROCM_ROOT;$ROCM_LIB_ROOT" \
  "-DCMAKE_HIP_FLAGS=--gcc-install-dir=/usr/lib/gcc/x86_64-linux-gnu/11 --rocm-path=$ROCM_ROOT --rocm-device-lib-path=$ROCM_ROOT/lib/llvm/amdgcn/bitcode"
cmake --build build-hip --target strata-dsv41 ds4_store_pages_test --parallel 4
ctest --test-dir build-hip --output-on-failure -R '^ds4_store_pages_test$'

python3 docs/benchmarks/dsv41-pcie-20261021/recompute.py
git diff 4b9e05a2a806a3fe24f7b2560d98626c37dade35...HEAD --check
  • Linux ASan/UBSan: 10,000 layout cases, real file-to-store bytes, nonidentity mock aliases, registration failure, shrink protection, regrowth and destruction passed. The portable layout checks also passed on macOS with C++17 and C++20.
  • CUDA sm_120: complete strata-dsv41 builds for head and parent; CTest passed. The head binary SHA256 was 2319c76b2e7d56d8ef77e209500a067aca244a5b496802760c324569bc2ddf6b.
  • HIP gfx1201: complete strata-dsv41 build and CTest passed with isolated ROCm 7.10.0a20251120, AMD Clang 22.0.0git and GCC 11 headers. Binary SHA256: ff2dffeb0928258453dacf02810c276940c82f65273eee7906514f5079c8c4b9. Initial compiler detection selected an incomplete GCC 12 header tree; explicitly selecting the installed GCC 11 resolved that configuration failure. No production-source change was needed.
  • Actual CUDA registration, alias reads, lifecycle and cleanup passed in both modes. For IQ2_XS weights, 120 experts / 360 matrices across all 40 layers were checked against independent file reads through CPU, the existing production zc_stage, and CUDA H2D readback: 3,493,601,280 checked bytes per mode, zero differences. Separate 1 GiB and 4 GiB synthetic arenas passed full CPU/SM/CE byte comparisons in both modes.
  • Parent versus default-off head, and head off/on/off: 293 prompt-position logits and 32 generated tokens were byte-identical, with no NaN/Inf. This is a bounded parity check, not broad model-quality acceptance or validation of every decode-position logit.
  • The model candidate showed 116,517,765,120 bytes of actual THP backing in both measured B runs. The separate 100 GiB harness directly counted 40 registrations and 40 unregister calls.

Unprofiled model comparison

Only DeepSeek-V4.1-Flash-1017-GSQ-RCO-IQ2_XS and its paired Engram table were used. Fixed LongSWE input: 16,179 tokens; fixed output: 512 tokens; greedy seed 1234; chunk/window 8192; context 32768; DSpark/vision off; 16 CPU threads; uniform initial expert profile; prefix reuse and VRAM expert exchange off. Explicit --vram-experts 0.5 produced the same 4,693 VRAM experts and 45.65 GB expert allocation in every run. Both arms had the same 10,240 RAM slots and 116.518 GB budget.

Control A used the existing 64-slot chunks and ordinary pages (160 registration chunks). Candidate B used 256-slot chunks (40 registrations) and verified 100% THP. All other arguments and environment settings were fixed, including DS4_STORE_ZC=1, DS4_STORE_ZC_FRAC=100, DS4_STORE_PREGROW=1, DS4_STORE_RESERVE=0, DS4_STORE_BG=0, DS4_STORE_PRELOAD=1, and DS4_NO_EOS=1.

One A warmup was excluded, then ABBA ran without a profiler or logits dump:

Run Prefill token/s Decode token/s Prefill ms Decode ms
A1 1048.06 13.66 15437 37421
B1 1050.52 17.19 15401 29727
B2 1050.77 17.15 15397 29798
A2 1044.85 13.63 15485 37483

The summary divides fixed work by each arm's mean phase time. Decode counts 511 post-prefill steps for 512 outputs. All four generated token sequences were identical. B2 had two store evictions versus zero in the other runs, and slightly more demand reads; this difference is retained rather than claiming identical cache events. No failed store reads occurred. GPU-active samples were PCIe 5.0 x16; no unrelated GPU compute process appeared.

Failed / unresolved

  • An initial 140 GiB ordinary-page arena passed its CPU comparison but failed a GPU readback comparison before any candidate timing. The first assertion did not identify the path/address. Its root cause remains unresolved; further investigation was explicitly waived by the requester. The 100 GiB bandwidth-only runs therefore omitted full-arena byte validation. These measurements do not establish large-arena integrity.
  • A 140 GiB candidate obtained only 125,449,535,488 / 150,323,855,360 bytes of THP (83.45%); it was rejected before timing. The later 100 GiB synthetic and 116.518 GB model candidates met 100%.
  • Same-40-chunk synthetic A/B/A showed a tradeoff: CUDA CE H2D 23.403 → 46.048 GB/s (+96.76%), but production SM staging 22.691 → 16.021 GB/s (−29.40%). This differs from the model's combined 160-to-40-chunk comparison and is not hidden by its decode gain.

Not run

  • AMD GPU execution; HIP compilation is not an AMD runtime result.
  • Other models, multi-GPU, broad quality suites, or longer output/context acceptance.
  • Complete Nsight phase attribution: collection was stopped at the requester's direction. No kernel-level causal bottleneck claim is made.

Limits

The option stays off by default. Results cover one host, input and expert-memory configuration; the small prefill change is not evidence of a meaningful prefill improvement. THP advice is not a guarantee, and the runtime's chunk count is configurable rather than always 40. Existing historical byte-integrity failures remain unresolved.

The historical 2026-10-21 copy measurements included in this PR came from a separate experimental engine and remain separate from the current results. Their 24 timing rows, hashes and arithmetic were recomputed successfully. Historical data, provenance and limitations.


🔄 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/4286 **Author:** [@yhfgyyf](https://github.com/yhfgyyf) **Created:** 10/27/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `codex/dsv41-block-pinned-hugepages` --- ### 📝 Commits (1) - [`c10a381`](https://github.com/Niko1221/Strata/commit/c10a381ed169a651b1b565d9eeaf385606136797) [Engine] add opt-in huge pages for the DeepSeek registered RAM store ### 📊 Changes **11 files changed** (+918 additions, -9 deletions) <details> <summary>View changed files</summary> 📝 `CMakeLists.txt` (+6 -0) 📝 `docs/DEEPSEEK41.md` (+9 -0) ➕ `docs/benchmarks/dsv41-pcie-20261021/README.md` (+138 -0) ➕ `docs/benchmarks/dsv41-pcie-20261021/historical_transfer.cpp` (+121 -0) ➕ `docs/benchmarks/dsv41-pcie-20261021/measurements.csv` (+25 -0) ➕ `docs/benchmarks/dsv41-pcie-20261021/provenance.json` (+316 -0) ➕ `docs/benchmarks/dsv41-pcie-20261021/recompute.py` (+31 -0) 📝 `src/dsv41/ds4_model.cu` (+7 -0) 📝 `src/dsv41/ds4_store.hpp` (+33 -9) ➕ `src/dsv41/ds4_store_pages.hpp` (+77 -0) ➕ `tests/dsv41/store_pages_test.cpp` (+155 -0) </details> ### 📄 Description ## Problem and result The DeepSeek RAM store already registers host-memory chunks for its optional GPU zero-copy path. Its original allocator does not align those chunks to 2 MiB or request and fault huge pages before registration. This allocator observation comes from source inspection of `4b9e05a2`; it is not a claim of a reproduced upstream regression. This change adds opt-in huge-page backing on Linux CUDA, preserves the default path, and accounts for padding in the existing RAM budget. On the submitted revision, a same-day IQ2_XS comparison of the original 64-slot chunks against 40 aligned chunks with 100% THP measured **decode 13.64 → 17.17 token/s (+25.84%)**. **Prefill was effectively unchanged: 1046.44 → 1050.65 token/s (+0.40%).** These are results for the combined tested configuration, not a claim that the page-size option alone gives this gain. ## Related discussion Open and closed issues/PRs were searched before submission. #4123 covers the broader DeepSeek/Maya engine update; this PR remains limited to the existing RAM-store allocator. No maintainer scope agreement is claimed, and no default changes or broader port are included. ## Approach - Reserve one contiguous, 2 MiB-aligned arena. Commit a chunk, request `MADV_HUGEPAGE`, and fault it before the existing CUDA registration callback. - Keep complete expert slots inside a registration, include padding in the budget, and bound registrations at 4 GiB minus 2 MiB. This bound is allocation policy, not a CUDA API limit. - Preserve device aliases, registration-failure handling, pinned-reader shrink protection, regrowth and cleanup. Reservation failure falls back to the original allocator; THP backing remains best effort. - Enable with `DS4_STORE_ZC=1 DS4_STORE_HUGE_PAGES=1`; the option is off by default. The measured 40-chunk model configuration also used `DS4_STORE_CHUNK_SLOTS=256`. ## Validation Tested head: `c10a381ed169a651b1b565d9eeaf385606136797`; parent/control build: `4b9e05a2a806a3fe24f7b2560d98626c37dade35`. Both used llama.cpp `3cf03257f219afbe7334045ff7c6a06ac68c627d`. The 4,958 head source files and 4,951 parent source files were checked against the local manifests before testing. Host: RTX PRO 6000 Blackwell 96 GB, active PCIe 5.0 x16, i7-14700KF, 192 GB RAM, Linux 6.8.0-138, NVIDIA 595.104.02, CUDA 13.2.51, GCC 11.4. No inference service or toolchain download ran alongside the measured GPU processes. The original service was restored afterward. ### Passed ```sh g++ -std=c++20 -O1 -g -Wall -Wextra -Werror \ -fsanitize=address,undefined -pthread -Isrc/dsv41 \ tests/dsv41/store_pages_test.cpp -o store-pages-test ./store-pages-test cmake -S . -B build-cuda -G Ninja -DCMAKE_BUILD_TYPE=Release \ -DSTRATA_ENABLE_CUDA=ON -DSTRATA_BUILD_DSV41=ON \ -DSTRATA_BUILD_TESTS=ON -DCMAKE_CUDA_ARCHITECTURES=120 \ -DCMAKE_CUDA_COMPILER=/usr/local/cuda-13.2/bin/nvcc \ -DCUDAToolkit_ROOT=/usr/local/cuda-13.2 \ -DSTRATA_GGML_DIR="$LLAMA_PINNED" cmake --build build-cuda --target strata-dsv41 ds4_store_pages_test --parallel 4 ctest --test-dir build-cuda --output-on-failure -R '^ds4_store_pages_test$' # ROCM_ROOT is the rocm-sdk root; ROCM_LIB_ROOT is the gfx120X library-wheel root. export LD_LIBRARY_PATH="$ROCM_ROOT/lib:$ROCM_LIB_ROOT/lib${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}" HIP_PLATFORM=amd HIP_COMPILER=clang HIP_RUNTIME=rocclr \ ROCM_PATH="$ROCM_ROOT" HIP_PATH="$ROCM_ROOT" \ cmake -S . -B build-hip -G Ninja -DCMAKE_BUILD_TYPE=Release \ -DSTRATA_ENABLE_HIP=ON -DSTRATA_ENABLE_CUDA=OFF \ -DSTRATA_BUILD_DSV41=ON -DSTRATA_BUILD_TESTS=ON \ -DCMAKE_HIP_ARCHITECTURES=gfx1201 -DSTRATA_GGML_DIR="$LLAMA_PINNED" \ -DCMAKE_HIP_COMPILER="$ROCM_ROOT/llvm/bin/clang++" \ -DCMAKE_HIP_COMPILER_ROCM_ROOT="$ROCM_ROOT" \ -DCMAKE_PREFIX_PATH="$ROCM_ROOT;$ROCM_LIB_ROOT" \ "-DCMAKE_HIP_FLAGS=--gcc-install-dir=/usr/lib/gcc/x86_64-linux-gnu/11 --rocm-path=$ROCM_ROOT --rocm-device-lib-path=$ROCM_ROOT/lib/llvm/amdgcn/bitcode" cmake --build build-hip --target strata-dsv41 ds4_store_pages_test --parallel 4 ctest --test-dir build-hip --output-on-failure -R '^ds4_store_pages_test$' python3 docs/benchmarks/dsv41-pcie-20261021/recompute.py git diff 4b9e05a2a806a3fe24f7b2560d98626c37dade35...HEAD --check ``` - Linux ASan/UBSan: 10,000 layout cases, real file-to-store bytes, nonidentity mock aliases, registration failure, shrink protection, regrowth and destruction passed. The portable layout checks also passed on macOS with C++17 and C++20. - CUDA `sm_120`: complete `strata-dsv41` builds for head and parent; CTest passed. The head binary SHA256 was `2319c76b2e7d56d8ef77e209500a067aca244a5b496802760c324569bc2ddf6b`. - HIP `gfx1201`: complete `strata-dsv41` build and CTest passed with isolated ROCm `7.10.0a20251120`, AMD Clang 22.0.0git and GCC 11 headers. Binary SHA256: `ff2dffeb0928258453dacf02810c276940c82f65273eee7906514f5079c8c4b9`. Initial compiler detection selected an incomplete GCC 12 header tree; explicitly selecting the installed GCC 11 resolved that configuration failure. No production-source change was needed. - Actual CUDA registration, alias reads, lifecycle and cleanup passed in both modes. For IQ2_XS weights, 120 experts / 360 matrices across all 40 layers were checked against independent file reads through CPU, the existing production `zc_stage`, and CUDA H2D readback: 3,493,601,280 checked bytes per mode, zero differences. Separate 1 GiB and 4 GiB synthetic arenas passed full CPU/SM/CE byte comparisons in both modes. - Parent versus default-off head, and head off/on/off: 293 prompt-position logits and 32 generated tokens were byte-identical, with no NaN/Inf. This is a bounded parity check, not broad model-quality acceptance or validation of every decode-position logit. - The model candidate showed 116,517,765,120 bytes of actual THP backing in both measured B runs. The separate 100 GiB harness directly counted 40 registrations and 40 unregister calls. ### Unprofiled model comparison Only **DeepSeek-V4.1-Flash-1017-GSQ-RCO-IQ2_XS** and its paired Engram table were used. Fixed LongSWE input: 16,179 tokens; fixed output: 512 tokens; greedy seed 1234; chunk/window 8192; context 32768; DSpark/vision off; 16 CPU threads; uniform initial expert profile; prefix reuse and VRAM expert exchange off. Explicit `--vram-experts 0.5` produced the same 4,693 VRAM experts and 45.65 GB expert allocation in every run. Both arms had the same 10,240 RAM slots and 116.518 GB budget. Control A used the existing 64-slot chunks and ordinary pages (160 registration chunks). Candidate B used 256-slot chunks (40 registrations) and verified 100% THP. All other arguments and environment settings were fixed, including `DS4_STORE_ZC=1`, `DS4_STORE_ZC_FRAC=100`, `DS4_STORE_PREGROW=1`, `DS4_STORE_RESERVE=0`, `DS4_STORE_BG=0`, `DS4_STORE_PRELOAD=1`, and `DS4_NO_EOS=1`. One A warmup was excluded, then ABBA ran without a profiler or logits dump: | Run | Prefill token/s | Decode token/s | Prefill ms | Decode ms | | --- | ---: | ---: | ---: | ---: | | A1 | 1048.06 | 13.66 | 15437 | 37421 | | B1 | 1050.52 | 17.19 | 15401 | 29727 | | B2 | 1050.77 | 17.15 | 15397 | 29798 | | A2 | 1044.85 | 13.63 | 15485 | 37483 | The summary divides fixed work by each arm's mean phase time. Decode counts 511 post-prefill steps for 512 outputs. All four generated token sequences were identical. B2 had two store evictions versus zero in the other runs, and slightly more demand reads; this difference is retained rather than claiming identical cache events. No failed store reads occurred. GPU-active samples were PCIe 5.0 x16; no unrelated GPU compute process appeared. ### Failed / unresolved - An initial 140 GiB ordinary-page arena passed its CPU comparison but failed a GPU readback comparison before any candidate timing. The first assertion did not identify the path/address. Its root cause remains unresolved; further investigation was explicitly waived by the requester. The 100 GiB bandwidth-only runs therefore omitted full-arena byte validation. These measurements do **not** establish large-arena integrity. - A 140 GiB candidate obtained only 125,449,535,488 / 150,323,855,360 bytes of THP (83.45%); it was rejected before timing. The later 100 GiB synthetic and 116.518 GB model candidates met 100%. - Same-40-chunk synthetic A/B/A showed a tradeoff: CUDA CE H2D **23.403 → 46.048 GB/s (+96.76%)**, but production SM staging **22.691 → 16.021 GB/s (−29.40%)**. This differs from the model's combined 160-to-40-chunk comparison and is not hidden by its decode gain. ### Not run - AMD GPU execution; HIP compilation is not an AMD runtime result. - Other models, multi-GPU, broad quality suites, or longer output/context acceptance. - Complete Nsight phase attribution: collection was stopped at the requester's direction. No kernel-level causal bottleneck claim is made. ## Limits The option stays off by default. Results cover one host, input and expert-memory configuration; the small prefill change is not evidence of a meaningful prefill improvement. THP advice is not a guarantee, and the runtime's chunk count is configurable rather than always 40. Existing historical byte-integrity failures remain unresolved. The historical 2026-10-21 copy measurements included in this PR came from a separate experimental engine and remain separate from the current results. Their 24 timing rows, hashes and arithmetic were recomputed successfully. [Historical data, provenance and limitations](https://github.com/yhfgyyf/Strata/blob/c10a381ed169a651b1b565d9eeaf385606136797/docs/benchmarks/dsv41-pcie-20261021/README.md). --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
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#4986
No description provided.