Skip to content

Commit ef484ca

Browse files
authored
Refine build system and update documentation for v0.6 release (flagos-ai#291)
* Modify Makefile and update v0.6 release notes * Fix a bug
1 parent 11f9b52 commit ef484ca

6 files changed

Lines changed: 87 additions & 54 deletions

File tree

Makefile

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ USE_DU ?= 0
1717
USE_MPI ?= 0
1818
USE_UCX ?= 0
1919
USE_IBUC ?= 0
20+
COMPILE_KERNEL ?= 0
2021

2122
# set to empty if not provided
2223
DEVICE_HOME ?=
@@ -116,6 +117,7 @@ UCX_LIB =
116117
UCX_INCLUDE =
117118
UCX_LINK =
118119
NET_ADAPTOR_FLAG =
120+
COMPILE_KERNEL_FLAG =
119121
ifeq ($(USE_NVIDIA), 1)
120122
DEVICE_LIB = $(DEVICE_HOME)/lib64
121123
DEVICE_INCLUDE = $(DEVICE_HOME)/include
@@ -242,6 +244,10 @@ ifeq ($(USE_IBUC), 1)
242244
NET_ADAPTOR_FLAG += -DUSE_IBUC
243245
endif
244246

247+
ifeq ($(COMPILE_KERNEL), 1)
248+
COMPILE_KERNEL_FLAG = -DCOMPILE_KERNEL
249+
endif
250+
245251
LIBDIR := $(BUILDDIR)/lib
246252
OBJDIR := $(BUILDDIR)/obj
247253

@@ -263,11 +269,12 @@ LIBSRCFILES:= \
263269
$(wildcard flagcx/adaptor/tuner/*.cc) \
264270
$(wildcard flagcx/service/*.cc)
265271

272+
ifeq ($(COMPILE_KERNEL), 1)
266273
DEVSRCFILES:= \
267274
$(wildcard flagcx/kernels/*.$(DEVICE_FILE_EXTENSION))
268-
269-
LIBOBJ:= $(LIBSRCFILES:%.cc=$(OBJDIR)/%.o)
270275
DEVOBJ:= $(DEVSRCFILES:%.$(DEVICE_FILE_EXTENSION)=$(OBJDIR)/%.o)
276+
endif
277+
LIBOBJ:= $(LIBSRCFILES:%.cc=$(OBJDIR)/%.o)
271278

272279
TARGET = libflagcx.so
273280
all: $(LIBDIR)/$(TARGET)
@@ -288,6 +295,7 @@ print_var:
288295
@echo "USE_MUSA: $(USE_MUSA)"
289296
@echo "USE_DU: $(USE_DU)"
290297
@echo "USE_AMD: $(USE_AMD)"
298+
@echo "COMPILE_KERNEL: $(COMPILE_KERNEL)"
291299
@echo "DEVICE_LIB: $(DEVICE_LIB)"
292300
@echo "DEVICE_INCLUDE: $(DEVICE_INCLUDE)"
293301
@echo "CCL_LIB: $(CCL_LIB)"
@@ -303,26 +311,37 @@ print_var:
303311
@echo "USE_IBUC: $(USE_IBUC)"
304312
@echo "NET_ADAPTOR_FLAG: $(NET_ADAPTOR_FLAG)"
305313

306-
$(LIBDIR)/$(TARGET): $(LIBOBJ) $(DEVOBJ) $(OBJDIR)/kernel_dlink.o
314+
ifeq ($(COMPILE_KERNEL), 1)
315+
DEVOBJS = $(DEVOBJ) $(OBJDIR)/kernel_dlink.o
316+
else
317+
DEVOBJS =
318+
endif
319+
320+
$(LIBDIR)/$(TARGET): $(LIBOBJ) $(DEVOBJS)
307321
@mkdir -p `dirname $@`
308322
@echo "Linking $@"
309323
@g++ $^ -o $@ -L$(CCL_LIB) -L$(DEVICE_LIB) -L$(HOST_CCL_LIB) -L$(UCX_LIB) -shared -fvisibility=default -Wl,--no-as-needed -Wl,-rpath,$(LIBDIR) -Wl,-rpath,$(CCL_LIB) -Wl,-rpath,$(HOST_CCL_LIB) -Wl,-rpath,$(UCX_LIB) -lpthread -lrt -ldl $(CCL_LINK) $(DEVICE_LINK) $(HOST_CCL_LINK) $(UCX_LINK) -g
310324

311-
312325
$(OBJDIR)/%.o: %.cc
313326
@mkdir -p `dirname $@`
314327
@echo "Compiling $@"
315328
@g++ $< -o $@ $(foreach dir,$(INCLUDEDIR),-I$(dir)) -I$(CCL_INCLUDE) -I$(DEVICE_INCLUDE) -I$(HOST_CCL_INCLUDE) -I$(UCX_INCLUDE) $(ADAPTOR_FLAG) $(HOST_CCL_ADAPTOR_FLAG) $(NET_ADAPTOR_FLAG) -c -fPIC -fvisibility=default -Wvla -Wno-unused-function -Wno-sign-compare -Wall -MMD -MP -g
316329

330+
ifeq ($(COMPILE_KERNEL), 1)
317331
$(OBJDIR)/kernel_dlink.o: $(DEVOBJ)
318332
@$(DEVICE_LINKER) $^ -o $@ $(DEVICE_LINK) $(DEVICE_LINK_FLAG)
319333

320334
$(OBJDIR)/%.o: %.$(DEVICE_FILE_EXTENSION)
321335
@mkdir -p `dirname $@`
322336
@echo "Compiling $@ ($(DEVICE_RUNTIME))"
323-
@$(DEVICE_COMPILER) $< -o $@ $(foreach dir,$(INCLUDEDIR),-I$(dir)) -I$(CCL_INCLUDE) -I$(DEVICE_INCLUDE) -I$(HOST_CCL_INCLUDE) -I$(UCX_INCLUDE) $(ADAPTOR_FLAG) $(HOST_CCL_ADAPTOR_FLAG) $(NET_ADAPTOR_FLAG) $(DEVICE_COMPILE_FLAG)
337+
@$(DEVICE_COMPILER) $< -o $@ $(foreach dir,$(INCLUDEDIR),-I$(dir)) -I$(CCL_INCLUDE) -I$(DEVICE_INCLUDE) -I$(HOST_CCL_INCLUDE) -I$(UCX_INCLUDE) $(ADAPTOR_FLAG) $(HOST_CCL_ADAPTOR_FLAG) $(NET_ADAPTOR_FLAG) $(DEVICE_COMPILE_FLAG) $(COMPILE_KERNEL_FLAG) -g
338+
endif
324339

340+
ifeq ($(COMPILE_KERNEL), 1)
325341
-include $(LIBOBJ:.o=.d) $(DEVOBJ:.o=.d)
342+
else
343+
-include $(LIBOBJ:.o=.d)
344+
endif
326345

327346
clean:
328347
@rm -rf $(LIBDIR)/$(TARGET) $(OBJDIR)

README.md

Lines changed: 27 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,34 @@
11
[<img src="docs/images/flagopen.png">](https://flagopen.baai.ac.cn/)
22

33
## Latest News
4+
- **[2025/10]** Released [v0.6](https://github.com/FlagOpen/FlagCX/tree/release/v0.6):
5+
- Supported device-buffer P2P communication to achieve intra-node SendRecv operations.
6+
- Introduced Device-initiated, Host-launched device-side primitives, enabling kernel-based communication directly from the device.
7+
- Enhanced automatic tuning functionality, achieving up to 50% performance improvement on Metax platforms for the AllReduce operation.
48
- **[2025/09]** Released [v0.5](https://github.com/FlagOpen/FlagCX/tree/release/v0.5):
5-
- Adds AMD support (hipAdaptor and rcclAdaptor).
6-
- Introduces flagcxNetAdaptor to unify network backends, currently supporting SOCKET, IBRC, UCX and IBUC (experimently).
7-
- Enables zero-copy device-buffer RDMA (user-buffer RDMA) to boost small-message performance.
8-
- Supports automatic tuning in homogeneous scenarios via flagcxTuner.
9-
- Integrates automated PyTorch API tests into CI/CD.
9+
- Added AMD support (hipAdaptor and rcclAdaptor).
10+
- Introduced flagcxNetAdaptor to unify network backends, currently supporting SOCKET, IBRC, UCX and IBUC (experimently).
11+
- Enabled zero-copy device-buffer RDMA (user-buffer RDMA) to boost small-message performance.
12+
- Supported automatic tuning in homogeneous scenarios via flagcxTuner.
13+
- Integrated automated PyTorch API tests into CI/CD.
1014
- **[2025/08]** Released [v0.4](https://github.com/FlagOpen/FlagCX/tree/release/v0.4):
11-
- Supports heterogeneous training of ERNIE4.5 on Nvidia and Iluvatar GPUs with Paddle + FlagCX.
12-
- Enables more robust and flexible deployments with full support of heterogeneous communication across arbitrary NIC configurations (bug fixes).
13-
- Introduces an early experimental net plugin interface extending its support for both IBRC and SOCKET, along with the ability to register device buffers via DMA-BUF.
14-
- Adds an InterOp-level DSL to allow users designing customized C2C algorithms.
15-
- Provides usage documentation under docs/.
15+
- Supported heterogeneous training of ERNIE4.5 on Nvidia and Iluvatar GPUs with Paddle + FlagCX.
16+
- Enabled more robust and flexible deployments with full support of heterogeneous communication across arbitrary NIC configurations (bug fixes).
17+
- Introduced an early experimental net plugin interface extending its support for both IBRC and SOCKET, along with the ability to register device buffers via DMA-BUF.
18+
- Added an InterOp-level DSL to allow users designing customized C2C algorithms.
19+
- Provided usage documentation under docs/.
1620
- **[2025/07]** Released [v0.3](https://github.com/FlagOpen/FlagCX/tree/release/v0.3):
17-
- Integrates three additional native communication libraries: HCCL, MUSACCL and MPI.
18-
- Enhances heterogeneous collective communication operations with pipeline optimizations.
19-
- Introduces a device-side function mechanism to enable device-buffer RDMA, complementing the original host-side function mechanism.
20-
- Delivers a full-stack open-source solution, FlagScale + FlagCX, for efficient heterogeneous prefilling-decoding disaggregation.
21+
- Integrated three additional native communication libraries: HCCL, MUSACCL and MPI.
22+
- Enhanced heterogeneous collective communication operations with pipeline optimizations.
23+
- Introduced a device-side function mechanism to enable device-buffer RDMA, complementing the original host-side function mechanism.
24+
- Delivered a full-stack open-source solution, FlagScale + FlagCX, for efficient heterogeneous prefilling-decoding disaggregation.
2125
- **[2025/05]** Released [v0.2](https://github.com/FlagOpen/FlagCX/tree/release/v0.2):
22-
- Integrates three additional native communications libraries, including MCCL, XCCL and DUCCL.
23-
- Improves 11 heterogeneous collective communication operations with automatic topology detection, fully supporting both single-NIC and multi-NIC environments.
26+
- Integrated three additional native communications libraries, including MCCL, XCCL and DUCCL.
27+
- Improved 11 heterogeneous collective communication operations with automatic topology detection, fully supporting both single-NIC and multi-NIC environments.
2428
- **[2025/04]** Released [v0.1](https://github.com/FlagOpen/FlagCX/tree/release/v0.1):
25-
- Integrates five native communications libraries including NCCL, IXCCL, CNCL, BOOTSTRAP and GLOO.
26-
- Supports 11 heterogeneous collective communication operations using the originally proposed C2C (Cluster-to-Cluster) algorithm.
27-
- Provides a full-stack open-source solution, FlagScale + FlagCX, for efficient heterogeneous training.
29+
- Integrated five native communications libraries including NCCL, IXCCL, CNCL, BOOTSTRAP and GLOO.
30+
- Supported 11 heterogeneous collective communication operations using the originally proposed C2C (Cluster-to-Cluster) algorithm.
31+
- Provided a full-stack open-source solution, FlagScale + FlagCX, for efficient heterogeneous training.
2832
- Natively integrated into PaddlePaddle [v3.0.0](https://github.com/PaddlePaddle/Paddle/tree/v3.0.0), with support for both dynamic and static graphs.
2933

3034
## About
@@ -87,11 +91,11 @@ FlagCX also integrates with upper-layer applications such as PyTorch and PaddleP
8791
| all_to_all_single |||
8892
| barrier |||
8993

90-
The FlagCX PyTorch plugin has undergone comprehensive validation across multiple communication backends, as summarized below:
94+
In particular, PyTorch support is enabled via the FlagCX Torch Plugin, which provides native integration with the PyTorch distributed backend. This plugin has undergone comprehensive validation across diverse communication backends and hardware platforms, ensuring robust functionality, consistent performance, and compatibility in heterogeneous multi-chip environments, as summarized below:
9195

92-
| FlagCX Backend | NCCL | IXCCL | CNCL | MCCL | XCCL | DUCCL | HCCL | MUSACCL | RCCL |
93-
| ---------------------- | ---- | ----- | ---- | ---- | ---- | ----- | ---- | ------- | ---- |
94-
| PyTorch Plugin Support ||||||||||
96+
| FlagCX Backend | NCCL | IXCCL | CNCL | MCCL | XCCL | DUCCL | HCCL | MUSACCL | RCCL |
97+
|:-----------------|:-----|:------|:-----|:-----|:-----|:------|:-----|:--------|:-----|
98+
| PyTorch Support ||||||||||
9599

96100
To enable heterogeneous cross-chip communication using the PyTorch DDP FlagCX backend, it is recommended to use identical PyTorch versions across all nodes. Mismatched versions may lead to initialization failures during process group setup. Further compatibility and performance tests will be conducted in future releases, and we warmly welcome community contributions to help expand and strengthen the validation matrix.
97101

flagcx/core/flagcx_kernel_host.cc

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#include "comm.h"
2+
#include "flagcx.h"
3+
#include "flagcx_kernel.h"
4+
5+
FLAGCX_HOST_DECORATOR flagcxResult_t dequeue(void *fifoBuffer,
6+
flagcxDeviceTrigger_t trigger) {
7+
int idx = -1;
8+
unsigned long long int *buffer = (unsigned long long int *)fifoBuffer;
9+
int capacity = buffer[0];
10+
int distance = buffer[2] - buffer[1];
11+
if (distance > 0) {
12+
idx = buffer[1] % capacity;
13+
buffer[1] = buffer[1] + 1;
14+
__sync_synchronize();
15+
}
16+
if (idx > -1) {
17+
memcpy((void *)trigger,
18+
(void *)(buffer + 3 +
19+
sizeof(flagcxDeviceTrigger) /
20+
sizeof(unsigned long long int) * idx),
21+
sizeof(flagcxDeviceTrigger));
22+
} else {
23+
memset((void *)trigger, 0, sizeof(flagcxDeviceTrigger));
24+
}
25+
return flagcxSuccess;
26+
}
27+
28+
// __host__ flagcxResult_t flagcxFifo::enqueue(flagcxReduceTrigger trigger) {
29+
// // to be implemented
30+
// return flagcxNotSupported;
31+
// }

flagcx/include/flagcx_kernel.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,14 +107,15 @@ struct flagcxFifo {
107107
};
108108
typedef struct flagcxFifo *flagcxFifo_t;
109109

110+
FLAGCX_HOST_DECORATOR flagcxResult_t dequeue(void *fifoBuffer,
111+
flagcxDeviceTrigger_t trigger);
112+
#ifdef COMPILE_KERNEL
110113
// device-producer + host-consumer APIs
111114
FLAGCX_DEVICE_DECORATOR flagcxResult_t enqueue(void *fifoBuffer, uint64_t addr,
112115
uint64_t count,
113116
uint64_t peerRank,
114117
uint64_t datatype,
115118
uint64_t type);
116-
FLAGCX_HOST_DECORATOR flagcxResult_t dequeue(void *fifoBuffer,
117-
flagcxDeviceTrigger_t trigger);
118119
// host-producer + device-consumer APIs
119120
// FLAGCX_HOST_DECORATOR flagcxResult_t enqueue(flagcxReduceTrigger trigger);
120121
// FLAGCX_HOST_DECORATOR flagcxResult_t dequeue(flagcxReduceTrigger_t trigger);
@@ -134,4 +135,5 @@ FLAGCX_DEVICE_DECORATOR flagcxResult_t flagcxDeviceWait(void *fifoBuffer);
134135
void flagcxP2pDemo(const void *sendbuff, void *recvbuff, size_t count,
135136
flagcxDataType_t datatype, int sendPeer, int recvPeer,
136137
flagcxComm_t comm, flagcxStream_t stream);
138+
#endif // COMPILE_KERNEL
137139
#endif
Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -102,29 +102,6 @@ FLAGCX_DEVICE_DECORATOR flagcxResult_t enqueue(void *fifoBuffer, uint64_t addr,
102102
return flagcxSuccess;
103103
}
104104

105-
FLAGCX_HOST_DECORATOR flagcxResult_t dequeue(void *fifoBuffer, flagcxDeviceTrigger_t trigger) {
106-
int idx = -1;
107-
unsigned long long int *buffer = (unsigned long long int *)fifoBuffer;
108-
int capacity = buffer[0];
109-
int distance = buffer[2] - buffer[1];
110-
if (distance > 0) {
111-
idx = buffer[1] % capacity;
112-
buffer[1] = buffer[1] + 1;
113-
__sync_synchronize();
114-
}
115-
if (idx > -1) {
116-
memcpy((void *)trigger, (void *)(buffer + 3 + sizeof(flagcxDeviceTrigger) / sizeof(unsigned long long int) * idx), sizeof(flagcxDeviceTrigger));
117-
} else {
118-
memset((void *)trigger, 0, sizeof(flagcxDeviceTrigger));
119-
}
120-
return flagcxSuccess;
121-
}
122-
123-
// __host__ flagcxResult_t flagcxFifo::enqueue(flagcxReduceTrigger trigger) {
124-
// // to be implemented
125-
// return flagcxNotSupported;
126-
// }
127-
128105
// __device__ flagcxResult_t flagcxFifo::dequeue(flagcxReduceTrigger_t trigger) {
129106
// // to be implemented
130107
// return flagcxNotSupported;

test/kernel/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ all: test-kernel-demo
2525

2626
test-kernel-demo: test_kernel_demo.cpp
2727
@echo "Compiling $@"
28-
@$(COMPILER) $(EXTRA_COMPILER_FLAG) -o test_kernel_demo test_kernel_demo.cpp $(LIBSRCFILES) -I../../flagcx/include -I../../flagcx/adaptor/include -I../../flagcx/service/ -I../../flagcx/core/ -I$(INCLUDEDIR) -I$(MPI_INCLUDE) -I$(DEVICE_INCLUDE) -L../../build/lib -L$(MPI_LIB) -L$(DEVICE_LIB) -lflagcx $(MPI_LINK) $(DEVICE_LINK)
28+
@$(COMPILER) $(EXTRA_COMPILER_FLAG) -o test_kernel_demo test_kernel_demo.cpp $(LIBSRCFILES) -I../../flagcx/include -I../../flagcx/adaptor/include -I../../flagcx/service/ -I../../flagcx/core/ -I$(INCLUDEDIR) -I$(MPI_INCLUDE) -I$(DEVICE_INCLUDE) -L../../build/lib -L$(MPI_LIB) -L$(DEVICE_LIB) -lflagcx $(MPI_LINK) $(DEVICE_LINK) -DCOMPILE_KERNEL
2929

3030
clean:
3131
@rm -f test_kernel_demo

0 commit comments

Comments
 (0)