Compare commits

...
Author SHA1 Message Date
Georgi Gerganov 52e9954892 cont : fix 2026-08-14 17:15:50 +03:00
Georgi Gerganov 1aa98bbe67 cont : fix 2026-08-14 17:15:21 +03:00
Georgi Gerganov 5beb19ad71 cont : more logs 2026-08-14 17:13:45 +03:00
Georgi Gerganov 8eca1cd5e4 cont : fix 2026-08-14 16:52:46 +03:00
Georgi Gerganov 0fdb83ec6f cont : fix 2026-08-14 16:50:49 +03:00
Georgi Gerganov cd8860a09b cont : add <string> 2026-08-14 16:49:47 +03:00
Georgi Gerganov 511fa698f5 rpc : make RDMA probe diagnostics more verbose
Log the target GID (local address) being matched against, the
GGML_RDMA_DEV / GGML_RDMA_GID env overrides if set, and every GID
present on each probed device (with its type and a [MATCH] marker).
This makes it clear why a device is skipped when RDMA is not usable.

Assisted-by: llama.cpp:DeepSeek-4-Flash-0731
2026-08-14 16:45:29 +03:00
Georgi Gerganov 8d4c022ee8 rpc : log the actual network transport in use
Add log messages at the transport decision points so the user can tell
whether an RPC connection is actually using RDMA or falling back to TCP.

- rdma_probe(): log each reason for failing to set up RDMA instead of
  silently returning false
- update_caps(): log 'RDMA transport active' on success and
  'RDMA not negotiated, staying on TCP' when the peer advertises no caps

Assisted-by: llama.cpp:DeepSeek-4-Flash-0731
2026-08-14 16:33:09 +03:00
+88 -11
View File
@@ -17,9 +17,11 @@
# include <netdb.h>
# include <unistd.h>
#endif
#include <cstdio>
#include <cstdlib>
#include <mutex>
#include <optional>
#include <string>
#ifdef GGML_RPC_RDMA
# include <infiniband/verbs.h>
@@ -191,19 +193,47 @@ std::optional<rdma_gid_t> socket_t::impl::rdma_build_target_gid() {
return std::nullopt;
}
// Format an RDMA GID (16 bytes) as a colon-separated hex string for diagnostics.
static std::string rdma_gid_to_string(const uint8_t * gid) {
char buf[3 * RDMA_GID_SIZE]; // 16 * 2 hex digits + 15 separators + NUL
char * p = buf;
for (size_t i = 0; i < RDMA_GID_SIZE; i++) {
p += sprintf(p, "%02x%s", gid[i], i + 1 < RDMA_GID_SIZE ? ":" : "");
}
return std::string(buf);
}
static const char * rdma_gid_type_str(enum ibv_gid_type type) {
switch (type) {
case IBV_GID_TYPE_IB: return "IB";
case IBV_GID_TYPE_ROCE_V1: return "RoCEv1";
case IBV_GID_TYPE_ROCE_V2: return "RoCEv2";
default: return "unknown";
}
}
bool socket_t::impl::rdma_probe() {
const char * dev_env = std::getenv("GGML_RDMA_DEV");
const char * gid_env = std::getenv("GGML_RDMA_GID");
auto target_gid = rdma_build_target_gid();
if (!target_gid) {
GGML_LOG_INFO("RDMA probe: cannot build target GID from socket local address, staying on TCP\n");
return false;
}
GGML_LOG_INFO("RDMA probe: target GID (local addr) = %s\n", rdma_gid_to_string(target_gid->data()).c_str());
if (dev_env || gid_env) {
GGML_LOG_INFO("RDMA probe: env GGML_RDMA_DEV=%s GGML_RDMA_GID=%s\n",
dev_env ? dev_env : "(unset)", gid_env ? gid_env : "(unset)");
}
const uint8_t ib_port = 1;
int num_devs = 0;
ibv_device ** devs = ibv_get_device_list(&num_devs);
if (!devs || num_devs == 0) return false;
if (!devs || num_devs == 0) {
GGML_LOG_INFO("RDMA probe: no RDMA devices found, staying on TCP\n");
return false;
}
ibv_context * ibctx = nullptr;
const char * matched_dev = nullptr;
@@ -215,10 +245,17 @@ bool socket_t::impl::rdma_probe() {
if (dev_env && strcmp(dev_env, dn) != 0) continue;
ibv_context * ctx = ibv_open_device(devs[d]);
if (!ctx) continue;
if (!ctx) {
GGML_LOG_INFO("RDMA probe: failed to open device %s\n", dn);
continue;
}
ibv_port_attr pa;
if (ibv_query_port(ctx, ib_port, &pa) != 0) { ibv_close_device(ctx); continue; }
if (ibv_query_port(ctx, ib_port, &pa) != 0) {
GGML_LOG_INFO("RDMA probe: failed to query port %u of device %s\n", ib_port, dn);
ibv_close_device(ctx);
continue;
}
int found_gid = gid_idx;
int found_version = IBV_GID_TYPE_IB;
@@ -232,7 +269,12 @@ bool socket_t::impl::rdma_probe() {
for (int i = 0; i < pa.gid_tbl_len; i++) {
ibv_gid_entry entry = {};
if (ibv_query_gid_ex(ctx, ib_port, i, &entry, 0) != 0) continue;
if (memcmp(entry.gid.raw, target_gid->data(), RDMA_GID_SIZE) != 0) continue;
const bool matches = memcmp(entry.gid.raw, target_gid->data(), RDMA_GID_SIZE) == 0;
GGML_LOG_INFO("RDMA probe: device %s port %u GID[%d] type=%s gid=%s%s\n",
dn, ib_port, i, rdma_gid_type_str((enum ibv_gid_type) entry.gid_type),
rdma_gid_to_string(entry.gid.raw).c_str(),
matches ? " [MATCH]" : "");
if (!matches) continue;
if (entry.gid_type == IBV_GID_TYPE_ROCE_V2 && v2_idx < 0) {
v2_idx = i;
} else if (entry.gid_type == IBV_GID_TYPE_ROCE_V1 && v1_idx < 0) {
@@ -251,6 +293,9 @@ bool socket_t::impl::rdma_probe() {
ibv_gid_entry entry = {};
if (ibv_query_gid_ex(ctx, ib_port, found_gid, &entry, 0) == 0) {
found_version = entry.gid_type;
GGML_LOG_INFO("RDMA probe: device %s port %u: GID[%d] type=%s gid=%s\n",
dn, ib_port, found_gid, rdma_gid_type_str((enum ibv_gid_type) found_version),
rdma_gid_to_string(entry.gid.raw).c_str());
}
}
if (found_gid >= 0) {
@@ -259,25 +304,43 @@ bool socket_t::impl::rdma_probe() {
gid_version = found_version;
matched_dev = dn;
rdma_local.path_mtu = pa.active_mtu;
GGML_LOG_INFO("RDMA probe: device %s port %u: GID[%d] type=%s gid=%s\n",
dn, ib_port, found_gid, rdma_gid_type_str((enum ibv_gid_type) found_version),
rdma_gid_to_string(target_gid->data()).c_str());
break;
}
GGML_LOG_INFO("RDMA probe: device %s port %u: no GID matching local addr %s, skipping\n",
dn, ib_port, rdma_gid_to_string(target_gid->data()).c_str());
ibv_close_device(ctx);
}
ibv_free_device_list(devs);
if (!ibctx) return false;
if (!ibctx) {
GGML_LOG_INFO("RDMA probe: no matching device/GID found, staying on TCP\n");
return false;
}
rdma_local.ib_port = ib_port;
rdma_local.gid_idx = gid_idx;
GGML_LOG_INFO("RDMA probe: device %s port %u: GID[%d] type=%s gid=%s\n",
matched_dev, rdma_local.ib_port, gid_idx, rdma_gid_type_str((enum ibv_gid_type) gid_version),
rdma_gid_to_string(target_gid->data()).c_str());
rdma = std::make_unique<rdma_conn>();
rdma->ctx = ibctx;
rdma->pd = ibv_alloc_pd(ibctx);
if (!rdma->pd) return false;
if (!rdma->pd) {
GGML_LOG_INFO("RDMA probe: failed to allocate protection domain\n");
return false;
}
rdma->scq = ibv_create_cq(ibctx, 16, nullptr, nullptr, 0);
rdma->rcq = ibv_create_cq(ibctx, RDMA_RX_DEPTH + 4, nullptr, nullptr, 0);
if (!rdma->scq || !rdma->rcq) return false;
if (!rdma->scq || !rdma->rcq) {
GGML_LOG_INFO("RDMA probe: failed to create completion queues\n");
return false;
}
ibv_qp_init_attr qia = {};
qia.send_cq = rdma->scq;
@@ -290,20 +353,32 @@ bool socket_t::impl::rdma_probe() {
qia.cap.max_inline_data = 256;
rdma->qp = ibv_create_qp(rdma->pd, &qia);
if (!rdma->qp) return false;
if (!rdma->qp) {
GGML_LOG_INFO("RDMA probe: failed to create queue pair\n");
return false;
}
rdma->max_inline = qia.cap.max_inline_data;
rdma->tx_buf = aligned_alloc(4096, RDMA_CHUNK);
rdma->rx_buf = aligned_alloc(4096, static_cast<size_t>(RDMA_RX_DEPTH) * RDMA_CHUNK);
if (!rdma->tx_buf || !rdma->rx_buf) return false;
if (!rdma->tx_buf || !rdma->rx_buf) {
GGML_LOG_INFO("RDMA probe: failed to allocate buffers\n");
return false;
}
rdma->tx_mr = ibv_reg_mr(rdma->pd, rdma->tx_buf, RDMA_CHUNK, IBV_ACCESS_LOCAL_WRITE);
rdma->rx_mr = ibv_reg_mr(rdma->pd, rdma->rx_buf, static_cast<size_t>(RDMA_RX_DEPTH) * RDMA_CHUNK,
IBV_ACCESS_LOCAL_WRITE | IBV_ACCESS_REMOTE_WRITE);
if (!rdma->tx_mr || !rdma->rx_mr) return false;
if (!rdma->tx_mr || !rdma->rx_mr) {
GGML_LOG_INFO("RDMA probe: failed to register memory regions\n");
return false;
}
ibv_gid local_gid;
if (ibv_query_gid(ibctx, ib_port, gid_idx, &local_gid) != 0) return false;
if (ibv_query_gid(ibctx, ib_port, gid_idx, &local_gid) != 0) {
GGML_LOG_INFO("RDMA probe: failed to query local GID\n");
return false;
}
rdma_local.qpn = rdma->qp->qp_num;
rdma_local.psn = rdma->qp->qp_num & 0xffffff;
@@ -527,11 +602,13 @@ void socket_t::impl::update_caps(const uint8_t * remote_caps) {
rdma_caps rc = {};
memcpy(&rc, remote_caps, sizeof(rc));
if (rc.qpn == 0) {
GGML_LOG_INFO("RDMA not negotiated, staying on TCP\n");
rdma.reset();
return;
}
if (rdma_activate(rc.qpn, rc.psn, rc.gid)) {
use_rdma = true;
GGML_LOG_INFO("RDMA transport active\n");
} else {
GGML_LOG_ERROR("RDMA activate failed, staying on TCP\n");
rdma.reset();