Skip to content

[Engine] keep low-VRAM tiny-cache pinning off above 16 GiB - #6948

Open
gtrak wants to merge 1 commit into
Niko1221:mainfrom
gtrak:fix/low-vram-pin-gate
Open

gtrak wants to merge 1 commit into
Niko1221:mainfrom
gtrak:fix/low-vram-pin-gate

Conversation

@gtrak

@gtrak gtrak commented Nov 24, 2026

Copy link
Copy Markdown

Problem and result

low_vram_pin_slots() (v0.2.20, d28c053e6) decides by cache fraction, not card size: any cache below 25% resident pins 25% of its slots. It was measured on 8-16 GiB consumer cards. A 24 GiB card running a large MoE also sits under 25% resident — Qwen3.8-Flash-Next UD-Q4_K_XL on a 72 GB model is 20.8% — so the card pins ~1,105 slots while the #4870 15-65% coverage rule raises adaptive swaps to 2 / 192 / 0.92. The two fight.

Same-build A/B (STRATA_CACHE_PIN_FRAC=0 vs the default), RTX 4090 24 GB, Windows WDDM, engine 0.1.66, 256 forced greedy tokens, 4 alternating paired rounds:

tag with pinning pinning off
long (~3.2K prompt) 33.0 tok/s 34.5 (+4.5%)
chat1 37.4 39.4 (+5.3%)
chat2 33.8 35.1 (+3.8%)

The wider decode regression and its other parts (the 2/192 rate, the auto cache slots) are tracked in #6799. This PR only stops the low-VRAM pinning from firing on cards it was not measured on.

Result: the pinning behaves exactly as before on <= 16 GiB cards and is off above; unknown VRAM (0) keeps the old fraction-only rule.

Approach

  • low_vram_pin_slots() takes total_vram_bytes and returns 0 above kLowVram16GiB (16 GiB). kLowVram16GiB is new next to the other low-VRAM ceilings.
  • generate.cpp passes the device total from cudaMemGetInfo (already used a few lines below); a failed query leaves 0, which keeps the old rule.
  • low_vram_rules_test.cpp covers 8/12/16/24 GiB and the unknown-VRAM case.

Validation

Passed:

  • engine/src/core/low_vram_rules_test.cpp: low_vram_rules_test: ok (MSVC 19.44, /std:c++20).
  • Windows 11 WDDM, RTX 4090 24 GB (sm_89), CUDA 13.0, Release/portable: built (--arch 89) and served Qwen3.8-Flash-Next UD-Q4_K_XL with STRATA_HC_Q8=0 (to sidestep the separate [Engine] fix fused_gr Q8 TC kernels calling __ldg on shared memory (q8_smem_ld16) #6714 crash, which is not part of this PR). The engine no longer prints the pinned top … line on the 4090.
  • PR build vs the 0.1.66 release engine (HC off, 4 alternating rounds): long 32.5 vs 31.6, chat2 33.2 vs 31.7, chat1 35.0 vs 35.1. (Slots 4,494 vs 4,423 from start-up free-VRAM variance; the same-build A/B above is the isolated measurement.)

Failed: none observed.

Not run:

  • HIP, Metal, SYCL.
  • Cards <= 16 GiB at runtime (the unit test covers the boundary; their behavior should be unchanged).
  • Other models and quantizations; Linux.
  • The full engine test suite (built with -DSTRATA_BUILD_TESTS=OFF), windows-path tests, and multi-GPU.

Limits

low_vram_pin_slots() keys on the cache fraction (< 25% resident) and so applies the 8-16 GiB tiny-cache rule to a 24 GiB card with a large MoE, where it fights the Niko1221#4870 mid-coverage adaptive rule and cost ~4.5% decode (RTX 4090, UD-Q4_K_XL, engine 0.1.66).

Pass the card's total VRAM and keep the pinning to <= 16 GiB; unknown VRAM keeps the old fraction-only rule. The unit test covers the 8/12/16/24 GiB boundary.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant