Mooncake/mooncake-transfer-engine/nvlink-allocator
Teng Ma e73f785f2d
[CI/Build] Switch WITH_NVIDIA_PEERMEM to env variable (#2066)
* [CI/Build] Switch WITH_NVIDIA_PEERMEM to env variable

* [CI/Build] Switch WITH_NVIDIA_PEERMEM to runtime env variable

Instead of a cmake build-time option, check the WITH_NVIDIA_PEERMEM
environment variable at runtime in rdma_context.cpp and
rdma_transport.cpp to switch between ibv_reg_mr() and
ibv_reg_dmabuf_mr().

- Remove option(WITH_NVIDIA_PEERMEM) and add_compile_definitions() from
  common.cmake (no more compile-time flag)
- Update CMakeLists.txt to use GPU toolkit presence instead of cmake var
  for nvlink-allocator build condition
- Add withNvidiaPeermem() runtime helper reading WITH_NVIDIA_PEERMEM env
  var; default false (dmabuf path, no nvidia-peermem required)
- Replace #if !defined(WITH_NVIDIA_PEERMEM) && defined(USE_CUDA) guards
  with runtime if (!withNvidiaPeermem()) checks

Agent-Logs-Url: https://github.com/kvcache-ai/Mooncake/sessions/05c94a1b-d4d6-4b44-be25-3b98d9b01f1b

Co-authored-by: stmatengss <11641725+stmatengss@users.noreply.github.com>

* Add WITH_NVIDIA_PEERMEM to Environ; use Environ::Get() in rdma files

Agent-Logs-Url: https://github.com/kvcache-ai/Mooncake/sessions/66e6cabb-c473-4a9d-9711-aebe468fcee2

Co-authored-by: stmatengss <11641725+stmatengss@users.noreply.github.com>

* Fix linker error: link transfer_engine against mooncake_common for Environ::Get()

Agent-Logs-Url: https://github.com/kvcache-ai/Mooncake/sessions/29d46e31-6dc1-4fee-be33-4a603537b827

Co-authored-by: stmatengss <11641725+stmatengss@users.noreply.github.com>

* Fix linker error in Go CGO builds: add -lmooncake_common to build.sh scripts

Agent-Logs-Url: https://github.com/kvcache-ai/Mooncake/sessions/ab73f098-d408-4ed0-95bb-77f9ce9f71ae

Co-authored-by: stmatengss <11641725+stmatengss@users.noreply.github.com>

* Add USE_MACA to nvlink-allocator conditions to cover all GPU cases

Agent-Logs-Url: https://github.com/kvcache-ai/Mooncake/sessions/251d2c35-d12a-43ed-9958-40526e0420d5

Co-authored-by: stmatengss <11641725+stmatengss@users.noreply.github.com>

* Fix Go CGO linker path: add mooncake-common/src to library search paths

Agent-Logs-Url: https://github.com/kvcache-ai/Mooncake/sessions/5a91e4b9-660d-463b-a8f2-d3fb0118fc34

Co-authored-by: stmatengss <11641725+stmatengss@users.noreply.github.com>

* Fix Rust build.rs: add mooncake_common link and CUDA stubs search paths

Agent-Logs-Url: https://github.com/kvcache-ai/Mooncake/sessions/e0d1e4fd-2cc5-4fe9-9268-5c205e3fc0f5

Co-authored-by: stmatengss <11641725+stmatengss@users.noreply.github.com>

* Fix Rust build.rs: remove CUDA stubs from search_dirs to prevent runtime libcuda.so.1 dep

Agent-Logs-Url: https://github.com/kvcache-ai/Mooncake/sessions/cd938ceb-c822-4439-b617-03f065015d4c

Co-authored-by: stmatengss <11641725+stmatengss@users.noreply.github.com>

* Fix Rust build.rs: remove CUDA stubs from early rustc-link-search to prevent libcuda.so.1 runtime dep

Agent-Logs-Url: https://github.com/kvcache-ai/Mooncake/sessions/055de577-7669-4039-a89a-d6066493e2d0

Co-authored-by: stmatengss <11641725+stmatengss@users.noreply.github.com>

* Fix CI: create libcuda.so.1 symlink and set LD_LIBRARY_PATH for cargo test --lib

Agent-Logs-Url: https://github.com/kvcache-ai/Mooncake/sessions/76131e72-de6f-485b-98ab-342b112f3968

Co-authored-by: stmatengss <11641725+stmatengss@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: stmatengss <11641725+stmatengss@users.noreply.github.com>
2026-05-20 10:05:21 +08:00
..
CMakeLists.txt [CI/Build] Switch WITH_NVIDIA_PEERMEM to env variable (#2066) 2026-05-20 10:05:21 +08:00
build.sh [CI/Build] Switch WITH_NVIDIA_PEERMEM to env variable (#2066) 2026-05-20 10:05:21 +08:00
nvlink_allocator.cpp refactor: unify fabric allocator plumbing (#2028) 2026-05-06 10:13:37 +08:00