Skip to content

EXAMPLES: Introduce NIXL-EP example#1043

Merged
ovidiusm merged 1 commit intoai-dynamo:mainfrom
itayalroy:nixl_ep_ups
Dec 8, 2025
Merged

EXAMPLES: Introduce NIXL-EP example#1043
ovidiusm merged 1 commit intoai-dynamo:mainfrom
itayalroy:nixl_ep_ups

Conversation

@itayalroy
Copy link
Contributor

@itayalroy itayalroy commented Nov 20, 2025

NIXL EP: Expert-Parallel Communication Example

Overview

NIXL EP is a complete example implementation of expert-parallel communication for Mixture of Experts (MoE) models built on top of NIXL's device API. It provides elastic scaling capabilities, enabling dynamic addition and removal of processes (ranks) during runtime without disrupting existing connections, and leverages NIXL's RDMA and NVLink support for optimal performance.

Features

  • Dispatch and Combine support: Supports dispatch and combine operations for MoE inference
  • RDMA and NVLink support: Utilizes NIXL's abstractions to support both RDMA and NVLink transports for optimal performance
  • Elastic Scaling: Dynamically add or remove ranks during runtime

Buffer Initialization

NIXL EP provides a flexible buffer initialization pattern that supports dynamic rank management:

import nixl_ep

# Initialize buffer with dynamic rank support
buffer = nixl_ep.Buffer(rank, explicitly_destroy=True)
buffer.update_memory_buffers(num_ranks, num_experts_per_rank, rdma_bytes)
buffer.connect_ranks(initial_ranks)

# Dispatch & Combine calls
buffer.dispatch(...)
buffer.combine(...)

# Later: Connect new ranks dynamically
buffer.connect_ranks(ranks)

# Dispatch & Combine calls
buffer.dispatch(...)
buffer.combine(...)

# Disconnect ranks when scaling down
buffer.disconnect_ranks(ranks)

Key APIs

  • Buffer(rank_id, nvlink_backend, explicitly_destroy): Initialize the NIXL communication buffer
  • update_memory_buffers(num_ranks, num_experts_per_rank, num_rdma_bytes): Prepare buffers for up to num_ranks ranks and num_experts_per_rank experts
  • connect_ranks(remote_ranks): Establish NIXL connections to new peers (can be called multiple times)
  • disconnect_ranks(remote_ranks): Clean up connections to departing peers

Testing

The elastic test suite in tests/elastic/ validates dynamic scaling capabilities:

  • Plan files define scaling phases (representing an orchestrator)
  • Tests validate correctness and measure bandwidth between scaling phases

Example Plan (expansion_contraction.json):

[
  [0, 1, 2, 3],
  [0, 1, 2, 3, 4, 5, 6, 7],
  [0, 1, 2, 3, 4, 5]
]

This plan defines three phases:

  • Phase 0: Initial state with ranks 0-3
  • Phase 1: Ranks 4-7 are added dynamically (launched independently from initial ranks)
  • Phase 2: Ranks 6-7 are removed dynamically

Getting Started

Build NIXL with NIXL EP:

First, configure the pkg-config paths (only needed when dependencies are installed to non-default paths)

export PKG_CONFIG_PATH=<path to rdma-core install>/lib/pkgconfig:$PKG_CONFIG_PATH
export PKG_CONFIG_PATH=<path to UCX install>/lib/pkgconfig:$PKG_CONFIG_PATH
export PKG_CONFIG_PATH=<path to DOCA install>/lib/x86_64-linux-gnu/pkgconfig:$PKG_CONFIG_PATH

Then, configure the NIXL plugin directory so it can find UCX plugin, and set the LD_LIBRARY_PATH so UCX can find rdma-core:

export NIXL_PLUGIN_DIR=<path to NIXL install directory>/lib/x86_64-linux-gnu/plugins
export LD_LIBRARY_PATH=<path to rdma-core install>/lib:$LD_LIBRARY_PATH

Build and install:

meson setup build \
    -Ducx_path=<path to UCX install> \
    -Dprefix=<path to NIXL install directory> \
    -Dbuildtype=release \
    -Dbuild_nixl_ep=true

cd build
ninja install

Finally, configure PYTHONPATH to use NIXL EP:

export PYTHONPATH=<path to NIXL build directory>/examples/device/ep

Refer to tests/elastic/README.md for detailed instructions on how to run the elastic test suite.

@itayalroy itayalroy requested review from a team, brminich, gleon99 and yosefe as code owners November 20, 2025 23:15
@copy-pr-bot
Copy link

copy-pr-bot bot commented Nov 20, 2025

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@github-actions
Copy link

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

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

🚀

@itayalroy itayalroy force-pushed the nixl_ep_ups branch 6 times, most recently from 697d7a4 to e6a29b7 Compare November 21, 2025 20:54
@itayalroy itayalroy requested a review from a team as a code owner November 21, 2025 20:58
@itayalroy itayalroy force-pushed the nixl_ep_ups branch 13 times, most recently from eaf37f0 to b59b1ce Compare November 25, 2025 00:28
@ovidiusm
Copy link
Contributor

ovidiusm commented Dec 5, 2025

/build

@brminich
Copy link
Contributor

brminich commented Dec 5, 2025

/ok to test 3658e83

@ovidiusm
Copy link
Contributor

ovidiusm commented Dec 5, 2025

/build

Copy link
Contributor

@dmitry-tokarev-nv dmitry-tokarev-nv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reviewed file headers wrt licenses and copyright notices. LGTM!

@ovidiusm
Copy link
Contributor

ovidiusm commented Dec 5, 2025

/build

@itayalroy
Copy link
Contributor Author

@ovidiusm @yosefe @brminich can you guys look at the CI issues? seems unrelated to the PR

@ovidiusm
Copy link
Contributor

ovidiusm commented Dec 8, 2025

/build

@yosefe
Copy link
Contributor

yosefe commented Dec 8, 2025

@itayalroy pls use GPG-signed commits so the gitlab, AWS CI will run automatically

@ovidiusm
Copy link
Contributor

ovidiusm commented Dec 8, 2025

/build

Add an example implementation of expert-parallel
dispatch and combine operations using the NIXL
device API.

Co-authored-by: Roey Azran <roeya@nvidia.com>
Co-authored-by: Micha Dery <mdery@nvidia.com>
Co-authored-by: Michal Shalev <mshalev@nvidia.com>

Signed-off-by: Itay Alroy <ialroy@nvidia.com>
@ovidiusm
Copy link
Contributor

ovidiusm commented Dec 8, 2025

/build

@ovidiusm
Copy link
Contributor

ovidiusm commented Dec 8, 2025

/ok to test efb2bf0

@ovidiusm
Copy link
Contributor

ovidiusm commented Dec 8, 2025

Please use normal commits once the code is in review, I cannot see the diff for the changes

@ovidiusm
Copy link
Contributor

ovidiusm commented Dec 8, 2025

/build

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.

7 participants