Skip to content

enable window AGP via ncclx (#2018)#2018

Open
tianfengfrank wants to merge 4 commits intometa-pytorch:mainfrom
tianfengfrank:export-D100036330
Open

enable window AGP via ncclx (#2018)#2018
tianfengfrank wants to merge 4 commits intometa-pytorch:mainfrom
tianfengfrank:export-D100036330

Conversation

@tianfengfrank
Copy link
Copy Markdown
Contributor

@tianfengfrank tianfengfrank commented Apr 9, 2026

Summary:

  • Expose window based AGP via ncclx
  • add UT for testing

Differential Revision: D100036330

… core funcs and add Buffer abstraction layer

Summary:
## Motivation

AllGatherP's utility functions (`nvlCeBcast`, `copyToSelf`) are currently tightly coupled to `PersistArgs` — they take `PersistArgs&` and extract fields internally. This prevents reuse from any other context that has remote buffer metadata but not a `PersistArgs` struct.

This diff decouples these utilities by replacing the `PersistArgs&` parameter with explicit, individually-passed arguments. This is a pure refactoring with zero logic or behavior change.

## What Changed

**`CommUtils.h`:**
- `nvlCeBcast(... PersistArgs& pArgs ...)` →
  `nvlCeBcast(... const vector<void*>& remoteRecvBuffs, const vector<RemoteAccessKey>& remoteAccessKeys ...)`
- `copyToSelf(... PersistArgs& pArgs ...)` →
  `copyToSelf(... void* recvbuff ...)`

**`DirectImpl.cc` / `PipelineImpl.cc`:**
- Updated all call sites to pass `pArgs.remoteRecvBuffs`, `pArgs.remoteAccessKeys`, `pArgs.recvbuff` explicitly.

## Before → After (call site)

```
Before:  nvlCeBcast(comm, sendBuff, sendSize, offset, pArgs, stream);
After:   nvlCeBcast(comm, sendBuff, sendSize, offset,
                     pArgs.remoteRecvBuffs, pArgs.remoteAccessKeys,
                     stream);

Before:  copyToSelf(comm, sendBuff, sendSize, pArgs, stream);
After:   copyToSelf(comm, sendBuff, sendSize, pArgs.recvbuff, stream);
```

## Why This Enables Window-Based Reuse (Follow-up)

```
  ┌──────────────────────────────────────────────────┐
  │            Reusable Utility Functions             │
  │                                                   │
  │  nvlCeBcast(remoteRecvBuffs[], accessKeys[])     │
  │  copyToSelf(recvbuff)                             │
  └────────────────┬────────────────┬────────────────┘
                   │                │
         ┌─────────┴──┐     ┌──────┴────────┐
         │  Legacy AGP │     │  Window Path  │
         │  (existing) │     │  (follow-up)  │
         ├────────────┤     ├───────────────┤
         │  Passes:    │     │  Passes:      │
         │  pArgs.     │     │  win->        │
         │  remoteRecv │     │  remWinInfo   │
         │  Buffs      │     │  [peer].      │
         │  pArgs.     │     │  dataAddr     │
         │  remoteAccess│    │  win->        │
         │  Keys       │     │  remWinInfo   │
         │             │     │  [peer].      │
         │  pArgs.     │     │  dataRkey     │
         │  recvbuff   │     │  win->        │
         │             │     │  winDataPtr   │
         └─────────────┘     └───────────────┘
```

The follow-up diff will add a window-based execution path that calls
these same utility functions with `win->remWinInfo` data, enabling:
- Regular AG → persistent AGP conversion in graph capture mode
- SM-free CE-based allgather reusable via window API
- No duplication of the core CE broadcast and copy logic
```
                      ┌──────────────┐      ┌──────────────┐
                      │  PersistArgs │      │   CtranWin   │
                      │  (legacy)    │      │  (Phase 3)   │
                      └──────┬───────┘      └──────┬───────┘
                             │                     │
                      populate Buffer        populate Buffer
                             │                     │
                      ┌──────▼─────────────────────▼──────┐
                      │           Buffer (view)            │
                      │  recvbuff, recvHdl,                │
                      │  *remoteRecvBuffs, *remoteAccessKeys│
                      └──────────────┬─────────────────────┘
                                     │
                ┌────────────────────┼─────────────────────┐
                ▼                    ▼                      ▼
      ┌─────────────────┐  ┌──────────────────┐   ┌───────────────┐
      │  copyToSelf()   │  │  nvlCeBcast()    │   │ GPE submit()  │
      │  (CE → self)    │  │  (CE → NVL peers)│   │ (IB put/ring) │
      └─────────────────┘  └──────────────────┘   └───────────────┘
          Phase 1              Phase 1               Phase 2
        parameterized        parameterized         parameterized
```

Differential Revision: D99514784
@meta-cla meta-cla bot added the CLA Signed This label is managed by the Meta Open Source bot. label Apr 9, 2026
@meta-codesync
Copy link
Copy Markdown
Contributor

meta-codesync bot commented Apr 9, 2026

@tianfengfrank has exported this pull request. If you are a Meta employee, you can view the originating Diff in D100036330.

Feng Tian and others added 3 commits April 9, 2026 14:37
Summary: Pull Request resolved: meta-pytorch#2002

Differential Revision: D100051366
Summary:
Pull Request resolved: meta-pytorch#2018

Pull Request resolved: meta-pytorch#2003

- Expose window based AGP via ncclx
- add UT for testing

Differential Revision: D100036330
@meta-codesync meta-codesync bot changed the title enable window AGP via ncclx (#2003) enable window AGP via ncclx (#2018) Apr 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Meta Open Source bot. fb-exported meta-exported

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant