mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[PR #3711] [Engine] reuse warm pages for slot copies and superseded parks #4757
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#4757
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/3711
Author: @yoggsaron010-lang
Created: 10/22/2026
Status: 🔄 Open
Base:
main← Head:engine/reuse-warm-kv-pages📝 Commits (1)
36b01d3engine: reuse warm pages for slot copies and superseded parks (#3321)📊 Changes
5 files changed (+263 additions, -49 deletions)
View changed files
📝
include/strata/core/conversation_buffer.hpp(+25 -1)📝
include/strata/core/conversation_cache.hpp(+68 -18)📝
src/core/conversation_cache_test.cpp(+63 -0)📝
src/program/generate.cpp(+61 -16)📝
sycl/src/program/generate.cpp(+46 -14)📄 Description
Problem and scope
The host slot-shuttle path created and discarded a fresh
ConversationKvfor every QSA layer. #3321 reports a fresh-page-fault/pinning cost on that path. This change retains one host image per stage/layer, and moves K/V buffers from an otherwise superseded parked entry into the next capture instead of freeing and reallocating them. It also requestsMADV_HUGEPAGEfor new Linux buffer segments.Credit for the diagnosis and proposed changes: @wannagoxuf in #3321. #3742 addresses the complementary per-stage parallel copies. The simulation and production speedups in that issue are the reporter's measurements, not measurements of this PR.
Behavior and compatibility
STRATA_SLOT_SHUTTLE=0restores fresh host slot images. This is buffer reuse, not pinned allocation or a reduction in transferred payload.drop_supersededcheckpoint-chain rule; guarded donors stay parked. Harvested buffers useunchanged_tokens=0: every payload byte is recopied. The upstream snapshot API requires state provenance and rewrite tracking before trusting an unchanged prefix; equal token IDs alone are not its contract. The prefix-rule discussion is in #3321.Latest validation — 2026-10-24
PR head:
36b01d3723e1204a6cc30f84e404cbbf5adfbac8; unchanged upstream baseline:011c9e600a93bbc9fd451c563501b5831c32bbca. No PR code was changed for this verification.Windows HIP build and targeted tests: passed
Windows 11, RX 6750 GRE 12GB (gfx1031), 31.2 GiB RAM; ROCm
10.2.0a20260930, AMD clang 24, VS 2022 Build Tools, CMake 4.4.3 and Ninja 1.13.2. Both the PR and the unchanged baseline engine were built with the same configuration: HIP/gfx1031, native experts, portable CPU baseline, prompt MMQ enabled, pinned ggml3cf03257f219afbe7334045ff7c6a06ac68c627d.This new targeted build needed no source patches, including no
hc_persist_parity.cppshim. Both builds exited 0. It is not an all-target build.All three targeted tests passed, zero skips, including the GPU snapshot test. This does not supersede the historical full-suite failures below.
Real-model superseded-park harvest and restore: passed
Native stdin protocol, two private engine processes run sequentially. Both use the same IQ2_XS files, token inputs and settings:
--mmap-experts --max-context 2048 --kv int8 --spec 2 --mtp-max-t 1 --suffix-draft 0 --adapt-swaps 0 --prefill 256 --batch 2 --prompt-cache 6 --prompt-cache-root 0 --prompt-cache-every 0 --conversation-cache-mib 1536 --conversation-cache-slots 4 --conversation-cache-min-free-mib 2560 --expert-cache 1800 --vram-reserve-mib 1024, without MTP. Both report 1874 sized expert slots.STRATA_STATE_HASH=1records main-model state fingerprints.Sequence: admit A into a slot; switch to B to park A; re-render the assistant turn so A1 restores the slot's turn checkpoint; switch to C to supersede/harvest old A; restore captured A1 to continue as A2; switch away and exercise a checkpoint rewind.
Observed in the PR run:
The
0 MiBlog is rounded down: the short-chat K/V allocation is below 1 MiB, not empty. The harvested payload is recopied, soreused_kv_bytes=0is expected for that capture.All 7/7 request output-token sequences and all 7/7 main-model state fingerprints match the unchanged upstream baseline with the same cache settings. This covers the harvested capture's subsequent restore and checkpoint rewind, not just the log marker. Raw protocol stdout, engine stderr, input/output IDs, fingerprints and SHA-256 manifests are retained locally with the harness.
Unsuccessful attempts are retained separately:
These are short correctness runs, not a throughput A/B. Sequential warm-cache effects make their timing unsuitable for a speedup claim.
Linux buffer and huge-page advice: passed
Own-fork workflow and downloadable evidence, validation commit
6e312d3(only workflow/test files added; diff of engine sources against this PR is empty).Ubuntu 24.04 runner, g++ C++20.
conversation_cache_test: 4785 checks passed; split allocation-failure test passed.stracerecordedmadvise(..., MADV_HUGEPAGE) = 0; relevant mappings hadhginVmFlags. The 64 MiB test buffer had four segments and 57344 KiB ofAnonHugePages; shrink/regrowth preserved payload.Host THP policy was
[always] madvise never. Actual huge-page coverage is therefore an observation, not proof that this advice caused promotion. No system policy was changed. Artifact:linux-buffer-evidence(14-day retention; also downloaded locally).Complete SYCL engine compile/link: passed; execution not tested
Same workflow, separate Ubuntu 24.04 runner. Official Intel apt compiler/oneMKL packages; Intel oneAPI DPC++/C++ compiler 2026.2.0. Pinned ggml as above. Unmodified engine sources, JIT/SPIR-V configuration; parity-test targets disabled, engine kernel defaults unchanged:
All 134 build steps completed, ending with
Linking CXX executable strata. Binary SHA-256:3d2c2ecce2e056d64a043429de3d4b462cc4ef5af226a809d671ecad87a8ce76. Artifact:sycl-build-evidence(14-day retention; downloaded locally). No Intel GPU was available: device execution, driver JIT and output correctness on Intel remain untested.Earlier tests and unresolved full-suite results
Earlier standalone host results: cache 4785 checks; split allocation-failure cases 8/12/16; memory 25; file 183; session-save reclaim 119;
conv_cache_testpassed.python -m serve.test_monitor: 10 tests, OK. The earlier Windows model smoke reached slot copies and parking, but did not reach superseded harvest; the latest run above closes that specific gap.The earlier all-target HIP build required a local
_putenv_sshim inhc_persist_parity.cpp, not in this PR. Itsctest --output-on-failure -j 1 --timeout 180reported 141 tests and seven failures. Earlier wording "134 passed" was inaccurate: the non-failing remainder includes skips; the exact split was not retained. Those old logs were deleted during requested cleanup; the new verification logs above have been retained.ple_parityexpert_parity,pool_testpack/full/experts.binabsent.isa_guard_checkobjdump; ISA check did not execute.hip_handoffseparate copy/ring timeout; no clean-base comparison of this failure.vmm_testf1 >= f0 + 8 * Gassertion failed; cause not established.hip_prefill_mmq_parity0xC0000005after synthetic checks; cause not established.The new targeted tests do not diagnose or clear these seven historical failures. They must not all be described as proven unrelated to this PR.
Remaining gaps
No engine speedup, lower RAM footprint, or untested hardware correctness is claimed.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.