[PR #492] [CLOSED] DeepSeek: account for reclaimable ZFS ARC when sizing RAM #565

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

📋 Pull Request Information

Original PR: https://github.com/mw00/project-maya/pull/492
Author: @saltacc
Created: 10/25/2026
Status: ❌ Closed

Base: main ← Head: fix/ds4-zfs-arc-memory


📝 Commits (1)

  • 79f2989 DeepSeek: include reclaimable ZFS ARC in RAM budgets

📊 Changes

2 files changed (+142 additions, -1 deletions)

View changed files

📝 src/ds4/ds4_model.cu (+24 -1)
➕ tools/test_ds4_ram_avail.py (+118 -0)

📄 Description

On Linux with ZFS, DeepSeek's ram_avail() uses MemAvailable without accounting for reclaimable ARC. After model reads fill the ARC, this understates the RAM available for expert warmup. Maya's Python setup already accounts for ARC, but the DeepSeek engine does not.

Read size and c_min from /proc/spl/kstat/zfs/arcstats and add max(size - c_min, 0) to known MemAvailable. Bound the addition by MemTotal without overflowing, then apply the existing cgroup v2 limits, including ancestor limits. Missing or incomplete ARC statistics contribute zero; unknown host availability retains its existing sentinel.

The change is confined to the DeepSeek memory estimate and a host-only regression test. Related background: #89. This is separate from the optional direct-I/O/cache-release controls in #421.

Measurements

Startup observations before and after applying this patch to v1.1.28, with the same DeepSeek Maya-XS IQ1_S configuration at 131072 context:

Engine startup budget Stock With ARC accounting
Available RAM estimate 43.3 GB 57.6 GB
Expert warmup budget 34.68 GB 49.03 GB

Hardware: i9-14900K, 64 GiB installed RAM, RTX 4090 24 GiB, CachyOS, OpenZFS 2.4.4 on a two-NVMe mirror. Values above use the engine's decimal GB units. ARC occupancy differed between starts; these observations describe startup sizing, not a controlled throughput comparison.

The same-input host harness also compares the stock and patched functions directly: with 8 GiB MemAvailable, 16 GiB ARC and a 2 GiB ARC floor, the estimate changes from 8 to 22 GiB. Adding a cgroup with 2 GiB headroom caps both versions at 2 GiB.

Validation

  • The new CPU-only test compiles the actual engine helpers and checks 19 scenarios: absent/incomplete ARC stats, the ARC floor, physical-RAM and overflow bounds, unknown host availability, and cgroup/ancestor limits. Passed on macOS and Linux.
  • python tools/check_hip_compat.py passed.
  • python -m unittest discover -s serve -p 'test_*.py' -t .: 366 tests, passed (11 skipped), macOS.
  • python -m unittest discover -s tools -p 'test_*.py': 395 tests, passed (28 skipped), Linux. The full tools suite uses Linux-specific setup checks; an initial macOS run encountered environment failures (/proc, missing cmake, and temporary-path canonicalization).
  • The identical helper bodies were built with CUDA 13.4.3 for sm_89 and run on the RTX 4090. Health, arithmetic and counting smoke requests passed at 131072 context, with no cgroup OOM events. Token-for-token numerical parity was not measured.
  • git diff --check passed.

🔄 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/492 **Author:** [@saltacc](https://github.com/saltacc) **Created:** 10/25/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `fix/ds4-zfs-arc-memory` --- ### 📝 Commits (1) - [`79f2989`](https://github.com/mw00/project-maya/commit/79f2989ba23d962f4efed929f410b9d9f638d84b) DeepSeek: include reclaimable ZFS ARC in RAM budgets ### 📊 Changes **2 files changed** (+142 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `src/ds4/ds4_model.cu` (+24 -1) ➕ `tools/test_ds4_ram_avail.py` (+118 -0) </details> ### 📄 Description On Linux with ZFS, DeepSeek's `ram_avail()` uses `MemAvailable` without accounting for reclaimable ARC. After model reads fill the ARC, this understates the RAM available for expert warmup. Maya's Python setup already accounts for ARC, but the DeepSeek engine does not. Read `size` and `c_min` from `/proc/spl/kstat/zfs/arcstats` and add `max(size - c_min, 0)` to known `MemAvailable`. Bound the addition by `MemTotal` without overflowing, then apply the existing cgroup v2 limits, including ancestor limits. Missing or incomplete ARC statistics contribute zero; unknown host availability retains its existing sentinel. The change is confined to the DeepSeek memory estimate and a host-only regression test. Related background: #89. This is separate from the optional direct-I/O/cache-release controls in #421. ### Measurements Startup observations before and after applying this patch to v1.1.28, with the same DeepSeek Maya-XS IQ1_S configuration at 131072 context: | Engine startup budget | Stock | With ARC accounting | | --- | ---: | ---: | | Available RAM estimate | 43.3 GB | 57.6 GB | | Expert warmup budget | 34.68 GB | 49.03 GB | Hardware: i9-14900K, 64 GiB installed RAM, RTX 4090 24 GiB, CachyOS, OpenZFS 2.4.4 on a two-NVMe mirror. Values above use the engine's decimal GB units. ARC occupancy differed between starts; these observations describe startup sizing, not a controlled throughput comparison. The same-input host harness also compares the stock and patched functions directly: with 8 GiB `MemAvailable`, 16 GiB ARC and a 2 GiB ARC floor, the estimate changes from 8 to 22 GiB. Adding a cgroup with 2 GiB headroom caps both versions at 2 GiB. ### Validation - The new CPU-only test compiles the actual engine helpers and checks 19 scenarios: absent/incomplete ARC stats, the ARC floor, physical-RAM and overflow bounds, unknown host availability, and cgroup/ancestor limits. Passed on macOS and Linux. - `python tools/check_hip_compat.py` passed. - `python -m unittest discover -s serve -p 'test_*.py' -t .`: 366 tests, passed (11 skipped), macOS. - `python -m unittest discover -s tools -p 'test_*.py'`: 395 tests, passed (28 skipped), Linux. The full tools suite uses Linux-specific setup checks; an initial macOS run encountered environment failures (`/proc`, missing `cmake`, and temporary-path canonicalization). - The identical helper bodies were built with CUDA 13.4.3 for `sm_89` and run on the RTX 4090. Health, arithmetic and counting smoke requests passed at 131072 context, with no cgroup OOM events. Token-for-token numerical parity was not measured. - `git diff --check` passed. --- <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:56 +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#565
No description provided.