[PR #1130] [Engine] Windows: apply commit limits after allocation failure #3048

Open
opened 2026-11-04 02:05:12 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Niko1221/Strata/pull/1130
Author: @SladeThe
Created: 10/6/2026
Status: 🔄 Open

Base: main ← Head: windows-commit-retry-v2


📝 Commits (1)

  • 1f4b7cd Apply commit limits after allocation failure

📊 Changes

6 files changed (+293 additions, -26 deletions)

View changed files

📝 CMakeLists.txt (+2 -0)
📝 docs/DETAILS.md (+1 -1)
📝 docs/UNSLOTH_Q4.md (+10 -5)
📝 include/strata/core/expert_source.hpp (+20 -2)
📝 src/core/expert_source.cpp (+73 -18)
📝 tests/core/file_expert_source_test.cpp (+187 -0)

📄 Description

Problem and result

Follow-up to #749: the resident-memory allocation is capped against current Windows commit capacity before an allocation is attempted, even when a system-managed page file could grow to satisfy it.

This change first attempts the allocation permitted by available RAM. After host allocation failure, Windows takes a fresh RAM/commit snapshot and retries once with a smaller positive budget. Borrowed GPU-cache slots that fit remain resident, including when every expert is already held by a GPU cache.

  • #730: the original Windows allocation failure.
  • #749: commit capacity, page-file growth and the retry approach.

Approach

Keep the existing RAM headroom on the first attempt. Apply the commit limit to the smaller retry only after pinned and ordinary allocation fail. Check for an empty retry after planning borrowed slots, preserve both attempts' errors and the file fallback, and require a strict whole complement to fit. Other platforms retain their existing allocation flow.

Validation

Tested on 1 November 2026 at 1f4b7cdd56243fccbc21af4478202dbb50521814, rebased on upstream main at c62d5e3a15b40ea51c96aae9e8d36928965f53ab (Strata 0.2.9 source, engine 0.1.55).

Environment: Windows 11 build 26300, RX 6900 XT, 192 GiB RAM, AMD Clang 24.0.0git and Visual Studio 2022. Release HIP build for gfx1030, with STRATA_BUILD_TESTS, STRATA_NATIVE_EXPERTS, STRATA_PORTABLE and STRATA_PREFILL_MMQ enabled.

Passed:

& ./.venv/Lib/site-packages/cmake/data/bin/cmake.exe --build build-hip-rebase --parallel 6 --target strata file_expert_source_test
& ./.venv/Lib/site-packages/cmake/data/bin/ctest.exe --test-dir build-hip-rebase --output-on-failure --no-tests=error -R '^file_expert_source(_retry)?_test$'
git diff --check upstream/main...HEAD

The HIP engine and test executable built successfully. CTest reported:

1/2 Test #20: file_expert_source_test ..........   Passed    0.36 sec
2/2 Test #21: file_expert_source_retry_test ....   Passed    1.70 sec
100% tests passed out of 2

The whitespace check exited successfully with no output. The regression checks cover one smaller retry, fresh memory limits, explicit and automatic budgets, borrowed slots, empty retries, retained bytes, errors and the file fallback. The GPU integration test ran on one physical GPU; additional-stage residency is represented by the fixture and the initial allocation failure is injected.

GitHub Actions also built and linked the Metal engine successfully on macos-26 for this PR. This compiles the host engine; it does not execute Metal kernels on a GPU.

Failed: None in the checks above. Compilation emitted warnings.

Not run:

  • CUDA build/execution and Metal GPU execution: their toolchains or hardware are unavailable here. Metal compilation/linking passed in CI as noted above.
  • SYCL build/execution: no configured toolchain; that backend uses separate, unchanged source/header copies.
  • Linux execution, physical multi-GPU execution, real commit exhaustion and page-file growth on this revision.

Limits

Draft pending the missing backend validation, as required by CONTRIBUTING.md. Help is needed to build the shared engine changes with CUDA on this revision. There is no new end-to-end performance claim. A successful first allocation does not enforce a separate commit reserve, and allocation success is not guaranteed after a memory snapshot.


🔄 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/Niko1221/Strata/pull/1130 **Author:** [@SladeThe](https://github.com/SladeThe) **Created:** 10/6/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `windows-commit-retry-v2` --- ### 📝 Commits (1) - [`1f4b7cd`](https://github.com/Niko1221/Strata/commit/1f4b7cdd56243fccbc21af4478202dbb50521814) Apply commit limits after allocation failure ### 📊 Changes **6 files changed** (+293 additions, -26 deletions) <details> <summary>View changed files</summary> 📝 `CMakeLists.txt` (+2 -0) 📝 `docs/DETAILS.md` (+1 -1) 📝 `docs/UNSLOTH_Q4.md` (+10 -5) 📝 `include/strata/core/expert_source.hpp` (+20 -2) 📝 `src/core/expert_source.cpp` (+73 -18) 📝 `tests/core/file_expert_source_test.cpp` (+187 -0) </details> ### 📄 Description ## Problem and result Follow-up to #749: the resident-memory allocation is capped against current Windows commit capacity before an allocation is attempted, even when a system-managed page file could grow to satisfy it. This change first attempts the allocation permitted by available RAM. After host allocation failure, Windows takes a fresh RAM/commit snapshot and retries once with a smaller positive budget. Borrowed GPU-cache slots that fit remain resident, including when every expert is already held by a GPU cache. ## Related discussion - #730: the original Windows allocation failure. - #749: commit capacity, page-file growth and the retry approach. ## Approach Keep the existing RAM headroom on the first attempt. Apply the commit limit to the smaller retry only after pinned and ordinary allocation fail. Check for an empty retry after planning borrowed slots, preserve both attempts' errors and the file fallback, and require a strict whole complement to fit. Other platforms retain their existing allocation flow. ## Validation Tested on 1 November 2026 at `1f4b7cdd56243fccbc21af4478202dbb50521814`, rebased on upstream `main` at `c62d5e3a15b40ea51c96aae9e8d36928965f53ab` (Strata 0.2.9 source, engine 0.1.55). Environment: Windows 11 build 26300, RX 6900 XT, 192 GiB RAM, AMD Clang 24.0.0git and Visual Studio 2022. Release HIP build for `gfx1030`, with `STRATA_BUILD_TESTS`, `STRATA_NATIVE_EXPERTS`, `STRATA_PORTABLE` and `STRATA_PREFILL_MMQ` enabled. **Passed:** ```powershell & ./.venv/Lib/site-packages/cmake/data/bin/cmake.exe --build build-hip-rebase --parallel 6 --target strata file_expert_source_test & ./.venv/Lib/site-packages/cmake/data/bin/ctest.exe --test-dir build-hip-rebase --output-on-failure --no-tests=error -R '^file_expert_source(_retry)?_test$' git diff --check upstream/main...HEAD ``` The HIP engine and test executable built successfully. CTest reported: ```text 1/2 Test #20: file_expert_source_test .......... Passed 0.36 sec 2/2 Test #21: file_expert_source_retry_test .... Passed 1.70 sec 100% tests passed out of 2 ``` The whitespace check exited successfully with no output. The regression checks cover one smaller retry, fresh memory limits, explicit and automatic budgets, borrowed slots, empty retries, retained bytes, errors and the file fallback. The GPU integration test ran on one physical GPU; additional-stage residency is represented by the fixture and the initial allocation failure is injected. GitHub Actions also [built and linked the Metal engine successfully](https://github.com/Niko1221/Strata/actions/runs/41343197166/job/124957401218) on `macos-26` for this PR. This compiles the host engine; it does not execute Metal kernels on a GPU. **Failed:** None in the checks above. Compilation emitted warnings. **Not run:** - CUDA build/execution and Metal GPU execution: their toolchains or hardware are unavailable here. Metal compilation/linking passed in CI as noted above. - SYCL build/execution: no configured toolchain; that backend uses separate, unchanged source/header copies. - Linux execution, physical multi-GPU execution, real commit exhaustion and page-file growth on this revision. ## Limits Draft pending the missing backend validation, as required by CONTRIBUTING.md. Help is needed to build the shared engine changes with CUDA on this revision. There is no new end-to-end performance claim. A successful first allocation does not enforce a separate commit reserve, and allocation success is not guaranteed after a memory snapshot. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Sign in to join this conversation.
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
Niko1221/Strata#3048
No description provided.