mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[PR #5530] [Engine] add independent weight and context memory locking to Core an… #5505
Labels
No labels
needs-format
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Niko1221/Strata#5505
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/Niko1221/Strata/pull/5530
Author: @satakecode
Created: 11/7/2026
Status: 🔄 Open
Base:
main← Head:main📝 Commits (1)
827d55a[Engine] add independent weight and context memory locking to Core and DS4📊 Changes
48 files changed (+3007 additions, -212 deletions)
View changed files
📝
CMakeLists.txt(+121 -0)📝
docs/DETAILS.md(+4 -1)➕
docs/DS4_MEMORY_LOCKING.md(+341 -0)➕
include/strata/core/checkpoint_allocation.hpp(+108 -0)📝
include/strata/core/conversation_buffer.hpp(+15 -5)📝
include/strata/core/conversation_cache.hpp(+31 -18)📝
include/strata/core/conversation_file.hpp(+3 -2)📝
include/strata/core/conversation_snapshot.hpp(+18 -7)📝
include/strata/core/expert_source.hpp(+7 -1)➕
include/strata/core/memory_policy.hpp(+108 -0)📝
include/strata/core/native_head.hpp(+3 -0)📝
include/strata/core/pinned.hpp(+8 -0)📝
include/strata/platform/memory.hpp(+1 -0)➕
include/strata/platform/memory_lock.hpp(+298 -0)📝
src/core/conversation_cache_test.cpp(+35 -8)📝
src/core/conversation_copy.hpp(+8 -5)📝
src/core/conversation_file.cpp(+23 -5)📝
src/core/conversation_file_test.cpp(+25 -1)📝
src/core/conversation_snapshot.cpp(+12 -1)📝
src/core/conversation_snapshot_test.cpp(+23 -3)...and 28 more files
📄 Description
Problem and result
Under memory pressure, pageable CPU model weights can be swapped out, causing inference stalls when those weights are needed again.
This change adds independent controls for locking eligible CPU weights and host context/checkpoint storage. Users can request weight residency without adding locks to ordinary conversation payloads.
All new controls default to off. Unset or
0preserves existing behavior, including legacy locking and GPU-required host pinning.Related discussion
None
Approach
Each engine has independent settings:
STRATA_MLOCK_WEIGHTSSTRATA_MLOCK_CONTEXTDS4_MLOCK_WEIGHTSDS4_MLOCK_CONTEXTSet a variable to
1to request locking for that category. The engines do not read each other’s settings.The implementation uses allocation-scoped Linux
mlock()/munlock(), with overlapping-page ownership tracking, cleanup and engine/category diagnostics. Optional lock failures are reported without terminating otherwise-viable inference.Coverage includes eligible Core CPU weight storage and DS4 anonymous expert storage used with
--mmap-experts off. Context locking covers eligible host checkpoint and conversation payloads.Supporting changes handle allocation growth, checkpoint admission and rollback, and synchronized publication of DS4 prepared storage. Expensive preparation stays outside demand inference paths.
Difference from
STRATA_ARENA_LOCKSTRATA_ARENA_LOCKcontrols legacy optional locking of Core’s CPU expert arena, particularly portions not already GPU-pinned.STRATA_MLOCK_WEIGHTScovers broader eligible CPU weight storage: expert arenas, resident/exchange buffers, mapped weights, host embeddings/output heads and PLE storage.STRATA_MLOCK_WEIGHTSunset or0STRATA_ARENA_LOCKSTRATA_MLOCK_WEIGHTS=1STRATA_ARENA_LOCK=0Neither setting controls context locking, removes GPU-required pinning or configures DS4.
New enabled locking paths do not raise resource limits. The legacy mapped-PLE soft-limit increase remains on its compatibility path, bounded by the existing hard limit.
Validation
The automated results below were reported by the implementation agent. Hardware testing was reported by the contributor. Exact commands, tested revision and log attachments were not supplied with these summaries.
Passed:
Failed:
Not run:
Limits
RLIMIT_MEMLOCK. Swap does not increase lockable capacity.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.