Repository navigation
[core][rdt] Enable LIBFABRIC backend for NIXL - #62339
Sparks0219 merged 6 commits into
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces automatic backend selection for NIXL, enabling LIBFABRIC support on AWS EFA instances while defaulting to UCX in other environments. The changes include documentation updates, logic to detect EFA devices, and backend-specific diagnostic hints in error messages. A review comment correctly identified a potential AttributeError in the exception handler when accessing the NIXL agent's backends and suggested using the select_backend method for a more robust implementation.
|
This pull request has been automatically marked as stale because it has not had You can always ask for help on our discussion forum or Ray's public slack channel. If you'd like to keep this open, just leave any comment, and the stale label will be removed. |
|
unstale |
Signed-off-by: Joshua Lee <[email protected]>
c27c3a2 to
324079c
Compare
03081be to
d223eab
Compare
d223eab to
13d38ce
Compare
|
|
||
| To pin the backend explicitly, set the ``RAY_NIXL_BACKEND`` environment variable to either ``UCX`` or ``LIBFABRIC``. An explicit override skips both the EFA probe and the GPUDirect validation. Because the two endpoints of a transfer must agree on a backend, set ``RAY_NIXL_BACKEND`` consistently on every actor that participates in a transfer. Otherwise per-process auto-detection can diverge and fail every transfer with ``NIXL_ERR_BACKEND``. Auto-detection can diverge in two ways: a process picks a different backend under different allocator state, and nodes with different GPUDirect setup can auto-select different backends, for example one node passes the validation registration and selects ``LIBFABRIC`` while another fails it and falls back to ``UCX``. The fallback warning includes the node IP and actor ID to help spot a mixed cluster. | ||
|
|
||
| To tune the validation probe, set ``RAY_NIXL_PROBE_SIZE_BYTES`` (default 64 MiB). The probe allocates a CUDA buffer of this size and tries to register it; the value must exceed EFA's ~32 MiB host bounce pool so the probe exercises a real registration rather than the bounce path, which can succeed even without working GPUDirect. |
There was a problem hiding this comment.
Do we really need it to be configurable? Fewer knobs is better.
| monkeypatch.setattr(ntt.glob, "glob", fake_glob) | ||
|
|
||
|
|
||
| def test_efa_detected_on_host(monkeypatch): |
There was a problem hiding this comment.
Some of these tests seem a bit overkill; it's fine if we just check that the selected backend is right.
13d38ce to
b5beaab
Compare
b5beaab to
1f6fdc7
Compare
| - **AWS instances with EFA**: Ray detects EFA devices and validates that a realistic-size CUDA memory registration succeeds before it selects the ``LIBFABRIC`` backend. To detect EFA both on bare hosts and inside containers, Ray probes the EFA network device (``/sys/class/net/efa*``) as well as the rdma-verbs devices that the AWS EFA Kubernetes device plugin mounts into pods (``/sys/class/infiniband/*`` and ``/dev/infiniband/uverbs*``). The host network device isn't visible inside a pod, so the verbs probes are what make detection work under Kubernetes. | ||
| - **All other environments**: Ray uses the ``UCX`` backend. | ||
|
|
||
| If Ray detects EFA but the validation registration fails, Ray falls back to the ``UCX`` backend and logs a warning. This happens, for example, when the node lacks GPUDirect (no ``nvidia-peermem`` or dmabuf), so EFA can register only small buffers through its host bounce pool, or when the tensors use CUDA VMM memory (``PYTORCH_CUDA_ALLOC_CONF=expandable_segments:True``), which can't be RDMA-registered. |
There was a problem hiding this comment.
In this case, I think it's fine to simplify this and just fail as it most likely signals that there's something wrong with the instance.
| """Validates that LIBFABRIC/EFA can register a realistic GPU buffer. | ||
|
|
||
| return self._nixl_agent | ||
| EFA presence doesn't guarantee GPUDirect works. Without nvidia-peermem or |
There was a problem hiding this comment.
I think GPUDirect validation is also fine to leave as a TODO, the error is propagated during transfer time either way
There was a problem hiding this comment.
if the transfer buffer is less than the bounce pool than the error would not be propagated
There was a problem hiding this comment.
It sounds like from the nixl docs that GPUDirect support is required: https://github.com/ai-dynamo/nixl/blob/1f4468faec77165dea7b9ebc67420d7e170c3fcf/src/plugins/libfabric/README.md
otherwise it'll error out, were you seeing something different? If the error is always propagated, can we remove the probe?
There was a problem hiding this comment.
good call, I removed the nixl register validation
| """Allocates a raw, non-VMM CUDA buffer for backend probing. | ||
|
|
||
| PyTorch's caching allocator uses CUDA VMM (``cuMemCreate``) when | ||
| ``PYTORCH_CUDA_ALLOC_CONF=expandable_segments:True`` (standard for Megatron). |
There was a problem hiding this comment.
why can't you just allocate a torch buffer if expandable segments is off by default?
There was a problem hiding this comment.
How can we ensure expandable_segments is off by default here?
Harden NIXL backend selection so an EFA-equipped node only commits to the LIBFABRIC backend when it can actually use it, and make the choice controllable and observable: - Detect EFA inside containers/Kubernetes pods, not just on bare hosts, by also probing the rdma-verbs devices the AWS EFA device plugin mounts (/sys/class/infiniband/* and /dev/infiniband/uverbs*) in addition to the host netdev (/sys/class/net/efa*). - Validate GPUDirect at selection time: when LIBFABRIC is auto-selected, register a realistic-size (non-VMM) CUDA buffer and fall back to UCX with a warning (including node IP and actor ID) if it fails, instead of surfacing NIXL_ERR_BACKEND only at transfer time. - Add a RAY_NIXL_BACKEND override (UCX/LIBFABRIC) that skips both the EFA probe and the validation, so both endpoints can be pinned to the same backend deterministically. - Add RAY_NIXL_PROBE_SIZE_BYTES (default 64 MiB) to tune the probe above EFA's ~32 MiB host bounce pool. - Improve the registration-failure message with a VMM/expandable_segments hint and backend-specific diagnostics guidance. - Add CPU-only unit tests covering detection, override parsing, and the LIBFABRIC->UCX validation fallback. Signed-off-by: xyuzh <[email protected]> Co-authored-by: Joshua Lee <[email protected]>
1f6fdc7 to
112f002
Compare
|
LGTM modulo @Sparks0219's remaining comments. |
|
|
||
| If Ray detects EFA but the validation registration fails, Ray raises an error instead of selecting a backend, because the failure usually signals a misconfigured instance. This happens, for example, when the node lacks GPUDirect (no ``nvidia-peermem`` or dmabuf), so EFA can register only small buffers through its host bounce pool, or when the tensors use CUDA VMM memory (``PYTORCH_CUDA_ALLOC_CONF=expandable_segments:True``), which can't be RDMA-registered. To use ``UCX`` on such a node, set ``RAY_NIXL_BACKEND=UCX``. | ||
|
|
||
| To pin the backend explicitly, set the ``RAY_NIXL_BACKEND`` environment variable to either ``UCX`` or ``LIBFABRIC``. An explicit override skips both the EFA probe and the GPUDirect validation. Because the two endpoints of a transfer must agree on a backend, set ``RAY_NIXL_BACKEND`` consistently on every actor that participates in a transfer. Otherwise per-process auto-detection can diverge — for example, one node has EFA and selects ``LIBFABRIC`` while another doesn't and selects ``UCX`` — and every transfer fails with ``NIXL_ERR_BACKEND``. |
There was a problem hiding this comment.
This seems a bit janky, perhaps in the future where RDT provides support for more nixl backends having a config like RAY_NIXL_BACKEND would be helpful. But right now, it seems that AWS instances with EFA enabled should always use the LIBFABRIC backend, and UCX otherwise, so I don't see much of the benefit of this config option.
There was a problem hiding this comment.
there is a case when we have rollout in a cluster with EFA, trainer in a cluster with only UCX.
In this case we have to still use UCX for both clusters even EFA is detected
We have remove RAY_NIXL_BACKEND right now for the first iteration
| "Set UCX_LOG_LEVEL=debug for detailed UCX diagnostics." | ||
| ) | ||
| vmm_hint = "" | ||
| alloc_conf = os.environ.get("PYTORCH_CUDA_ALLOC_CONF", "").lower() |
There was a problem hiding this comment.
this issue with pytorch vmm memory is not specific to LIBFABRIC right, it's applicable to any backend? I feel like nixl should propagate the error in this case, and RDT just shows it to the user. Is this not the case today?
There was a problem hiding this comment.
Right now the nixl doesn't expose any guidance on the error message:
- nixl/_api.py → register_memory calls self.agent.registerMem(...) with no error handling of its own.
- The C++ binding does throw_nixl_exception(ret), which maps the nixl_status_t to a typed exception like nixlBackendError, nixlInvalidParamError, etc.
- The message is just nixlEnumStrings::statusStr(status) — i.e. the bare status name, e.g. "NIXL_ERR_BACKEND". No size, no gpu_id, no remediation, no libfabric/UCX detail.
So I think we should expose more clear error msg until nixl has a version that does it
There was a problem hiding this comment.
gotcha makes sense, could you leave a TODO here so that we remember to remove this warning once nixl addresses this?
… diagnostics Remove the explicit RAY_NIXL_BACKEND override path so backend selection is driven purely by hardware auto-detection (LIBFABRIC on EFA, UCX elsewhere). Slim the NIXL memory-registration failure message and point at the NIXL libfabric plugin docs for troubleshooting instead of an inline checklist.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
Reviewed by Cursor Bugbot for commit 823d2e2. Configure here.
…me error Drop the pre-commit LIBFABRIC validation probe (_libfabric_registration_works, the non-VMM cudart allocation helper, and the cached _agent_init_error). EFA auto-selects LIBFABRIC unconditionally; if GPUDirect isn't available, the failure now surfaces with clear, backend-specific guidance from _add_tensor_descs at registration time instead of from a separate startup probe.
Factor the actor-side NIXL availability check out of the __ray_actor_has_tensor_transport__ closure into a module-level _nixl_transport_available_in_process() helper so it can be unit-tested directly. It returns False on any agent-init failure (nixl not installed, LIBFABRIC/EFA failure, or other backend init errors) and logs at debug. Tests updated to cover the helper's failure handling.
## Why are these changes needed? Ray's NIXL tensor transport currently hardcodes the UCX backend (`nixl_agent_config(backends=["UCX"])`). On AWS EFA instances UCX cannot drive the EFA NICs (they are libfabric-only), so cross-node RDT transfers silently degrade to **software-emulated RMA over TCP (~0.3 GB/s)** — correct data, but ~600× slower than the hardware is capable of, with no warning emitted. NIXL itself logs a hint recommending LIBFABRIC. This change makes `NixlTensorTransport` select the **LIBFABRIC** backend on EFA hardware (falling back to UCX everywhere else), unlocking genuine GPUDirect RDMA over EFA. Builds on the initial draft (`joshlee/use-libfabric-nixl-backend`) and hardens it for the environments where naive device-presence selection fails: containers/K8s, hosts without GPUDirect, and CUDA VMM allocators. ### What's included 1. **Backend auto-selection** (`select_backend()`): `LIBFABRIC` when EFA is present, else `UCX`. `get_nixl_agent()` uses it instead of the hardcoded UCX. 2. **Container/K8s-aware EFA detection.** Device presence alone (`glob /sys/class/net/efa*`) is **empty inside pods** — netdevs are network- namespaced — so on K8s the naive check reports "no EFA" and silently selects the slow UCX/TCP path. Detection also accepts the rdma-verbs devices the EFA k8s device-plugin mounts (`/dev/infiniband/uverbs*` + `/sys/class/infiniband/*`). 3. **Validate before committing to LIBFABRIC.** EFA-present ≠ GPUDirect-works: on hosts/drivers without `nvidia-peermem`/dmabuf, LIBFABRIC instantiates and registers *small* CUDA buffers via EFA's ~32 MiB host bounce pool (looks healthy), but `fi_mr_reg` of a real-size buffer fails at transfer time with `NIXL_ERR_BACKEND`. We register/deregister a CUDA buffer **at realistic transfer size** before committing, and fall back to UCX on failure. Size is tunable via `RAY_NIXL_VALIDATE_BYTES`. 4. **VMM (`expandable_segments`) safety.** CUDA VMM memory (`PYTORCH_CUDA_ALLOC_CONF=expandable_segments:True`, standard in large-model training) cannot be RDMA-registered. The validation probe allocates non-expandable memory so it mirrors a real registrable buffer rather than false-failing on a VMM probe. 5. **`RAY_NIXL_BACKEND` override.** Per-process auto-detection can diverge between the two endpoints of a transfer when they run in different processes / Ray jobs with different allocator state (observed: sender → UCX, receiver → LIBFABRIC → every read fails `NIXL_ERR_BACKEND`). `RAY_NIXL_BACKEND=UCX| LIBFABRIC` lets an orchestrator pin both sides; the size-matched probe makes auto-selection deterministic across same-shaped hosts as the default. 6. **Per-transfer stats + backend-specific diagnostics** (`NixlTransferStats`: bytes, xfer time, throughput, backend) and backend-aware error hints (`FI_LOG_LEVEL=Debug` for LIBFABRIC, `UCX_LOG_LEVEL=debug` for UCX) on registration failure. ## Benchmark results Validated in a downstream RL trainer (miles) weight-sync workload (Megatron trainer → sglang rollout engines) on Anyscale, p5.48xlarge (8×H100-80GB, 32×EFA), Ray 2.55.1 + this change, cross-node (every transfer crosses the node boundary). This addresses the draft's "TODO: benchmarking". | Backend | path | effective bandwidth | |---|---|---| | **LIBFABRIC (this PR)** | GPUDirect RDMA over EFA | **~23–30 GiB/s per source** | | UCX (status quo on EFA) | software-emulated RMA over TCP | ~0.3 GB/s | End-to-end weight-sync time (`pull_wait` = pure transfer; full model bf16): | Model | size | shard/src | `pull_wait` (transfer) | full sync | |---|---|---|---|---| | Qwen3-30B-A3B | 57 GiB | 14.24 GiB | 0.61 s | 2.7 s | | GLM-4.7-Flash (MLA+MoE) | — | 14.13 GiB | 0.61 s | 1.9 s | | Moonlight-16B (MLA) | — | 7.48 GiB | 0.33 s | 1.0 s | - LIBFABRIC over EFA was **~8–9× faster than NCCL broadcast** for the same cross-node sync (~3 s vs ~26 s for the 57 GiB model). - Flat across 2→4 nodes (transfer is per-source-shard bound, not node-count bound). - All transfers byte-correct end-to-end (downstream `--check-weight-update-equal` byte-compares the received weights, incl. MLA and fused-MoE tensors). Without fix ray-project#2 (K8s detection) the change is a silent no-op on pods (stays on UCX/TCP). Without ray-project#3/ray-project#4 it selects LIBFABRIC and then fails at transfer time on no-GPUDirect/VMM hosts. With all of them, the LIBFABRIC path is correct and fast across dense, MoE, and MLA models. ## Related issue number Builds on / supersedes the draft on `joshlee/use-libfabric-nixl-backend`. ## Checks - Testing strategy: exercised via a real cross-node RDT weight-sync workload on EFA hardware (numbers above), plus the fallback paths — UCX selection on non-EFA, and LIBFABRIC→UCX fallback when the transfer-size CUDA registration fails (no-GPUDirect host). Suggested unit coverage: `select_backend()` honors `RAY_NIXL_BACKEND` and the EFA globs; `get_nixl_agent()` falls back to UCX when the validation registration raises. - [ ] Signed off commits - [ ] `scripts/format.sh` - [ ] Doc update (`doc/source/ray-core/direct-transport.rst` — backend selection section) - [ ] Tests passing ## Notes for reviewers - The `NixlTransferStats` backend field reads `list(nixl_agent.backends.keys())`; confirm `backends` is always a dict on the supported NIXL version (an earlier review flagged a possible `AttributeError`) and consider guarding it, since the stats path runs on the hot recv path. - Detection globs are cached (`functools.lru_cache`) — fine since hardware doesn't change within a process. --------- Signed-off-by: Joshua Lee <[email protected]> Signed-off-by: xyuzh <[email protected]> Co-authored-by: xyuzh <[email protected]>
## Why are these changes needed? Ray's NIXL tensor transport currently hardcodes the UCX backend (`nixl_agent_config(backends=["UCX"])`). On AWS EFA instances UCX cannot drive the EFA NICs (they are libfabric-only), so cross-node RDT transfers silently degrade to **software-emulated RMA over TCP (~0.3 GB/s)** — correct data, but ~600× slower than the hardware is capable of, with no warning emitted. NIXL itself logs a hint recommending LIBFABRIC. This change makes `NixlTensorTransport` select the **LIBFABRIC** backend on EFA hardware (falling back to UCX everywhere else), unlocking genuine GPUDirect RDMA over EFA. Builds on the initial draft (`joshlee/use-libfabric-nixl-backend`) and hardens it for the environments where naive device-presence selection fails: containers/K8s, hosts without GPUDirect, and CUDA VMM allocators. ### What's included 1. **Backend auto-selection** (`select_backend()`): `LIBFABRIC` when EFA is present, else `UCX`. `get_nixl_agent()` uses it instead of the hardcoded UCX. 2. **Container/K8s-aware EFA detection.** Device presence alone (`glob /sys/class/net/efa*`) is **empty inside pods** — netdevs are network- namespaced — so on K8s the naive check reports "no EFA" and silently selects the slow UCX/TCP path. Detection also accepts the rdma-verbs devices the EFA k8s device-plugin mounts (`/dev/infiniband/uverbs*` + `/sys/class/infiniband/*`). 3. **Validate before committing to LIBFABRIC.** EFA-present ≠ GPUDirect-works: on hosts/drivers without `nvidia-peermem`/dmabuf, LIBFABRIC instantiates and registers *small* CUDA buffers via EFA's ~32 MiB host bounce pool (looks healthy), but `fi_mr_reg` of a real-size buffer fails at transfer time with `NIXL_ERR_BACKEND`. We register/deregister a CUDA buffer **at realistic transfer size** before committing, and fall back to UCX on failure. Size is tunable via `RAY_NIXL_VALIDATE_BYTES`. 4. **VMM (`expandable_segments`) safety.** CUDA VMM memory (`PYTORCH_CUDA_ALLOC_CONF=expandable_segments:True`, standard in large-model training) cannot be RDMA-registered. The validation probe allocates non-expandable memory so it mirrors a real registrable buffer rather than false-failing on a VMM probe. 5. **`RAY_NIXL_BACKEND` override.** Per-process auto-detection can diverge between the two endpoints of a transfer when they run in different processes / Ray jobs with different allocator state (observed: sender → UCX, receiver → LIBFABRIC → every read fails `NIXL_ERR_BACKEND`). `RAY_NIXL_BACKEND=UCX| LIBFABRIC` lets an orchestrator pin both sides; the size-matched probe makes auto-selection deterministic across same-shaped hosts as the default. 6. **Per-transfer stats + backend-specific diagnostics** (`NixlTransferStats`: bytes, xfer time, throughput, backend) and backend-aware error hints (`FI_LOG_LEVEL=Debug` for LIBFABRIC, `UCX_LOG_LEVEL=debug` for UCX) on registration failure. ## Benchmark results Validated in a downstream RL trainer (miles) weight-sync workload (Megatron trainer → sglang rollout engines) on Anyscale, p5.48xlarge (8×H100-80GB, 32×EFA), Ray 2.55.1 + this change, cross-node (every transfer crosses the node boundary). This addresses the draft's "TODO: benchmarking". | Backend | path | effective bandwidth | |---|---|---| | **LIBFABRIC (this PR)** | GPUDirect RDMA over EFA | **~23–30 GiB/s per source** | | UCX (status quo on EFA) | software-emulated RMA over TCP | ~0.3 GB/s | End-to-end weight-sync time (`pull_wait` = pure transfer; full model bf16): | Model | size | shard/src | `pull_wait` (transfer) | full sync | |---|---|---|---|---| | Qwen3-30B-A3B | 57 GiB | 14.24 GiB | 0.61 s | 2.7 s | | GLM-4.7-Flash (MLA+MoE) | — | 14.13 GiB | 0.61 s | 1.9 s | | Moonlight-16B (MLA) | — | 7.48 GiB | 0.33 s | 1.0 s | - LIBFABRIC over EFA was **~8–9× faster than NCCL broadcast** for the same cross-node sync (~3 s vs ~26 s for the 57 GiB model). - Flat across 2→4 nodes (transfer is per-source-shard bound, not node-count bound). - All transfers byte-correct end-to-end (downstream `--check-weight-update-equal` byte-compares the received weights, incl. MLA and fused-MoE tensors). Without fix ray-project#2 (K8s detection) the change is a silent no-op on pods (stays on UCX/TCP). Without ray-project#3/ray-project#4 it selects LIBFABRIC and then fails at transfer time on no-GPUDirect/VMM hosts. With all of them, the LIBFABRIC path is correct and fast across dense, MoE, and MLA models. ## Related issue number Builds on / supersedes the draft on `joshlee/use-libfabric-nixl-backend`. ## Checks - Testing strategy: exercised via a real cross-node RDT weight-sync workload on EFA hardware (numbers above), plus the fallback paths — UCX selection on non-EFA, and LIBFABRIC→UCX fallback when the transfer-size CUDA registration fails (no-GPUDirect host). Suggested unit coverage: `select_backend()` honors `RAY_NIXL_BACKEND` and the EFA globs; `get_nixl_agent()` falls back to UCX when the validation registration raises. - [ ] Signed off commits - [ ] `scripts/format.sh` - [ ] Doc update (`doc/source/ray-core/direct-transport.rst` — backend selection section) - [ ] Tests passing ## Notes for reviewers - The `NixlTransferStats` backend field reads `list(nixl_agent.backends.keys())`; confirm `backends` is always a dict on the supported NIXL version (an earlier review flagged a possible `AttributeError`) and consider guarding it, since the stats path runs on the hot recv path. - Detection globs are cached (`functools.lru_cache`) — fine since hardware doesn't change within a process. --------- Signed-off-by: Joshua Lee <[email protected]> Signed-off-by: xyuzh <[email protected]> Co-authored-by: xyuzh <[email protected]> Signed-off-by: 400Ping <[email protected]>

Why are these changes needed?
Ray's NIXL tensor transport currently hardcodes the UCX backend
(
nixl_agent_config(backends=["UCX"])). On AWS EFA instances UCX cannot drivethe EFA NICs (they are libfabric-only), so cross-node RDT transfers silently
degrade to software-emulated RMA over TCP (~0.3 GB/s) — correct data, but
~600× slower than the hardware is capable of, with no warning emitted. NIXL
itself logs a hint recommending LIBFABRIC.
This change makes
NixlTensorTransportselect the LIBFABRIC backend on EFAhardware (falling back to UCX everywhere else), unlocking genuine GPUDirect RDMA
over EFA. Builds on the initial draft (
joshlee/use-libfabric-nixl-backend) andhardens it for the environments where naive device-presence selection fails:
containers/K8s, hosts without GPUDirect, and CUDA VMM allocators.
What's included
Backend auto-selection (
select_backend()):LIBFABRICwhen EFA ispresent, else
UCX.get_nixl_agent()uses it instead of the hardcoded UCX.Container/K8s-aware EFA detection. Device presence alone (
glob /sys/class/net/efa*) is empty inside pods — netdevs are network-namespaced — so on K8s the naive check reports "no EFA" and silently selects
the slow UCX/TCP path. Detection also accepts the rdma-verbs devices the EFA
k8s device-plugin mounts (
/dev/infiniband/uverbs*+/sys/class/infiniband/*).Validate before committing to LIBFABRIC. EFA-present ≠ GPUDirect-works:
on hosts/drivers without
nvidia-peermem/dmabuf, LIBFABRIC instantiates andregisters small CUDA buffers via EFA's ~32 MiB host bounce pool (looks
healthy), but
fi_mr_regof a real-size buffer fails at transfer time withNIXL_ERR_BACKEND. We register/deregister a CUDA buffer at realistictransfer size before committing, and fall back to UCX on failure. Size is
tunable via
RAY_NIXL_VALIDATE_BYTES.VMM (
expandable_segments) safety. CUDA VMM memory(
PYTORCH_CUDA_ALLOC_CONF=expandable_segments:True, standard in large-modeltraining) cannot be RDMA-registered. The validation probe allocates
non-expandable memory so it mirrors a real registrable buffer rather than
false-failing on a VMM probe.
RAY_NIXL_BACKENDoverride. Per-process auto-detection can divergebetween the two endpoints of a transfer when they run in different processes
/ Ray jobs with different allocator state (observed: sender → UCX, receiver →
LIBFABRIC → every read fails
NIXL_ERR_BACKEND).RAY_NIXL_BACKEND=UCX| LIBFABRIClets an orchestrator pin both sides; the size-matched probe makesauto-selection deterministic across same-shaped hosts as the default.
Per-transfer stats + backend-specific diagnostics (
NixlTransferStats:bytes, xfer time, throughput, backend) and backend-aware error hints
(
FI_LOG_LEVEL=Debugfor LIBFABRIC,UCX_LOG_LEVEL=debugfor UCX) onregistration failure.
Benchmark results
Validated in a downstream RL trainer (miles) weight-sync workload (Megatron
trainer → sglang rollout engines) on Anyscale, p5.48xlarge (8×H100-80GB,
32×EFA), Ray 2.55.1 + this change, cross-node (every transfer crosses the node
boundary). This addresses the draft's "TODO: benchmarking".
End-to-end weight-sync time (
pull_wait= pure transfer; full model bf16):pull_wait(transfer)cross-node sync (~3 s vs ~26 s for the 57 GiB model).
bound).
--check-weight-update-equalbyte-compares the received weights, incl. MLA and fused-MoE tensors).
Without fix #2 (K8s detection) the change is a silent no-op on pods (stays on
UCX/TCP). Without #3/#4 it selects LIBFABRIC and then fails at transfer time on
no-GPUDirect/VMM hosts. With all of them, the LIBFABRIC path is correct and
fast across dense, MoE, and MLA models.
Related issue number
Builds on / supersedes the draft on
joshlee/use-libfabric-nixl-backend.Checks
EFA hardware (numbers above), plus the fallback paths — UCX selection on
non-EFA, and LIBFABRIC→UCX fallback when the transfer-size CUDA registration
fails (no-GPUDirect host). Suggested unit coverage:
select_backend()honorsRAY_NIXL_BACKENDand the EFA globs;get_nixl_agent()falls back to UCX whenthe validation registration raises.
scripts/format.shdoc/source/ray-core/direct-transport.rst— backend selection section)Notes for reviewers
NixlTransferStatsbackend field readslist(nixl_agent.backends.keys());confirm
backendsis always a dict on the supported NIXL version (an earlierreview flagged a possible
AttributeError) and consider guarding it, since thestats path runs on the hot recv path.
functools.lru_cache) — fine since hardwaredoesn't change within a process.