Add auto-detect for RoCE v2 GID for mlx5 NICs in MlxDevice#4304
Add auto-detect for RoCE v2 GID for mlx5 NICs in MlxDevice#4304mkuchnik wants to merge 2 commits into
Conversation
rdma-core's default gid_index (3) is not the routable GID on RoCE v2 fabrics,
and mlx5 does no auto-selection, so QPs come up on an unroutable GID.
This diff adds autoselection logic for MlxDevice:
1. MONARCH_IB_GID_INDEX, if set (as an override);
2. else auto-detect the first routable RoCE v2 GID from sysfs
(gid_attrs/types/<i> == "RoCE v2" and gids/<i> not link-local / all-zero);
3. else fall back to gid_index 3 (prior InfiniBand-mode NICs behavior).
The result is cached process-wide.
Tested on a GB300 node with ConnectX-8 SuperNIC, where the routable GID is index 7.
|
|
||
| /// `MONARCH_IB_GID_INDEX` parsed as a `u8`, if set and valid. | ||
| fn env_gid_index() -> Option<u8> { | ||
| std::env::var("MONARCH_IB_GID_INDEX") |
There was a problem hiding this comment.
The canonical way to define an env var option in monarch is using a hyperactor config attribute; the options for RDMA are defined here. Please call it RDMA_IBV_DEFAULT_GID_INDEX, and incorporate it into the code base by setting the value in IbvConfig's default implementation.
There was a problem hiding this comment.
Take a look. The downside of spreading autoconfig between 1) env 2) autoconfig 3) default is there is an unclear ordering of priority. For example, autoconfig is applied after env and default, so the priority order seems 2, 1, 3, which may be unexpected.
84bed5c to
8119cdf
Compare
Addresses review of the auto-detect commit. Moves the GID-selection logic out of the standalone roce_gid module and onto primitives::Gid. The default is RDMA_IBV_DEFAULT_GID_INDEX (env MONARCH_RDMA_IBV_DEFAULT_GID_INDEX). Tested on a GB300 node with ConnectX-8 SuperNIC, where the routable GID is index 7.
8119cdf to
47ceac0
Compare
| Some("MONARCH_RDMA_IBV_DEFAULT_GID_INDEX".to_string()), | ||
| Some("rdma_ibv_default_gid_index".to_string()), | ||
| )) | ||
| pub attr RDMA_IBV_DEFAULT_GID_INDEX: Option<u8> = None; |
There was a problem hiding this comment.
Let's make this non-optional with a default of 0. The comment shouldn't mention mlx5 or any specific hardware.
| /// | ||
| /// Reads the kernel's GID table from sysfs | ||
| /// (`/sys/class/infiniband/<dev>/ports/<p>/gid_attrs/types/<i>` and | ||
| /// `gids/<i>`) rather than `ibv_query_gid*`: on some mlx5 / RoCE stacks the |
There was a problem hiding this comment.
A few things:
- Comments in non-hardware-specific files shouldn't be mentioning specific hardware that uses it.
- Are you actually in practice running into cases where
ibv_query_gidreturns a bad value? - If
device_infodoesn't contain the right thing, then we should updateIbvDeviceInfoso that it does contain the right thing. Instead of having eachIbvPortcontain only a single gid, let's give it the full list of gids, read from sysfs (filtering out non-roce-v2 gids), and fill it in insidequery_device_info. ThenGid::index_ofcan just read fromIbvDeviceInfowithout having to go through sysfs or any additionalibv_query_gidcalls. - Please tell the LLM to be more concise in its comments.
rdma-core's default gid_index (3) is not the routable GID on RoCE v2 fabrics, and mlx5 does no auto-selection, so QPs come up on an unroutable GID. This diff adds autoselection logic for MlxDevice:
The result is cached process-wide.
Tested on a GB300 node with ConnectX-8 SuperNIC, where the routable GID is index 7.