[PR #523] [CLOSED] DeepSeek: budget parked conversation RAM by bytes #578

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

📋 Pull Request Information

Original PR: https://github.com/mw00/project-maya/pull/523
Author: @handmade0octopus
Created: 10/26/2026
Status: ❌ Closed

Base: main ← Head: pr/ds4-slot-ram-budget


📝 Commits (1)

  • b4bdbc6 DeepSeek: budget parked conversation RAM by bytes

📊 Changes

4 files changed (+52 additions, -5 deletions)

View changed files

📝 README.md (+1 -0)
📝 docs/SETTINGS.md (+1 -0)
📝 serve/server.py (+4 -0)
📝 src/ds4/ds4_main.cpp (+46 -5)

📄 Description

Summary

Add an optional byte budget for DeepSeek conversations parked in RAM:

MAYA_DS4_SLOT_RAM_GB=8

(STRATA_DS4_SLOT_RAM_GB is the engine-side name.)

The existing SLOT_CAP limits the number of RAM conversations, but their states vary widely in size. The new budget additionally limits their actual payload bytes. When either limit is exceeded, the least recently used RAM state spills to the existing slot folder and can later be restored with its token prefix intact.

  • Default 0 preserves the existing count-limited behavior; invalid, non-finite, negative, or out-of-range values also fall back to 0 with a diagnostic.
  • This is a post-save/steady-state cap: the incoming state is serialized before old states spill, so peak memory can temporarily include old parked states plus the incoming state. It is not a preallocation hard cap.
  • The count cap, folder byte cap, file format, and eviction policy are otherwise unchanged.
  • One RAM conversation is retained even if it alone exceeds the byte budget, so the active/most-recent conversation is not forced out merely because of its size.
  • STAT now exposes slot_ram, slot_disk, slot_ram_bytes, and slot_ram_cap, with matching Monitor metric descriptions.

Benefits

Agent sessions can interleave many conversations whose parked states range from small to multiple GiB. A byte cap makes steady-state parked RAM use predictable while retaining the existing fast disk-restore path, instead of relying on a conversation count as a proxy for memory. Slot telemetry is emitted only while slots are enabled.

Validation

Windows CUDA / DeepSeek-V4.1-Flash IQ1_M:

  • Forced an artificial 1,073-byte RAM cap with three 1,536-token conversations.
  • Final placement: 1 RAM + 2 disk states; the one retained RAM state was allowed to exceed the artificial cap.
  • Returning to conversation A loaded its state from the folder and reused exactly 1,543 tokens, with only 33 new tokens read.
  • Folder .bin/.meta counts and the reported byte/cap counters matched the expected state.
  • A separate negative-budget run safely logged the fallback to 0; with slots disabled, the request succeeded and no slot_ram* fields were emitted.
  • A separate 159-context agent-style soak completed successfully. Its 32-conversation count cap produced 32 RAM + 127 disk states; revisiting the first context reused 8,221 tokens and loaded from disk in 0.671 s.
  • The production-sized 8 GiB byte cap was not reached by that soak, so the forced tiny-cap test above is the direct byte-eviction test.
  • Windows CUDA build and HIP name-compatibility scan pass. After a clean v1.1.29 rebase, the full 101-test server suite passed (3 platform skips), along with the 32-test DS4 conformance and slot helper tests. No AMD or multi-GPU runtime claim is made.

This extends the DeepSeek conversation storage added in #356; it does not reimplement slots or change their serialization. Picture-support PRs such as #429/#462 are orthogonal, although this code should be rebased with whichever lands first. The merged GLM RAM-slot work in #236 is a conceptual precedent, not a duplicate: this PR adds a RAM byte budget and LRU spill accounting to the existing DeepSeek RAM+disk slot implementation rather than changing to RAM-only transport.


🔄 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/523 **Author:** [@handmade0octopus](https://github.com/handmade0octopus) **Created:** 10/26/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `pr/ds4-slot-ram-budget` --- ### 📝 Commits (1) - [`b4bdbc6`](https://github.com/mw00/project-maya/commit/b4bdbc629b5e0b80d4d2b607cacd2cf24b18a657) DeepSeek: budget parked conversation RAM by bytes ### 📊 Changes **4 files changed** (+52 additions, -5 deletions) <details> <summary>View changed files</summary> 📝 `README.md` (+1 -0) 📝 `docs/SETTINGS.md` (+1 -0) 📝 `serve/server.py` (+4 -0) 📝 `src/ds4/ds4_main.cpp` (+46 -5) </details> ### 📄 Description ## Summary Add an optional **byte budget** for DeepSeek conversations parked in RAM: ```text MAYA_DS4_SLOT_RAM_GB=8 ``` (`STRATA_DS4_SLOT_RAM_GB` is the engine-side name.) The existing `SLOT_CAP` limits the number of RAM conversations, but their states vary widely in size. The new budget additionally limits their actual payload bytes. When either limit is exceeded, the least recently used RAM state spills to the existing slot folder and can later be restored with its token prefix intact. - Default `0` preserves the existing count-limited behavior; invalid, non-finite, negative, or out-of-range values also fall back to `0` with a diagnostic. - This is a **post-save/steady-state** cap: the incoming state is serialized before old states spill, so peak memory can temporarily include old parked states plus the incoming state. It is not a preallocation hard cap. - The count cap, folder byte cap, file format, and eviction policy are otherwise unchanged. - One RAM conversation is retained even if it alone exceeds the byte budget, so the active/most-recent conversation is not forced out merely because of its size. - `STAT` now exposes `slot_ram`, `slot_disk`, `slot_ram_bytes`, and `slot_ram_cap`, with matching Monitor metric descriptions. ## Benefits Agent sessions can interleave many conversations whose parked states range from small to multiple GiB. A byte cap makes steady-state parked RAM use predictable while retaining the existing fast disk-restore path, instead of relying on a conversation count as a proxy for memory. Slot telemetry is emitted only while slots are enabled. ## Validation Windows CUDA / DeepSeek-V4.1-Flash IQ1_M: - Forced an artificial **1,073-byte** RAM cap with three 1,536-token conversations. - Final placement: **1 RAM + 2 disk** states; the one retained RAM state was allowed to exceed the artificial cap. - Returning to conversation A loaded its state from the folder and reused exactly **1,543 tokens**, with only **33 new tokens** read. - Folder `.bin`/`.meta` counts and the reported byte/cap counters matched the expected state. - A separate negative-budget run safely logged the fallback to `0`; with slots disabled, the request succeeded and no `slot_ram*` fields were emitted. - A separate 159-context agent-style soak completed successfully. Its 32-conversation count cap produced 32 RAM + 127 disk states; revisiting the first context reused **8,221 tokens** and loaded from disk in **0.671 s**. - The production-sized 8 GiB byte cap was not reached by that soak, so the forced tiny-cap test above is the direct byte-eviction test. - Windows CUDA build and HIP name-compatibility scan pass. After a clean v1.1.29 rebase, the full 101-test server suite passed (3 platform skips), along with the 32-test DS4 conformance and slot helper tests. No AMD or multi-GPU runtime claim is made. ## Related work / overlap check This extends the DeepSeek conversation storage added in #356; it does not reimplement slots or change their serialization. Picture-support PRs such as #429/#462 are orthogonal, although this code should be rebased with whichever lands first. The merged GLM RAM-slot work in #236 is a conceptual precedent, not a duplicate: this PR adds a RAM byte budget and LRU spill accounting to the existing DeepSeek RAM+disk slot implementation rather than changing to RAM-only transport. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-29 21:27:07 +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#578
No description provided.