Skip to content

fix(engine): probe the real WSL pin budget instead of guessing 40% RAM - #233

Open
zuver-lab wants to merge 1 commit into
FlashML-org:mainfrom
zuver-lab:fix/wsl-pin-budget
Open

fix(engine): probe the real WSL pin budget instead of guessing 40% RAM#233
zuver-lab wants to merge 1 commit into
FlashML-org:mainfrom
zuver-lab:fix/wsl-pin-budget

Conversation

@zuver-lab

Copy link
Copy Markdown

_pin_budget_bytes() 返回物理内存的 40%(测试机 25.1 GiB),比真实累计 CUDA pin 上限高出约 25 倍,导致 split-residency 机制从不触发,模型加载时直接死在 cudaHostRegister

现在在 WSL2 上,启动时一次性实测上限(lru_cache):用 cudaHostAlloc 以 256 MiB 块逐步分配直到驱动拒绝,触页后与 pin-after-fill bank 行为一致,取实测值的 80% 留余量,并释放探针缓冲。真 Linux(内核无 microsoft 标签)保持不设限(返回 None);FREETOKEN_PIN_BUDGET_GB 环境变量仍可覆盖。

被拒绝的分配会在 CUDA context 留下粘性错误,后续每次调用都会重放为 "out of memory";返回前用 cudaGetLastError() 清除。

实验环境:WSL2 kernel 6.18.33.2-microsoft-standard-WSL2,CUDA 13.0(torch, libcudart.so.13),RTX 3090 24 GiB,62.8 GiB RAM。实测 pin 墙 0.75–1.0 GiB 累计(256 MiB 块);host_ptr_identity(UVA)为 False。

🤖 Generated with Claude Code

_pin_budget_bytes() returned 40% of physical RAM (25.1 GiB on the test
box, ~25x above the real cumulative CUDA pin ceiling), so split residency
never engaged and loads died in cudaHostRegister.

Now on WSL2 it measures the ceiling once (lru_cache): cudaHostAlloc in
256 MiB chunks until the driver refuses, faults the pages to match
pin-after-fill banks, returns 80% of the measured total for headroom, and
frees the probe buffers. Plain Linux (no "microsoft" kernel tag) stays
uncapped (None); FREETOKEN_PIN_BUDGET_GB still overrides. The refused
alloc leaves a *sticky* CUDA error every later call replays as "out of
memory"; cudaGetLastError() clears it before return.

Experiment env: WSL2 kernel 6.18.33.2-microsoft-standard-WSL2, CUDA 13.0
(torch, libcudart.so.13), RTX 3090 24 GiB, 62.8 GiB RAM. Probed wall
0.75-1.0 GiB cumulative (256 MiB chunks); host_ptr_identity (UVA) False.
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.

2 participants