[PR #2409] [CLOSED] [Engine] avoid CUDA OOM during conversation-cache restore #4031

Closed
opened 2026-11-07 15:32:38 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Niko1221/Strata/pull/2409
Author: @MarsLuay
Created: 10/14/2026
Status: ❌ Closed

Base: main ← Head: fix/issue-2408-conversation-restore-oom


📝 Commits (4)

  • 6b95fd3 fix: skip conversation restore without VRAM headroom
  • da4b978 fix: keep single-GPU conversation restores eligible
  • 7b62cac Merge upstream/main into fix/issue-2408-conversation-restore-oom
  • b116fd8 fix: restore missing brace after conversation restore headroom check

📊 Changes

3 files changed (+60 additions, -0 deletions)

View changed files

📝 include/strata/program/conv_cache.hpp (+12 -0)
📝 src/program/conv_cache_test.cpp (+9 -0)
📝 src/program/generate.cpp (+39 -0)

📄 Description

Fixes #2408

Problem and result

On a two-GPU layer split, restoring a large conversation-cache snapshot can reconstruct K/V residency on a later GPU that is already below the configured VRAM reserve and terminate the server with CUDA OOM. This change admits a parked snapshot only when every sampled split device has the configured headroom; otherwise it returns the snapshot to the conversation cache and rereads the prompt. A failed or unavailable VRAM sample preserves the existing behavior. Single-GPU restores keep the existing path.

Approach

  • Add the unit-tested restore_has_headroom predicate in include/strata/program/conv_cache.hpp.
  • Sample free VRAM on the primary CUDA device and each layer-split stage before restoring an incoming snapshot.
  • Return the snapshot to the cache when a split device is below --vram-reserve-mib.
  • Keep the guard limited to layer-split restores and preserve the no-sample fallback.

Validation

  • Passed on submitted revision b116fd8f42f48e40156c82368e56a8431fee77ac:
    • cmake -S C:/tmp/strata-pr-repo -B C:/tmp/strata-pr-repo/build-cpu -G Ninja -DSTRATA_ENABLE_CUDA=OFF -DSTRATA_BUILD_TESTS=ON -DCMAKE_BUILD_TYPE=Debug
    • cmake --build C:/tmp/strata-pr-repo/build-cpu --target split_rules_test conv_cache_test --parallel 4 — passed.
    • ctest --test-dir C:/tmp/strata-pr-repo/build-cpu -C Debug --output-on-failure -R "^(split_rules_test|conv_cache_test)$" — 2/2 passed.
    • git diff --check — passed.
    • conv_cache_test includes the below-reserve single-GPU regression case.
  • Failed: none observed on that revision.
  • Not run yet: rebase onto current main/0.2.0-beta and current CUDA, HIP, and SYCL backend builds; these are the remaining checks after the tracker reset.

Limits

This is a conservative restore-admission fallback. It does not guarantee cache reuse when split-device headroom is unavailable, and it does not change single-GPU restore admission.


🔄 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/2409 **Author:** [@MarsLuay](https://github.com/MarsLuay) **Created:** 10/14/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `fix/issue-2408-conversation-restore-oom` --- ### 📝 Commits (4) - [`6b95fd3`](https://github.com/Niko1221/Strata/commit/6b95fd325db9c1ee04fb219cb523d324ace137c1) fix: skip conversation restore without VRAM headroom - [`da4b978`](https://github.com/Niko1221/Strata/commit/da4b978bbaf765b70a45adb5b39aa2cb7a7d6fa3) fix: keep single-GPU conversation restores eligible - [`7b62cac`](https://github.com/Niko1221/Strata/commit/7b62cac0b06ef852d4cebb11072aa0e3577a249d) Merge upstream/main into fix/issue-2408-conversation-restore-oom - [`b116fd8`](https://github.com/Niko1221/Strata/commit/b116fd8f42f48e40156c82368e56a8431fee77ac) fix: restore missing brace after conversation restore headroom check ### 📊 Changes **3 files changed** (+60 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `include/strata/program/conv_cache.hpp` (+12 -0) 📝 `src/program/conv_cache_test.cpp` (+9 -0) 📝 `src/program/generate.cpp` (+39 -0) </details> ### 📄 Description Fixes #2408 ## Problem and result On a two-GPU layer split, restoring a large conversation-cache snapshot can reconstruct K/V residency on a later GPU that is already below the configured VRAM reserve and terminate the server with CUDA OOM. This change admits a parked snapshot only when every sampled split device has the configured headroom; otherwise it returns the snapshot to the conversation cache and rereads the prompt. A failed or unavailable VRAM sample preserves the existing behavior. Single-GPU restores keep the existing path. ## Approach - Add the unit-tested `restore_has_headroom` predicate in `include/strata/program/conv_cache.hpp`. - Sample free VRAM on the primary CUDA device and each layer-split stage before restoring an incoming snapshot. - Return the snapshot to the cache when a split device is below `--vram-reserve-mib`. - Keep the guard limited to layer-split restores and preserve the no-sample fallback. ## Validation - Passed on submitted revision `b116fd8f42f48e40156c82368e56a8431fee77ac`: - `cmake -S C:/tmp/strata-pr-repo -B C:/tmp/strata-pr-repo/build-cpu -G Ninja -DSTRATA_ENABLE_CUDA=OFF -DSTRATA_BUILD_TESTS=ON -DCMAKE_BUILD_TYPE=Debug` - `cmake --build C:/tmp/strata-pr-repo/build-cpu --target split_rules_test conv_cache_test --parallel 4` — passed. - `ctest --test-dir C:/tmp/strata-pr-repo/build-cpu -C Debug --output-on-failure -R "^(split_rules_test|conv_cache_test)$"` — 2/2 passed. - `git diff --check` — passed. - `conv_cache_test` includes the below-reserve single-GPU regression case. - Failed: none observed on that revision. - Not run yet: rebase onto current `main`/0.2.0-beta and current CUDA, HIP, and SYCL backend builds; these are the remaining checks after the tracker reset. ## Limits This is a conservative restore-admission fallback. It does not guarantee cache reuse when split-device headroom is unavailable, and it does not change single-GPU restore admission. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-07 15:32:38 +07:00
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#4031
No description provided.