[PR #5466] [Engine] q36: report need/free MiB on expert-buffer and staging OOM #5438

Open
opened 2026-11-07 16:35:12 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Niko1221/Strata/pull/5466
Author: @bahooo22
Created: 11/7/2026
Status: 🔄 Open

Base: main ← Head: pr-serve-oom-mib


📝 Commits (1)

  • e74ccf1 q36: report need/free MiB on expert-buffer and staging OOM

📊 Changes

1 file changed (+25 additions, -7 deletions)

View changed files

📝 src/qwen35/q36_engine.cu (+25 -7)

📄 Description

Problem and result

A failed cudaMalloc in the q36 engine (place_experts) printed only "out of memory" with a line number, so the user could not tell whether to shrink the context, MTP, the slot count, the reserve or the quant. After this change every expert-buffer and staging allocation failure prints the buffer's need/free MiB and the launch parameters (ctx, chunk/tmax, top_k, n_embd), and the returned error string carries need/free too. A successful load is unchanged.

This fix previously went out as PR #5044 (bahooo22). #5044 was closed as superseded, but only its serve part landed upstream (b3c63386); the q36 OOM diagnostic did NOT land in upstream/main (verified: git merge-base --is-ancestor 2e1c2a04 54828c7e is false, and git grep alloc_vram 54828c7e -- src/qwen35/q36_engine.cu is empty; 2e1c2a04 is a local fork commit). This PR carries the q36 diagnostic alone. Tracking issue: https://github.com/Niko1221/Strata/issues/5464.

Approach

alloc_vram is hoisted above the expert-placement loop and wraps every device allocation that can OOM there: L.blobs (all-in-VRAM and per-layer slots), H.slot_of_d, E.ecpu, E.d_miss, and the two prompt staging buffers E.stage[0]/E.stage[1]. Diagnostic only: no allocation size, placement or control-flow change; the error text is built once at the failure site.

Validation

Passed:

  • Build (CUDA, sm_86), revision e74ccf1e: cmake -S . -B build -G Ninja -DSTRATA_ENABLE_CUDA=ON -DCMAKE_CUDA_ARCHITECTURES=86; cmake --build build --target strata-q36 -j; ctest --test-dir build --output-on-failure.
  • OOM smoke, KAT Q5_K_S, 80k, q4_0 KV, --mtp 0, 8 GiB: the line reads "prompt staging (E.stage[1]) allocation failed: need 528.0 MiB, free 1260.0 MiB (ctx 81920, chunk 512, top_k 8, n_embd 2048)"; with --vram-reserve-mib 1200 the engine starts (9 slots, 1.03 GiB staging).
  • A normal load prints no new lines and serves as before.

Failed: none observed.

Not run: HIP, SYCL, Metal and CPU-only builds; other models. Draft until the touched backends are built or targeted help is requested.

Limits

The message text is the whole change; it does not recover from an OOM or change the placement decision.


🔄 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/5466 **Author:** [@bahooo22](https://github.com/bahooo22) **Created:** 11/7/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `pr-serve-oom-mib` --- ### 📝 Commits (1) - [`e74ccf1`](https://github.com/Niko1221/Strata/commit/e74ccf1e70fabd8ec7e7858c792fe066936d1422) q36: report need/free MiB on expert-buffer and staging OOM ### 📊 Changes **1 file changed** (+25 additions, -7 deletions) <details> <summary>View changed files</summary> 📝 `src/qwen35/q36_engine.cu` (+25 -7) </details> ### 📄 Description ## Problem and result A failed cudaMalloc in the q36 engine (place_experts) printed only "out of memory" with a line number, so the user could not tell whether to shrink the context, MTP, the slot count, the reserve or the quant. After this change every expert-buffer and staging allocation failure prints the buffer's need/free MiB and the launch parameters (ctx, chunk/tmax, top_k, n_embd), and the returned error string carries need/free too. A successful load is unchanged. ## Related discussion This fix previously went out as PR #5044 (bahooo22). #5044 was closed as superseded, but only its serve part landed upstream (b3c63386); the q36 OOM diagnostic did NOT land in upstream/main (verified: git merge-base --is-ancestor 2e1c2a04 54828c7e is false, and git grep alloc_vram 54828c7e -- src/qwen35/q36_engine.cu is empty; 2e1c2a04 is a local fork commit). This PR carries the q36 diagnostic alone. Tracking issue: https://github.com/Niko1221/Strata/issues/5464. ## Approach alloc_vram is hoisted above the expert-placement loop and wraps every device allocation that can OOM there: L.blobs (all-in-VRAM and per-layer slots), H.slot_of_d, E.ecpu, E.d_miss, and the two prompt staging buffers E.stage[0]/E.stage[1]. Diagnostic only: no allocation size, placement or control-flow change; the error text is built once at the failure site. ## Validation **Passed:** - Build (CUDA, sm_86), revision e74ccf1e: cmake -S . -B build -G Ninja -DSTRATA_ENABLE_CUDA=ON -DCMAKE_CUDA_ARCHITECTURES=86; cmake --build build --target strata-q36 -j; ctest --test-dir build --output-on-failure. - OOM smoke, KAT Q5_K_S, 80k, q4_0 KV, --mtp 0, 8 GiB: the line reads "prompt staging (E.stage[1]) allocation failed: need 528.0 MiB, free 1260.0 MiB (ctx 81920, chunk 512, top_k 8, n_embd 2048)"; with --vram-reserve-mib 1200 the engine starts (9 slots, 1.03 GiB staging). - A normal load prints no new lines and serves as before. **Failed:** none observed. **Not run:** HIP, SYCL, Metal and CPU-only builds; other models. Draft until the touched backends are built or targeted help is requested. ## Limits The message text is the whole change; it does not recover from an OOM or change the placement decision. --- <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#5438
No description provided.