← Back to Pull requests

UCT/CUDA_COPY: Avoid dmabuf export probe when registrability is known - v1.23.x #12490

Open
unknown opened this pull request with 650 lines diff across 8 files
View on GitHub
unknown unknown commented on Nov 26, 2026 21:53 UTC
Author

What?


Backport of #12333 (fixes #12331) to v1.23.x. #12333 avoids the dmabuf export probe in uct_cuda_copy_md_is_registrable() when the allocation properties already determine the outcome.

This PR also contains the two changes #12333 builds on, each as a separate commit:
1. #12176 GTEST/UCT: Skip tests which assume GDR capable memory under MPS MLOPart
2. #12055 UCT/CUDA_COPY: Non GDR capable memory is non-registrable without DMABUF
3. #12333 UCT/CUDA_COPY: Avoid dmabuf export probe when registrability is known

Why?


Since #11553 (in v1.23.0), detecting UCS_MEM_FLAG_REGISTRABLE exports and closes a dmabuf fd (cuMemGetHandleForAddressRange + close) for every new CUDA buffer. This makes rendezvous transfers from new CUDA buffers 4-5x slower (#12331).

Measured on GB200 (Polyphe, driver 615.74, CUDA 13.2, DMA-BUF supported):

  • #12331 reproducer, 1 node, 8 MiB messages, µs per message, UCX_TLS=^ib,ud:aux, master with and without #12333:
  • | | pool | cudaMalloc |
    |---|---|---|
    | without | 77.8 | 180.5 |
    | with #12333 | 17.2 (4.5x) | 97.0 (1.9x) |

    Pool memory then matches UCX_CUDA_COPY_DMABUF=no (17.2).

  • On the v1.23 line (v1.23.x plus the #11062 and #12367 backports, with and without this one):

  • - reproducer pool memory: 86 -> 17.3 µs; cudaMalloc: 165-178 -> 78-91 µs;
    - 2-node rapidsmpf shuffle benchmark: 283 -> 116 ms (v1.20.1: 140 ms);
    - cudf-polars PDS-H Q9, SF30K, 4 x 4 GB200: 140.2 / 116.7 s -> 49.1 / 42.1 s per iteration (v1.20.1: 48.8 / 41.7 s).

    #12055 also fixes a bug of its own. On systems without DMA-BUF, CUDA memory that is not GPUDirect RDMA capable was reported as registrable, and its registration failed with ibv_reg_mr(): Bad address. This affects e.g. stream-ordered pools with CUDA_COPY_ASYNC_MEM_TYPE=cuda, as ucx.conf sets for Grace Hopper and Vera Rubin.

    How?


    The changes are the same as on master:
  • #12055: without DMA-BUF, the NIC pins the pages behind the virtual address, which the driver allows only for GPUDirect RDMA capable memory. So on that path, registrability is now the GDR capability the driver reports, the same value that gdr_copy already uses. Host-located VMM, managed memory and memory without a device are unchanged.

  • #12333: the allocation properties (async managed, host located, localized, GDR capable, allocated for GDR over PCIe, memory pool) are now gathered into uct_cuda_copy_alloc_props_t while detecting the memory type. When dmabuf is supported, uct_cuda_copy_md_is_registrable() uses them to skip the export where the answer is known:

  • - Memory that is GPUDirect RDMA capable, not localized and not allocated for PCIe only is registrable, without probing. This covers regular cudaMalloc memory.
    - On a device that is not shared through MPS (CU_DEVICE_ATTRIBUTE_MPS_ENABLED = 0), memory that is not localized is also registrable without probing. This covers stream-ordered pool memory.
    - Localized memory (VMM localized to a locality domain, or a pool whose pointers report a locality domain):
    - without a sibling device, the result is the device's GPU_DIRECT_RDMA_WITH_LOCALIZED_MEMORY_SUPPORTED attribute;
    - with a sibling device, a pool or memory allocated for GDR over PCIe is registrable, because the dmabuf is then mapped through PCIe.
    - Everything else, e.g. memory under MPS MLOPart, is still probed with a dmabuf export, as before.
    - The pool locality is queried only for pool memory, and only when the CUDA headers support it. A configure check is added for CU_DEVICE_ATTRIBUTE_GPU_DIRECT_RDMA_WITH_LOCALIZED_MEMORY_SUPPORTED.
    - New tests check that registrability matches an actual dmabuf export for regular, pool, VMM, multi-handle, localized and PCIe-only memory. They also check the non-dmabuf case.
  • #12176: test helpers mem_buffer::cuda_mem_is_gdr_capable(), test_md::check_registrable() and test_md::check_dmabuf_export(). Tests that assume GDR capable memory are skipped when the driver reports none, e.g. under MPS MLOPart.
  • Why #12055 and #12176 are in this PR


    #12333 cannot be applied or tested without them, so they are prerequisites rather than independent backports:
  • #12333 extends the is_gdr_capable registrability logic that #12055 adds to uct_cuda_copy_md_is_registrable(). Without #12055, the cherry-pick conflicts in four places in cuda_copy_md.c, and resolving those conflicts would effectively mean backporting #12055 inside #12333.

  • The new #12333 tests use test_md::check_registrable(), which #12176 adds. #12055's test uses #12176's cuda_mem_is_gdr_capable() and check_dmabuf_export().
  • With separate PRs, the #12333 PR could not build its tests until the other two were merged, in order. #12461 also bundled two master PRs (#11979 + #12344) into one v1.23.x backport. Each change stays a separate cherry-pick -x commit, so a rebase merge keeps them apart, and a squash merge lists all three.

    Backport notes


  • #12176 (tests only): context conflicts with test code that differs on master:

  • - vmm_locality_domain_mem_type: on master the test is test_cuda_copy_md.vmm_locality_domain_mem_type in test_cuda_ipc_md.cc. On v1.23.x it is still test_mem_alloc_device.vmm_locality_domain_mem_type in test_switch_cuda_device.cc, so the hunk is applied there. It skips when locality domain 1 is missing, and fails when domain 0 cannot be allocated although domain 1 was.
    - test_md.cc: the skip conditions are applied to the test_gdr_copy tests. On master they are also inside #if HAVE_DECL_GDR_PIN_BUFFER_V2, which v1.23.x does not have.
    - The lines this commit changes are identical to #12176 on master; only their location differs.
  • #12055: clean cherry-pick.

  • #12333: one conflict in cuda_copy_md.c, because #12204 (not on v1.23.x) moved uct_cuda_copy_mem_release_fabric() to cuda/base on master. Both sides are kept: the function stays where it is on v1.23.x, and the new uct_cuda_copy_alloc_props_t follows it. test_switch_cuda_device.cc and cuda_vmm_mem_buffer.h apply cleanly. Apart from context lines, the result is identical to e8427a295.
  • Diff: 650 lines (+487 / -163) across 8 files Reviewer: tvegas1 Review duration: 5759m
    All Vouch review confidence checks passed
    Residual risk 0.28 = Change Risk (0.52) × (1 − Review Confidence (0.47)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.52 · 650 lines diff across 8 files
    0.52
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    46%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.388
    Shallow Review Depth shallow_review_depth
    0.344
    Real PR Conversation Timeline
    1 comments
    "Review active on #12490"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 46.7% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 52% (MEDIUM) · Higher = larger blast radius
    52%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 46.7% · Lower = rushed or shallow review
    46.7%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 27.7% · Safe to merge
    27.7%
    Repository