cuda : add experimental bounded MoE host pinning - #76
GenerelSchwerz wants to merge 7 commits into
Conversation
Assisted-by: Codex
Assisted-by: Codex
Assisted-by: Codex
Keep backend-owned test buffers and avoid the Windows small macro. Assisted-by: Codex
|
I have been testing bounded MoE host pinning on native Windows with an RTX 5080 and can provide native Windows and physical mixed-GPU validation results. System:
On the clean #76 branch ( passes. I also tested real CUDA inference with both bounded-pinning modes. With: (staging-only), inference completed successfully with source registration disabled. Staging was approximately 906 MiB. With normal source registration enabled, the main-model host pin accounting reached: so the peak remained within the configured 4 GiB cap, and inference completed without a Compute error. I then tested a physical mixed-vendor configuration: where CUDA0 is the RTX 5080 and Vulkan2 is the RX 6800. There is one important interaction: #76 alone exposed the layer-split ROUTE failure addressed by #75. After cherry-picking #75, the unsupported grouped route correctly falls back to cached For the final clean validation I rebuilt the combined #76 + #75 branch ( Warm generation results:
The corresponding MoE cache hit rates were:
All requests completed successfully. Observed memory use during generation was approximately:
I also separately tested Qwen3.8 MTP drafting on the combined branch. It was stable, including the same cached So far I have not seen host-pin budget overruns or Compute errors caused by the bounded-pinning path on native Windows. The 4096 MiB cap is quite tight for this model/configuration: the measured main-model peak was 4,158,259,200 bytes versus the 4,294,967,296-byte cap. |
Keep bounded host pinning compatible with dynamically loaded CUDA backends. Assisted-by: OpenAI Codex
25b333d to
6b0b058
Compare
Assisted-by: Codex # Conflicts: # tests/test-moe-cache.cpp
Assisted-by: Codex
Overview
Draft for testing bounded CUDA host pinning for the MoE expert cache. This is a capacity feature, not a claim of full-pinning throughput parity or certified Windows support.
--moe-expert-cache-host-pinned-mbas a model-wide cap on cache-owned source registrations and pinned staging/control storage. Omitting it retains the existing default path. It supports mmap and non-mmap backing without implicit CPU expert placement.The cap is not a total-RAM or VRAM limit. Insufficient staging fails explicitly; a captured callback failure stops execution before incomplete slots can be consumed. No affinity policy, predictive expert prefetch or PLE change is included.
Trying it
Build this PR branch using the repository's CUDA build instructions. To try the optional host-copy optimizations, add both CMake options:
Run
test-moe-cache --host-pinning-only, then compare the same model, GPU expert slots, prompt, context and KV settings with the host-pin budget omitted versus explicitly configured. Use-fit off -lv 4and choose a budget that leaves room for staging and other allocations. For a staging-only check, setGGML_CUDA_MOE_HOST_REGISTER=0, then remove it before testing source registration again.Native Windows testers: report Windows/driver/toolkit versions, exact build options and command, allocation logs, RAM/VRAM measurements, repeated-request timings and whether outputs match. A successful model load alone is not an inference pass. There is no assumed universal Windows pinning limit. CUDA 12.8 is the Linux-tested target; use a toolkit and architecture appropriate for your GPU.
Validation and limitations
The cleaned candidate passed the full MoE suite with both copy optimizations ON and with both OFF. Optimized-build checks also passed LRU, forced staging, CUDA memcheck, the expected captured failure path, argument parsing and 880/880 CUDA MUL_MAT_ID cases. Earlier feature validation covered mmap/non-mmap servers and FLASH_ATTN_EXT. The retained CPU worker matches the exact extraction previously checked with ThreadSanitizer and MSVC/Wine; these are not native Windows CUDA tests.
The final cleaned-build Flash server completed four 1024-token requests and a different 512-token request, with all five output hashes matching the reference and no job swap, memory-limit/OOM events or watchdog stops. Warm median generation was 34.97 tokens/s. This is a post-cleanup correctness check, not another controlled speed comparison.
Model-sized staging reduced Flash copy traffic by 2.8% under the same pin cap, but its measured throughput gain was only 0.5%, below run variation. The CPU helper reduced callback body time in a matched profile, but the whole speed gain cannot be attributed solely to it. A fresh same-build partial/full comparison produced server medians of 39.61/35.78 versus 42.57/45.99 tokens/s, with all corresponding outputs matching. File-backed page activity varied, and one full-pinning load triggered memory-limit reclaim without OOM or job swap. These results do not promise steady 40/47 tokens/s rates.
See implementation notes and measurements for usage, accounting, failure behavior and evidence limitations. Still draft pending native Windows, physical multi-GPU and CUDA 11 runtime validation.
Requirements