[PR #421] [CLOSED] DeepSeek: add opt-in cache release and direct I/O for RAM expert copies #521

Closed
opened 2026-10-29 21:26:21 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/mw00/project-maya/pull/421
Author: @tctiger
Created: 10/23/2026
Status: ❌ Closed

Base: main ← Head: deepseek-expert-copy-cache-io


📝 Commits (2)

  • 6addc1b DeepSeek: add opt-in cache release and direct I/O for RAM expert copies
  • c6969bd Merge branch 'mw00:main' into deepseek-expert-copy-cache-io

📊 Changes

6 files changed (+199 additions, -4 deletions)

View changed files

📝 README.md (+13 -0)
📝 docs/SETTINGS.md (+32 -0)
📝 src/ds4/ds4_model.cu (+38 -4)
📝 src/ds4/ds4_os.hpp (+35 -0)
➕ tests/ds4_copy_cache.cpp (+58 -0)
➕ tools/test_ds4_copy_cache.py (+23 -0)

📄 Description

This adds two opt-in Linux controls to reduce duplicate file-cache memory while copying DeepSeek GGUF CPU experts into RAM.

Changes

  • DS4_COPY_DROP_CACHE=1: after an expert's matrices and NUMA parts have copied successfully, issue POSIX_FADV_DONTNEED for complete source pages. Partial boundary pages are retained. Eviction is advisory.
  • DS4_COPY_DIRECT=1: use direct I/O with reusable aligned staging buffers, then copy the exact bytes into the NUMA destinations. Unsupported or failed direct reads fall back to buffered reads, with byte counts reported in the startup log.

Both options default off. They do not change routing, tensor arithmetic, Engram reads or installer defaults. No global cache clearing, memory compaction or ZFS changes are included in this patch.

Measurements

Tested on Linux with one NVIDIA A40, two Xeon Gold 5218 CPUs, 750 GiB RAM, two NUMA nodes and a Samsung NVMe SSD using XFS.

Model: DeepSeek-V4.1-Flash-1017 Kiwimaker abliterated UD-Q8_K_XL, 1M configured context, DSpark enabled. All 14,417 CPU experts (271 GB) were copied into RAM, and both Engram tables (202.758 GB) were locked.

Both modes used the same patched v1.1.24 executable. Each cold load used the same external cache-clearing and memory-preparation procedure, which is not part of this patch.

Metric Buffered copy + cache release Direct I/O
Expert-copy stage 103.2 s 103.9 s
Model loading, excluding preparation 234 s 239 s
External preparation 18.30 s 3.97 s
Generation, median of three 256-token runs 28.0 tok/s 27.5 tok/s

Direct I/O read 271.049 GB with zero buffered fallback. Cache-release mode issued accepted hints for 270.872 GB; this is not a measurement of bytes actually evicted.

A preceding same-day run without either control took 432 s to load, including 291.4 s copying experts. This is a reference observation, not a repeated matched-binary default/on benchmark.

Direct I/O did not clearly outperform buffered reads with cache release. The main observed benefit was avoiding source-cache accumulation and the severe slowdown near the end of loading.

Validation

  • Both full-model loads completed with all CPU experts in RAM, both Engram tables locked and process Swap=0.
  • Arithmetic and streamed generation requests succeeded.
  • Linux CPU tests passed: copied-byte equality, split destination buffers, boundary alignment, invalid descriptors, overflow, unaligned direct reads, EOF handling and buffered fallback.
  • The current-main submission passed a separate CUDA sm_86 build and dynamic-library checks.
  • Server suite: 352 tests passed, 10 skipped.
  • Tools suite: 389 tests passed, 28 skipped.
  • HIP CUDA-name mapping and git diff checks passed.

Windows/HIP runtime, multi-GPU/V100 validation, repeated reversed-order loading pairs and full-model token parity were not tested. Generated token sequences differed between runs; no bit-for-bit generation parity claim is made.


🔄 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/mw00/project-maya/pull/421 **Author:** [@tctiger](https://github.com/tctiger) **Created:** 10/23/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `deepseek-expert-copy-cache-io` --- ### 📝 Commits (2) - [`6addc1b`](https://github.com/mw00/project-maya/commit/6addc1b470f22201e5de0f89b64bbe35c33338ed) DeepSeek: add opt-in cache release and direct I/O for RAM expert copies - [`c6969bd`](https://github.com/mw00/project-maya/commit/c6969bd01c07b81776baea7c983c2a34cac6c3cc) Merge branch 'mw00:main' into deepseek-expert-copy-cache-io ### 📊 Changes **6 files changed** (+199 additions, -4 deletions) <details> <summary>View changed files</summary> 📝 `README.md` (+13 -0) 📝 `docs/SETTINGS.md` (+32 -0) 📝 `src/ds4/ds4_model.cu` (+38 -4) 📝 `src/ds4/ds4_os.hpp` (+35 -0) ➕ `tests/ds4_copy_cache.cpp` (+58 -0) ➕ `tools/test_ds4_copy_cache.py` (+23 -0) </details> ### 📄 Description This adds two opt-in Linux controls to reduce duplicate file-cache memory while copying DeepSeek GGUF CPU experts into RAM. ## Changes - `DS4_COPY_DROP_CACHE=1`: after an expert's matrices and NUMA parts have copied successfully, issue POSIX_FADV_DONTNEED for complete source pages. Partial boundary pages are retained. Eviction is advisory. - `DS4_COPY_DIRECT=1`: use direct I/O with reusable aligned staging buffers, then copy the exact bytes into the NUMA destinations. Unsupported or failed direct reads fall back to buffered reads, with byte counts reported in the startup log. Both options default off. They do not change routing, tensor arithmetic, Engram reads or installer defaults. No global cache clearing, memory compaction or ZFS changes are included in this patch. ## Measurements Tested on Linux with one NVIDIA A40, two Xeon Gold 5218 CPUs, 750 GiB RAM, two NUMA nodes and a Samsung NVMe SSD using XFS. Model: DeepSeek-V4.1-Flash-1017 Kiwimaker abliterated UD-Q8_K_XL, 1M configured context, DSpark enabled. All 14,417 CPU experts (271 GB) were copied into RAM, and both Engram tables (202.758 GB) were locked. Both modes used the same patched v1.1.24 executable. Each cold load used the same external cache-clearing and memory-preparation procedure, which is not part of this patch. | Metric | Buffered copy + cache release | Direct I/O | |---|---:|---:| | Expert-copy stage | 103.2 s | 103.9 s | | Model loading, excluding preparation | 234 s | 239 s | | External preparation | 18.30 s | 3.97 s | | Generation, median of three 256-token runs | 28.0 tok/s | 27.5 tok/s | Direct I/O read 271.049 GB with zero buffered fallback. Cache-release mode issued accepted hints for 270.872 GB; this is not a measurement of bytes actually evicted. A preceding same-day run without either control took 432 s to load, including 291.4 s copying experts. This is a reference observation, not a repeated matched-binary default/on benchmark. Direct I/O did not clearly outperform buffered reads with cache release. The main observed benefit was avoiding source-cache accumulation and the severe slowdown near the end of loading. ## Validation - Both full-model loads completed with all CPU experts in RAM, both Engram tables locked and process Swap=0. - Arithmetic and streamed generation requests succeeded. - Linux CPU tests passed: copied-byte equality, split destination buffers, boundary alignment, invalid descriptors, overflow, unaligned direct reads, EOF handling and buffered fallback. - The current-main submission passed a separate CUDA sm_86 build and dynamic-library checks. - Server suite: 352 tests passed, 10 skipped. - Tools suite: 389 tests passed, 28 skipped. - HIP CUDA-name mapping and git diff checks passed. Windows/HIP runtime, multi-GPU/V100 validation, repeated reversed-order loading pairs and full-model token parity were not tested. Generated token sequences differed between runs; no bit-for-bit generation parity claim is made. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-29 21:26:21 +07:00
Sign in to join this conversation.
No labels
pull-request
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
mw00/project-maya#521
No description provided.