Skip to content

[release/1.5.1] fix(libfabric): fall back for context-independent CUDA allocations - #2470

Merged
nv-nmailhot merged 1 commit into
release/1.5.1from
nmailhot/1.5.1-cp-2425
Oct 21, 2026
Merged

nv-nmailhot merged 1 commit into
release/1.5.1from
nmailhot/1.5.1-cp-2425

Conversation

@nv-nmailhot

Copy link
Copy Markdown
Contributor

What?

Cherry-pick of #2425 (1f4afe6b): fall back for context-independent CUDA allocations in the libfabric backend.

Why?

CUDA returns a null CU_POINTER_ATTRIBUTE_CONTEXT for valid VMM allocations, breaking the libfabric backend on NIXL 1.4.0+ (TRT-LLM KV cache manager V2 on B300). Needed for 1.5.1.

🤖 Generated with Claude Code

…2425)

## Problem

A CUDA device pointer can have a valid device ordinal and a null
`CU_POINTER_ATTRIBUTE_CONTEXT`, as with context-independent VMM
allocations. In a two-node TensorRT-LLM KV cache V2 run, the failing
pointer belonged to an active, mapped VMM allocation while the
submitting thread had a non-null current CUDA context. A null
allocation-associated context is not a null pointer or proof that the
calling thread lacks a current context.

The [NIXL LIBFABRIC
backend](https://github.com/ai-dynamo/nixl/blob/v1.4.0/src/plugins/libfabric/libfabric_backend.cpp#L212)
obtains this value by querying `CU_POINTER_ATTRIBUTE_CONTEXT`; TRT-LLM
does not supply a NULL `CUcontext` argument. [CUDA
documents](https://docs.nvidia.com/cuda/archive/13.0.0/cuda-driver-api/group__CUDA__CTX.html)
that `cuMemCreate()` allocations are not associated with any CUDA
context.

`cudaUpdateCtxPtr()` currently caches that null allocation context and
reports success. The subsequent `cudaSetCtx()` rejects the cached null
value before calling `cuCtxSetCurrent()`, so LIBFABRIC descriptor
posting returns `NIXL_ERR_BACKEND`. The error message therefore does not
mean that the CUDA driver rejected an otherwise valid current context.

## Solution

Treat a null allocation context as a reason to use the existing
per-device `cudaSetDevice()` fallback. Keep ordinary allocation-context
handling unchanged, and update the fallback log so it also describes
this case.

This change addresses NIXL's handling of a null allocation-associated
context. EFA also needs libfabric's separate VMM synchronization fixes
([ofiwg/libfabric#12853](ofiwg/libfabric#12853));
this PR does not replace those fixes.

## Validation

- A standalone CUDA-only control on B300, without TRT-LLM, NIXL or
libfabric, reproduced a NULL allocation-associated context for mapped
`cuMemCreate` allocations while the thread current context was non-null.
Both singular and bulk pointer-attribute queries returned
`CUDA_SUCCESS`; mapping and memory write/read checks passed. The
`cuMemAlloc` control returned a non-null allocation context. POSIX_FD
and NONE handles were exercised; the FABRIC handle case was skipped
after allocation creation failed. [Source, build command and observed
results](#2425 (comment)).
This validates the NULL attribute's independent reproduction, not this
PR revision's GPU correctness.
- Compiled the actual changed context-selection function with a stub
CUDA query. The original code fails the null-context assertion; the
patched v1.4.0 and main implementations pass checks for null, valid,
repeated and conflicting contexts, a device mismatch, host memory, and a
query error.
- Changed lines pass clang-format 19 and `git diff --check`.
- Follow-up isolation test on TRT-LLM
`eac0f787e1aab5b1d8757909345b26acd1854adb`, two B300 nodes, Qwen3-0.6B
TP1/PP1: unmodified NIXL 1.4.0 still failed the same context guard with
only the diagnostic libfabric VMM fixes. Keeping the same binaries and
setting `NIXL_DISABLE_CUDA_ADDR_WA=1` completed 3/3 KV cache V2
inference requests using the NIXL LIBFABRIC backend over EFA RDM. Actual
mapped libraries and KV cache V2 worker logs were checked. This confirms
the separate NIXL failure, not this PR revision's GPU correctness.
- The equivalent patch on NIXL v1.4.0, combined with the libfabric VMM
fixes, completed three two-node TensorRT-LLM KV cache V2 inference
requests over EFA without `NIXL_DISABLE_CUDA_ADDR_WA` or `LD_PRELOAD`.
- Validation gap: a full build and GPU regression on this main-branch
revision, including multiple GPUs and deferred posting, remain
outstanding.

(cherry picked from commit 1f4afe6)
@github-actions

Copy link
Copy Markdown

👋 Hi nv-nmailhot! Thank you for contributing to ai-dynamo/nixl.

Your PR reviewers will review your contribution then trigger the CI to test your changes.

🚀

@nv-nmailhot
nv-nmailhot merged commit 1d2a52e into release/1.5.1 Oct 21, 2026
14 checks passed
@nv-nmailhot
nv-nmailhot deleted the nmailhot/1.5.1-cp-2425 branch October 21, 2026 06:27

This branch was previously deployed

1 inactive deployment
SWX_AWS — 31f040f6 Deployed Oct 21, 2026 by copy-pr-bot[bot] via Run AWS Tests #10221
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants