[PR #37] [CLOSED] core: elastic expert cache via CUDA VMM and on-demand GPU vision lifecycle #2423

Closed
opened 2026-11-04 01:59:59 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Niko1221/Strata/pull/37
Author: @code-martin
Created: 9/28/2026
Status: ❌ Closed

Base: main ← Head: feature/vmm-elastic-cache-and-vision


📝 Commits (1)

  • 5b51359 core: implement elastic expert cache via CUDA VMM and on-demand GPU vision

📊 Changes

6 files changed (+586 additions, -64 deletions)

View changed files

📝 CMakeLists.txt (+2 -2)
📝 include/strata/core/expert_cache.hpp (+67 -0)
📝 serve/server.py (+103 -26)
📝 src/core/expert_cache.cpp (+338 -36)
📝 src/program/generate.cpp (+30 -0)
➕ tools/test_vision_client.py (+46 -0)

📄 Description

Summary

This PR implements elastic resizing for the MoE expert cache using the CUDA Virtual Memory Management (VMM) API and introduces an on-demand lifecycle for GPU Vision models.

Key Changes

  • CUDA VMM Elastic Expert Cache:
    • Replaces fixed monolithic cudaMalloc allocations with cuMemAddressReserve, cuMemCreate, and cuMemMap / cuMemSetAccess.
    • Supports dynamic online shrink (RESIZE) and expansion (GROW) without reallocating virtual addresses or invalidating captured CUDA graphs.
    • Automatically falls back to standard cudaMalloc if VMM is unsupported on older architectures.
  • On-Demand GPU Vision Lifecycle:
    • Vision encoder is dynamically loaded into VRAM only when image embeddings are required.
    • Temporarily shrinks the expert cache to release VRAM, performs vision encoding, offloads the vision model, and instantly grows the expert cache back to full capacity.
    • Reclaims over 600 MoE slots (~830 MB) of VRAM permanently during text-only generation.
  • Client Validation Tool:
    • Adds ools/test_vision_client.py for end-to-end verification of image encoding, VRAM contraction, and cache restoration.

Testing

  • Verified on Windows with MSVC C++20 and CUDA 12.6 (RTX 3080 10GB).
  • Text-only generation runs with 2,459 expert slots (up from 1,840). Vision requests encode in ~7.5s and immediately restore the full 2,459 cache slots.

🔄 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/37 **Author:** [@code-martin](https://github.com/code-martin) **Created:** 9/28/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `feature/vmm-elastic-cache-and-vision` --- ### 📝 Commits (1) - [`5b51359`](https://github.com/Niko1221/Strata/commit/5b513598747f7fcc129f67b6bc7e2d7e09596c04) core: implement elastic expert cache via CUDA VMM and on-demand GPU vision ### 📊 Changes **6 files changed** (+586 additions, -64 deletions) <details> <summary>View changed files</summary> 📝 `CMakeLists.txt` (+2 -2) 📝 `include/strata/core/expert_cache.hpp` (+67 -0) 📝 `serve/server.py` (+103 -26) 📝 `src/core/expert_cache.cpp` (+338 -36) 📝 `src/program/generate.cpp` (+30 -0) ➕ `tools/test_vision_client.py` (+46 -0) </details> ### 📄 Description ### Summary This PR implements elastic resizing for the MoE expert cache using the CUDA Virtual Memory Management (VMM) API and introduces an on-demand lifecycle for GPU Vision models. ### Key Changes - **CUDA VMM Elastic Expert Cache**: - Replaces fixed monolithic cudaMalloc allocations with cuMemAddressReserve, cuMemCreate, and cuMemMap / cuMemSetAccess. - Supports dynamic online shrink (RESIZE) and expansion (GROW) without reallocating virtual addresses or invalidating captured CUDA graphs. - Automatically falls back to standard cudaMalloc if VMM is unsupported on older architectures. - **On-Demand GPU Vision Lifecycle**: - Vision encoder is dynamically loaded into VRAM only when image embeddings are required. - Temporarily shrinks the expert cache to release VRAM, performs vision encoding, offloads the vision model, and instantly grows the expert cache back to full capacity. - Reclaims over 600 MoE slots (~830 MB) of VRAM permanently during text-only generation. - **Client Validation Tool**: - Adds ools/test_vision_client.py for end-to-end verification of image encoding, VRAM contraction, and cache restoration. ### Testing - Verified on Windows with MSVC C++20 and CUDA 12.6 (RTX 3080 10GB). - Text-only generation runs with 2,459 expert slots (up from 1,840). Vision requests encode in ~7.5s and immediately restore the full 2,459 cache slots. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-04 01:59:59 +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#2423
No description provided.