Skip to content

implement JIT lowering for comm.nccl ops - #3122

Draft
mofeing wants to merge 14 commits into
mainfrom
ss/comm-nccl-lower-to-jit
Draft

mofeing wants to merge 14 commits into
mainfrom
ss/comm-nccl-lower-to-jit

Conversation

@mofeing

@mofeing mofeing commented Sep 6, 2026

Copy link
Copy Markdown
Collaborator

i've skipped the implementation of some ops that we may not need right now (ncclCommSplit, ncclCommDestroy, ...).

waiting for #3100 to be merged first (or fuse both PRs into one)

to do

  • add deps to bazel target
  • add compile time guard for only adding CUDA and NCCL headers and users if CUDA backend is compiled
  • add tests

@mofeing
mofeing force-pushed the ss/comm-lower-to-jit branch 3 times, most recently from 526c53f to 81fefc9 Compare September 11, 2026 12:56
Comment on lines +2527 to +2539
Value count =
LLVM::LoadOp::create(rewriter, op.getLoc(), type_i32, host_count_ptr)
.getResult();
Value datatype =
LLVM::LoadOp::create(rewriter, op.getLoc(), type_nccl_datatype,
host_datatype_ptr)
.getResult();
Value redop = LLVM::LoadOp::create(rewriter, op.getLoc(), type_nccl_redop,
host_redop_ptr)
.getResult();
Value comm =
LLVM::LoadOp::create(rewriter, op.getLoc(), type_ptr, host_comm_ptr)
.getResult();

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This seems pretty unfortunate: allocate a buffer on the device, only to immediately copy it back to the host in the jit wrapper? But maybe this is the best we can do given xla constraints?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

we should be able to avoid this memcpys by using attributes, but i don't know yet how to do it with jit_call. i think it's fine for now and can be improved once we learn how to pass attributes with jit_call.

@mofeing
mofeing force-pushed the ss/comm-lower-to-jit branch from 517f40b to 71fca7e Compare September 18, 2026 09:36
Base automatically changed from ss/comm-lower-to-jit to main September 18, 2026 13:10
@mofeing
mofeing force-pushed the ss/comm-nccl-lower-to-jit branch from 35b45d8 to 3029b0c Compare September 18, 2026 15:07

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants