Repository navigation
Conversation
|
🤖 Starting review — findings will be posted here when done. |
| #include "ucp_request.h" | ||
| #include "ucp_tl_info.h" | ||
|
|
||
| #include <uct/base/uct_md.h> |
There was a problem hiding this comment.
UCP currently includes only uct/api/*; pulling in the UCT-internal uct/base/uct_md.h crosses the layer boundary in src/AGENTS.md. Can we instead add ctl_device to uct_tl_device_resource_t and copy it in uct_md_query_tl_resources(), so the new TL op, the md lookup-by-name, and this include are all unnecessary?
There was a problem hiding this comment.
Updated: ctl_device now comes through uct_tl_device_resource_t and the public uct_md_query_tl_resources_v2() API. The internal UCT include, extra TL op, and name lookup are gone, with the legacy API and resource descriptor layout preserved.
| uct_gdaki_get_device_ctl_sys_dev(uct_md_h UCS_V_UNUSED md, const char *dev_name) | ||
| { | ||
| /* The device name was produced by uct_gdaki_fill_cuda_tl_devices(). */ | ||
| return uct_cuda_get_sys_dev(atoi(dev_name + UCT_DEVICE_CUDA_NAME_LEN)); |
There was a problem hiding this comment.
Recovering the GPU by parsing the device name is fragile - atoi() silently returns 0 for any unexpected name, which would point at the wrong GPU. uct_gdaki_fill_cuda_tl_devices() already holds the CUdevice when it builds the name, can we publish the sys_dev from there?
There was a problem hiding this comment.
Updated: uct_gdaki_fill_cuda_tl_devices() now obtains ctl_device directly from the CUdevice via uct_cuda_get_sys_dev_and_bus_id(), without parsing the device name.
| } | ||
|
|
||
| static const uct_gdaki_dev_matrix_elem_t * | ||
| uct_gdaki_dev_matrix_get(const uct_ib_md_t *ib_md, size_t *length_p) |
There was a problem hiding this comment.
why is the dev-matrix cache rework needed for this change? If it is an independent fix for per-context GDA_MAX_HCA_PER_GPU, pls split it to its own PR; it has its own lifetime/caching risk.
There was a problem hiding this comment.
Removed the cache rework from this PR; it now retains the existing upstream device-matrix cache.
| is_device = 1; | ||
| } | ||
|
|
||
| if (context->tl_rscs[tl_idx].tl_rsc.sys_device < |
There was a problem hiding this comment.
the removed TODO said rc_gda puts the GPU in sys_dev_map, and now these resources also affect sys_dev_map and the reachability check. was that fixed in the tl?
There was a problem hiding this comment.
The current GDA resource reports ib_md->dev.sys_dev (the NIC) as sys_device, with the GPU published separately as ctl_device. Distance and reachability checks therefore use the NIC, so the old name-based exclusion is no longer needed.
| EXPECT_EQ(UCS_BIT(1), select(1, UCS_ULUNITS_AUTO)); | ||
| EXPECT_EQ(both, select(1, UCS_ULUNITS_INF)); | ||
|
|
||
| /* GDA may assign more NICs than the registration limit. */ |
There was a problem hiding this comment.
if the transport assigns more NICs to the GPU than MAX_HCA_PER_GPU, the buffer stays unregistered on an assigned NIC, so the device lanes on that NIC cannot be used. should the limit clip the transport's assignment at all?
There was a problem hiding this comment.
The registration cap is intentional: this PR prefers GDA-assigned NICs while respecting UCX_MAX_HCA_PER_GPU. #11733 filters device memory lists to usable registrations when GDA assigns more NICs than the cap allows.
| get_memory_distance(device, distance); | ||
| } | ||
|
|
||
| ucp_context_t m_context = {}; |
There was a problem hiding this comment.
minor: pls align the new declarations (and the m_context.* assignments above) with clang-format.
| ucp_context_t m_context = {}; | |
| ucp_context_t m_context = {}; | |
| ucp_tl_md_t m_mds[2] = {}; | |
| ucp_tl_resource_desc_t m_resources[4] = {}; | |
| ucs_sys_device_t m_devices[4] = {}; | |
| ucs_sys_dev_distance_t m_distances[2]; | |
| ucs_global_state_t *m_topo_state = nullptr; | |
| bool m_provider_pushed = false; |
There was a problem hiding this comment.
Fixed the remaining declaration alignment in 8974c13; the m_context.* assignments above are aligned as well.
|
Residual coverage gaps: The new gtests only cover the UCP selection function against a synthetic context and the |
|
🤖 Starting review — findings will be posted here when done. |
|
🤖 CI Triage Agent — TL;DR: The BlueField (aarch64) build died with a GCC 11 internal compiler error: Bus error while compiling Full analysisSummary: Root cause: The compiler itself crashed, not the code:
Implicated commit: none — not a source regression. (The compiled file's last change is File: build agent environment — Suggested fix:
Related: none found — the only search hit (#11685) is unrelated to this ICE.
|
|
🤖 Starting review — findings will be posted here when done. |
|
🤖 CI Triage Agent — TL;DR: The release-mode lane crashed in Full analysisSummary: Root cause: Two compounding issues, both visible in the log:
PR #12125 ("UCP/DEVICE: Align GPU memory registration with GDA assignments") touches UCP device memory registration and has no relation to UCM bistro hooks, Implicated commit: unknown / long-standing — File: Suggested fix:
Related: PR #12125 (#12125); c77bb48 "UCM/BISTRO: Increase grace time to reduce patch race" (#11112); 676b579 "UCM/BISTRO: Add locking step while patching library functions" (introduced |
|
🤖 Starting review — findings will be posted here when done. |
|
Regarding the coverage concern: |
| * small, or another error code on failure. Outputs are unchanged on | ||
| * failure. | ||
| */ | ||
| ucs_status_t uct_md_query_tl_resources_v2( |
There was a problem hiding this comment.
do we need a new public API for this? the only caller is ucp_add_tl_resources(), and an internal helper in uct_md.h (like uct_cm.h used by ucp_listener.c) would avoid the field_mask + resource_size stride machinery and its validation.
| for (i = 1; i < count; i++) { | ||
| if (ucs_topo_distance_cmp(&select_mds[i].distance, | ||
| &select_mds[0].distance) != 0) { | ||
| if ((select_mds[i].is_device != select_mds[0].is_device) || |
There was a problem hiding this comment.
if the gda tl assigns two NICs to the same GPU with different distances, auto mode keeps only the closest one (and LIMIT can cut assigned MDs too), and then ucp_device_local_mem_list_create() fails with "invalid memh for md_index". should all is_device MDs be kept regardless of distance and of the limit?
There was a problem hiding this comment.
As explained in the earlier thread, this PR intentionally respects the registration cap. #11733 filters device lists to the selected registrations, including when AUTO or a numeric limit excludes GDA-assigned NICs.
|
|
||
| if ((context->config.features & UCP_FEATURE_DEVICE) && | ||
| (mem_sys_dev != UCS_SYS_DEVICE_ID_UNKNOWN) && | ||
| !(context->tl_rscs[tl_idx].flags & UCP_TL_RSC_FLAG_AUX) && |
There was a problem hiding this comment.
minor: aux resources always report ctl_device=UCS_SYS_DEVICE_ID_UNKNOWN, and mem_sys_dev is already checked for UNKNOWN, so this flag test can never change the result - why is it needed?
| { | ||
| uct_component_t *component = md->component; | ||
| uct_tl_resource_desc_t *resources, *tmp; | ||
| uct_tl_resource_desc_v2_t resource = {0}; |
There was a problem hiding this comment.
minor: {0} makes ctl_device read as sys_dev 0 (a valid device id) when the caller does not request CTL_DEVICE; UNKNOWN is safer, especially since ucp_add_tl_resource() copies it without checking field_mask.
| uct_tl_resource_desc_v2_t resource = {0}; | |
| uct_tl_resource_desc_v2_t resource = { | |
| .ctl_device = UCS_SYS_DEVICE_ID_UNKNOWN | |
| }; |
There was a problem hiding this comment.
Initialized ctl_device to UCS_SYS_DEVICE_ID_UNKNOWN as suggested in 6f2c7ac; the returned field mask still determines which fields callers may use.
| continue; | ||
| } | ||
|
|
||
| if ((num_tl_devices > UINT_MAX - num_resources) || |
There was a problem hiding this comment.
minor: these overflow checks cannot trigger (num_tl_devices is a real device count and resource_size >= 8) - maybe drop them to keep the loop simple?
There was a problem hiding this comment.
The API accepts a caller-specified resource_size, so even two real devices can overflow the byte size if the stride exceeds SIZE_MAX / 2. Keeping these checks prevents a wrapped allocation size.
There was a problem hiding this comment.
honestly I agree with bot. real count and stride won't overflow and garbage can't be detected this way
There was a problem hiding this comment.
Removed the overflow checks and unused <limits.h> include in 608f3ff.
|
Notes / residual coverage gaps: The Removing the
Coverage: Several continuation lines in the new code are misaligned ( |
|
🤖 Starting review — findings will be posted here when done. |
|
🤖 CI Triage Agent — TL;DR: The BlueField build failed while linking Full analysisSummary: Root cause: Environment/toolchain, not source. The link line for Implicated commit: unknown (no UCX commit implicated; the trigger is the HPC‑X daily module File: test/mpi/Makefile.am (target Suggested fix: On the BlueField worker, stop consuming the x86 Related: none found (searches for this error signature returned only unrelated open PRs) |
| } | ||
|
|
||
| modify_config("MAX_HCA_PER_GPU", "1"); | ||
| modify_config("IB_GDA_MAX_SYS_LATENCY", "1us"); |
There was a problem hiding this comment.
blocker: IB_GDA_MAX_SYS_LATENCY does not exist in the tree (only test_ucp_device.cc sets it as a raw env var; the actual IB MD option is GDA_MAX_HCA_PER_GPU), and the default FAIL_IF_NOT_EXIST mode aborts the test for any UCT option name (ucp_config_modify_internal() only searches the UCP table, and ucs_global_opts_set_value() only the UCS global tables, so a UCX_IB_* name returns UCS_ERR_NO_ELEM -> UCS_TEST_ABORT). Every other UCP test setting a UCT option passes SETENV_IF_NOT_EXIST/IGNORE_IF_NOT_EXIST. Since the CUDA check runs first, the test silently skips on non-CUDA machines and aborts exactly on the CUDA/GDA machines it targets.
| modify_config("IB_GDA_MAX_SYS_LATENCY", "1us"); | |
| modify_config("IB_GDA_MAX_HCA_PER_GPU", "1", SETENV_IF_NOT_EXIST); |
There was a problem hiding this comment.
Removed IB_GDA_MAX_SYS_LATENCY in 6f2c7ac. The test now uses MAX_HCA_PER_GPU=1 against GDA's existing assignment, so it still covers assignments larger than the registration cap when the hardware exposes them.
|
|
||
| if ((context->config.features & UCP_FEATURE_DEVICE) && | ||
| (mem_sys_dev != UCS_SYS_DEVICE_ID_UNKNOWN) && | ||
| !(context->tl_rscs[tl_idx].flags & UCP_TL_RSC_FLAG_AUX) && |
There was a problem hiding this comment.
The UCP_TL_RSC_FLAG_AUX condition looks redundant: aux resources come from ib/ud query_devices, which report ctl_device = UCS_SYS_DEVICE_ID_UNKNOWN, so with the preceding mem_sys_dev != UCS_SYS_DEVICE_ID_UNKNOWN check the ctl_device == mem_sys_dev comparison already excludes them. unassigned_candidates_use_distance only covers it by constructing an aux resource that also reports a ctl_device, which cannot happen in practice — can we drop the AUX check (and the matching test case)?
There was a problem hiding this comment.
The parser permits rc_gda:aux, which sets the UCP AUX flag after GDA has supplied a known ctl_device. Keeping the guard and test prevents an auxiliary-only GDA resource from changing registration preference.
| {"MAX_HCA_PER_GPU", "inf", | ||
| "Maximum number of HCAs to register GPU memory on.\n" | ||
| "With UCP_FEATURE_DEVICE, prefer HCAs assigned to the GPU by the device\n" | ||
| "transport. The transport's own HCA limit controls that assignment.\n" |
There was a problem hiding this comment.
minor: "The transport's own HCA limit controls that assignment" does not tell the user which knob that is. Pls name the option, e.g. "UCX_IB_GDA_MAX_HCA_PER_GPU controls that assignment", otherwise the user cannot find it.
There was a problem hiding this comment.
Updated the help text in 6f2c7ac to name UCX_IB_GDA_MAX_HCA_PER_GPU explicitly.
| * small, or another error code on failure. Outputs are unchanged on | ||
| * failure. | ||
| */ | ||
| ucs_status_t uct_md_query_tl_resources_v2( |
There was a problem hiding this comment.
question: why does this need to be a public API (plus a new release function) when UCP is the only consumer? uct_iface_attr_t::ctl_device already reports the same information, and UCP already includes internal UCT headers (uct/base/uct_cm.h), so an internal declaration in uct/base/uct_md.h would avoid a new permanent public API.
There was a problem hiding this comment.
The metadata is needed during context resource discovery, before iface creation, so iface querying cannot provide it here. A shared internal resource query could serve the current UCP-only consumer; leaving that API-scope choice open for maintainer input.
|
Residual coverage gaps: |
Remove the obsolete GDA latency setting that aborts the CUDA registration test. Name the GDA assignment limit, initialize optional controller metadata to UNKNOWN, and apply scoped CI formatting fixes.
|
Regarding the formatting and coverage notes: applied the CI formatter's corrections to the changed code in 6f2c7ac, retaining the surrounding configuration table's established layout. The invalid test setting is removed; a successful CUDA/mlx5/GDA run is still pending. |
|
🤖 Starting review — findings will be posted here when done. |
|
🤖 CI Triage Agent — TL;DR: The build failed at link time with Full analysisSummary: Root cause: All UCX sources (including the PR's The Implicated commit: none in the PR — not a code regression. The nearest related UCX commit is File: Suggested fix: Fix the worker/toolchain rather than UCX code:
Related: PR #12125 (this PR, unaffected by the code change); no existing issue found matching the |
| * small, or another error code on failure. Outputs are unchanged on | ||
| * failure. | ||
| */ | ||
| ucs_status_t |
There was a problem hiding this comment.
do we need this as a public API? the only caller is ucp_add_tl_resources(), and UCP already uses internal UCT headers (e.g. uct/base/uct_cm.h in ucp_listener.c) — can we add an internal variant in uct/base/uct_md.h instead, and avoid committing to a new public ABI with a stride contract?
| * @brief Valid fields in @ref uct_tl_resource_desc_v2_t. | ||
| */ | ||
| enum uct_tl_resource_desc_field { | ||
| UCT_TL_RESOURCE_DESC_FIELD_RESOURCE = UCS_BIT(0), /**< Resource */ |
There was a problem hiding this comment.
UCT_TL_RESOURCE_DESC_FIELD_RESOURCE is effectively mandatory: an entry without tl_name/dev_name cannot be identified, so no real caller can omit RESOURCE, and UCP always requests it. Making it optional adds a third branch to the size validation in uct_md_query_tl_resources_v2(), an extra if in the fill loop, and a test matrix (mask = control, mask = 0) that exercises code no caller will use.
resource is the identity of the entry, so no caller can really omit it — can we always fill it and keep the field mask only for the new optional fields? that removes one branch from the size check and one from the fill loop.
| * Must include field_mask and requested fields. | ||
| * Pass sizeof(uct_tl_resource_desc_v2_t) to use | ||
| * a typed array. | ||
| * @param [out] resources_p Allocated array, with resource_size byte stride. |
There was a problem hiding this comment.
Typed out-parameter plus caller-chosen stride is easy to misuse: resources_p is typed uct_tl_resource_desc_v2_t**, but the array is only indexable with [] when resource_size == sizeof(uct_tl_resource_desc_v2_t).
pls document that the array must be walked with resource_size stride (not []), and that resource_size must be a multiple of the struct alignment — otherwise field_mask of entries past the first is unaligned. The new test at test_ucp_context.cc:130 passes a 60-byte stride (offsetof(uct_tl_resource_desc_v2_t, ctl_device)) for a 2-entry array and then reads resources[0], which is exactly the case that silently breaks.
| continue; | ||
| } | ||
|
|
||
| if ((num_tl_devices > UINT_MAX - num_resources) || |
There was a problem hiding this comment.
minor: unreachable overflow guard.
| if ((num_tl_devices > UINT_MAX - num_resources) || | |
| tmp = ucs_realloc(resources, |
The guard cannot trigger: num_tl_devices is a handful per transport, and for any resource_size large enough to matter ucs_realloc() fails first (reaching num_resources > SIZE_MAX / resource_size would require a prior successful allocation larger than SIZE_MAX). It also reports UCS_ERR_NO_MEMORY for what is really a bad resource_size.
|
|
||
| /** @file uct_v2.h */ | ||
|
|
||
| /** |
There was a problem hiding this comment.
minor: declaration placement — the new enum, struct and two prototypes are inserted at the top of the file, above the @defgroup UCT_RESOURCE block they @ingroup into, while every other function prototype in uct_v2.h lives in the lower half after the type definitions. pls move these below the type definitions, next to the other prototypes, and after the @defgroup UCT_RESOURCE block they reference.
|
Residual note: in Residual note: Residual note: not covered by the new tests — Residual note: I could not fetch the PR's existing inline/review threads with the tools available here, so I cannot fully rule out that findings 1–3 duplicate an open discussion; if any of them is already raised, support the existing thread instead of opening a new one. |
| uct_tl_t *tl; | ||
|
|
||
| resources = NULL; | ||
| if ((resource_size < sizeof(resource.field_mask)) || |
There was a problem hiding this comment.
maybe simpler calculate expected_resource_size by field_mask and then compare
There was a problem hiding this comment.
Simplified in 608f3ff: compute expected_resource_size from the requested fields, then compare once. Added boundary coverage for header-only descriptors and undersized requested fields.
| continue; | ||
| } | ||
|
|
||
| if ((num_tl_devices > UINT_MAX - num_resources) || |
There was a problem hiding this comment.
honestly I agree with bot. real count and stride won't overflow and garbage can't be detected this way
| different for different | ||
| transports, e.g. ib0/tcp but | ||
| mlx5_0:1/rc_verbs */ | ||
| ucs_sys_device_t ctl_device; /* Controlling system device */ |
There was a problem hiding this comment.
comment alignment differ
There was a problem hiding this comment.
Aligned with the neighbouring comments in 608f3ff.
| legacy_resources = (uct_tl_resource_desc_t*)resources; | ||
| /* Each destination precedes the next unread descriptor. */ | ||
| for (i = 0; i < num_resources; ++i) { | ||
| memmove(&legacy_resources[i], &resources[i].resource, |
There was a problem hiding this comment.
do we need backward compatibility for uct_md_query_tl_resources?
do we need it both binary and code?
if only binary - we might add new fields uct_tl_resource_desc_t and keep old layout as uct_tl_resource_desc_legace_t only for compatibility.
if binary and code - maybe we obsolete use of uct_tl_resource_desc_t in our code and replace it with flat uct_tl_resource_desc_v2_t ?
There was a problem hiding this comment.
I assumed both source and binary compatibility, so the old public type/query keep their names and layout. Can you confirm that both are required, with only the new v2 descriptor flattened?
There was a problem hiding this comment.
better double check with maintainers, but AFAIK UCT API doesn't require strict compatibility across releases, direct UCT user moving to new version need recompile and possibly adapt func args
| ucs_free(resources); | ||
| } | ||
|
|
||
| void uct_release_tl_resource_list_v2(uct_tl_resource_desc_v2_t *resources) |
There was a problem hiding this comment.
why do we need separate release v2?
There was a problem hiding this comment.
Both now use the same deallocation path in 608f3ff. To remove the extra exported symbol, would you prefer void * on the existing release API, or a typed inline v2 wrapper preserving its exact signature?
| resource.ctl_device = tl_devices[i].ctl_device; | ||
| } | ||
|
|
||
| memcpy(UCS_PTR_BYTE_OFFSET(tmp, |
There was a problem hiding this comment.
why can't write directly if resource_size and field_mask validated
There was a problem hiding this comment.
Should resource_size be required to preserve descriptor alignment? The current contract accepts unaligned strides, so field-mask/size checks alone do not make direct typed writes safe.
| uint64_t field_mask; | ||
|
|
||
| /** Transport resource information. */ | ||
| uct_tl_resource_desc_t resource; |
There was a problem hiding this comment.
if uct_tl_resource_desc_t is obsolete and for legacy only - maybe not use it, add all it's fields directly. or rename uct_tl_resource_desc_t to uct_tl_resource_desc_legacy_t, and reuse it's name for this one?
There was a problem hiding this comment.
Agreed a flat v2 descriptor is cleaner. I have left the type definitions unchanged pending confirmation of source and binary compatibility.
Compute the minimum descriptor size from requested fields, remove overflow guards, and share the resource release implementation. Extend descriptor boundary coverage and align the controller comment.
|
🤖 Starting review — findings will be posted here when done. |
|
|
||
| if ((context->config.features & UCP_FEATURE_DEVICE) && | ||
| (mem_sys_dev != UCS_SYS_DEVICE_ID_UNKNOWN) && | ||
| !(context->tl_rscs[tl_idx].flags & UCP_TL_RSC_FLAG_AUX) && |
There was a problem hiding this comment.
The aux check looks redundant here: aux resources only come from uct_ib_device_query_ports()/ugni, which always set ctl_device = UCS_SYS_DEVICE_ID_UNKNOWN, and the condition below already requires ctl_device == mem_sys_dev with mem_sys_dev != UNKNOWN. Can we drop it, together with the m_resources[3].flags = UCP_TL_RSC_FLAG_AUX step in unassigned_candidates_use_distance which sets a state that cannot occur?
| expected_resource_size = | ||
| ucs_offsetof(uct_tl_resource_desc_v2_t, ctl_device) + | ||
| sizeof(resource.ctl_device); | ||
| } else if (field_mask & UCT_TL_RESOURCE_DESC_FIELD_RESOURCE) { |
There was a problem hiding this comment.
Minor: this chain silently depends on the fields being tested in reverse offset order. When a field is appended after ctl_device, a caller asking for RESOURCE|NEW_FIELD with the old resource_size still passes the check, and then gets a field_mask claiming NEW_FIELD is valid while the ucs_min() memcpy never writes it. Taking the max of the end offsets of all requested fields would be order-independent.
|
Residual coverage gap: Residual coverage gap: |
|
🤖 CI Triage Agent — Summary: Unable to fetch logs — cannot diagnose without them.
|
What?
Prefer HCAs assigned to the GPU by GDA when UCP_FEATURE_DEVICE is enabled,
while respecting UCX_MAX_HCA_PER_GPU.
Why?
UCP and GDA select NICs independently. On a symmetric topology, UCP can
register GPU memory on a NIC that GDA assigned to another GPU, leaving no
usable registered GDA lane.
Addresses the selection mismatch discussed in #11733.
How?
preserving the existing resource descriptor and query API.
registration limit.
differing limits, and actual GDA assignments when hardware is available.
This PR establishes compatible registration selection. #11733 is still
needed to filter device memory lists to those registrations when the GDA
assignment contains more NICs than UCX_MAX_HCA_PER_GPU permits.