Skip to content

Commit 42e904d

Browse files
committed
fix(device-ir): remove dead epoch accessors, fix sync and guard issues
1 parent d0c40ff commit 42e904d

7 files changed

Lines changed: 7 additions & 69 deletions

File tree

bindings/ir/flagcx_device_scalar_ir.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
*
99
* Design:
1010
* - CoopAny/Team replaced by flagcxCoopKind_t / flagcxTeamKind_t enums
11-
* - Barrier split arrive/wait use stampEpoch internally
1211
* - Net (transport) obtained via flagcxDevNetGetFromCommS (pre-allocated)
1312
*
1413
* When compiled to LLVM bitcode (clang -x cuda --cuda-device-only),

bindings/ir/public_symbols.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,10 +102,12 @@ flagcxGetTeamInter
102102
flagcxGetTeamIntra
103103
flagcxGetTeamWorld
104104
flagcxInterBarrierArriveS
105+
flagcxInterBarrierSessionInit
105106
flagcxInterBarrierSessionSync
106107
flagcxInterBarrierSyncS
107108
flagcxInterBarrierWaitS
108109
flagcxIntraBarrierArriveS
110+
flagcxIntraBarrierSessionInit
109111
flagcxIntraBarrierSessionArrive
110112
flagcxIntraBarrierSessionSync
111113
flagcxIntraBarrierSessionWait
@@ -116,6 +118,7 @@ flagcxTeamRankToIntraS
116118
flagcxTeamRankToWorldC
117119
flagcxTeamRankToWorldS
118120
flagcxWorldBarrierArriveS
121+
flagcxWorldBarrierSessionInit
119122
flagcxWorldBarrierSessionSync
120123
flagcxWorldBarrierSyncS
121124
flagcxWorldBarrierWaitS

flagcx/adaptor/flagcx_device.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1324,8 +1324,8 @@ extern "C" flagcxResult_t flagcxDevCommGetDevicePtr(flagcxDevComm_t devComm,
13241324
deviceAdaptor->deviceMemcpy(netCtxField, &netDevPtr, sizeof(void *),
13251325
flagcxMemcpyHostToDevice, NULL, NULL),
13261326
res, fail);
1327-
// Ensure net construction is complete before pointer escapes
1328-
FLAGCXCHECKGOTO(deviceAdaptor->streamSynchronize(NULL), res, fail);
1327+
// Ensure net construction + pointer patch are visible to all streams
1328+
FLAGCXCHECKGOTO(deviceAdaptor->deviceSynchronize(), res, fail);
13291329
}
13301330

13311331
devComm->cachedDevicePtr = dPtr;

flagcx/adaptor/include/device_api/default_comm_traits.h

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -854,10 +854,6 @@ struct Barrier<Default<P>, flagcxTeamTagIntra, Coop> {
854854
arrive(order);
855855
wait(order);
856856
}
857-
858-
// S-API epoch accessors
859-
FLAGCX_DEVICE_INLINE_DECORATOR uint64_t getEpoch() const { return _epoch; }
860-
FLAGCX_DEVICE_INLINE_DECORATOR void setEpoch(uint64_t e) { _epoch = e; }
861857
};
862858

863859
// ---- Barrier<Default<P>, flagcxTeamTagInter, Coop> ----
@@ -937,10 +933,6 @@ struct Barrier<Default<P>, flagcxTeamTagInter, Coop> {
937933
arrive(order);
938934
wait(order);
939935
}
940-
941-
// S-API epoch accessors
942-
FLAGCX_DEVICE_INLINE_DECORATOR uint64_t getEpoch() const { return _epoch; }
943-
FLAGCX_DEVICE_INLINE_DECORATOR void setEpoch(uint64_t e) { _epoch = e; }
944936
};
945937

946938
// ---- Barrier<Default<P>, flagcxTeamTagWorld, Coop> ----
@@ -1026,20 +1018,6 @@ struct Barrier<Default<P>, flagcxTeamTagWorld, Coop> {
10261018
_intra.wait(order);
10271019
}
10281020
}
1029-
1030-
// S-API epoch accessors (world = intra + inter)
1031-
FLAGCX_DEVICE_INLINE_DECORATOR uint64_t getIntraEpoch() const {
1032-
return _intra.getEpoch();
1033-
}
1034-
FLAGCX_DEVICE_INLINE_DECORATOR void setIntraEpoch(uint64_t e) {
1035-
_intra.setEpoch(e);
1036-
}
1037-
FLAGCX_DEVICE_INLINE_DECORATOR uint64_t getInterEpoch() const {
1038-
return _inter.getEpoch();
1039-
}
1040-
FLAGCX_DEVICE_INLINE_DECORATOR void setInterEpoch(uint64_t e) {
1041-
_inter.setEpoch(e);
1042-
}
10431021
};
10441022

10451023
#endif // FLAGCX_FALLBACK_DEVICE_TRAITS_H_

flagcx/adaptor/include/device_api/flagcx_device_core.h

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -534,14 +534,6 @@ struct flagcxDevBarrier<flagcxTeamTagIntra, Coop> {
534534
sync(flagcxDeviceMemoryOrder_t order = flagcxDeviceMemoryOrderAcqRel) {
535535
_impl.sync(order);
536536
}
537-
538-
// S-API epoch accessors
539-
FLAGCX_DEVICE_INLINE_DECORATOR uint64_t getEpoch() const {
540-
return _impl.getEpoch();
541-
}
542-
FLAGCX_DEVICE_INLINE_DECORATOR void setEpoch(uint64_t e) {
543-
_impl.setEpoch(e);
544-
}
545537
};
546538

547539
// ============================================================
@@ -918,14 +910,6 @@ struct flagcxDevBarrier<flagcxTeamTagInter, Coop> {
918910
flagcxDevNetFenceLevel fence = flagcxDevNetFenceLevel::Relaxed) {
919911
_impl.sync(order, fence);
920912
}
921-
922-
// S-API epoch accessors
923-
FLAGCX_DEVICE_INLINE_DECORATOR uint64_t getEpoch() const {
924-
return _impl.getEpoch();
925-
}
926-
FLAGCX_DEVICE_INLINE_DECORATOR void setEpoch(uint64_t e) {
927-
_impl.setEpoch(e);
928-
}
929913
};
930914

931915
// ---- World ----
@@ -970,20 +954,6 @@ struct flagcxDevBarrier<flagcxTeamTagWorld, Coop> {
970954
flagcxDevNetFenceLevel fence = flagcxDevNetFenceLevel::Relaxed) {
971955
_impl.sync(order, fence);
972956
}
973-
974-
// S-API epoch accessors (world = intra + inter)
975-
FLAGCX_DEVICE_INLINE_DECORATOR uint64_t getIntraEpoch() const {
976-
return _impl.getIntraEpoch();
977-
}
978-
FLAGCX_DEVICE_INLINE_DECORATOR void setIntraEpoch(uint64_t e) {
979-
_impl.setIntraEpoch(e);
980-
}
981-
FLAGCX_DEVICE_INLINE_DECORATOR uint64_t getInterEpoch() const {
982-
return _impl.getInterEpoch();
983-
}
984-
FLAGCX_DEVICE_INLINE_DECORATOR void setInterEpoch(uint64_t e) {
985-
_impl.setInterEpoch(e);
986-
}
987957
};
988958

989959
// Backward-compatible aliases

flagcx/adaptor/include/device_api/nvidia_comm_traits.h

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -500,10 +500,6 @@ struct Barrier<NvidiaVendor, flagcxTeamTagIntra, Coop> {
500500
reinterpret_cast<ncclLsaBarrierSession<ncclCoopCta> *>(_implStorage)
501501
->sync(ncclCoopCta(), Atomic::toNativeOrder(order));
502502
}
503-
504-
// S-API epoch accessors — NCCL manages epoch internally; no-op
505-
FLAGCX_DEVICE_INLINE_DECORATOR uint64_t getEpoch() const { return 0; }
506-
FLAGCX_DEVICE_INLINE_DECORATOR void setEpoch(uint64_t) {}
507503
};
508504

509505
// ---- Barrier<NvidiaVendor, flagcxTeamTagInter, Coop> ----
@@ -559,10 +555,6 @@ struct Barrier<NvidiaVendor, flagcxTeamTagInter, Coop> {
559555
flagcxDevNetFenceLevelMap[static_cast<int>(fence)]);
560556
}
561557
}
562-
563-
// S-API epoch accessors — NCCL manages epoch internally; no-op
564-
FLAGCX_DEVICE_INLINE_DECORATOR uint64_t getEpoch() const { return 0; }
565-
FLAGCX_DEVICE_INLINE_DECORATOR void setEpoch(uint64_t) {}
566558
};
567559

568560
// ---- Barrier<NvidiaVendor, flagcxTeamTagWorld, Coop> ----
@@ -661,12 +653,6 @@ struct Barrier<NvidiaVendor, flagcxTeamTagWorld, Coop> {
661653
flagcxDevNetFenceLevelMap[static_cast<int>(fence)]);
662654
}
663655
}
664-
665-
// S-API epoch accessors — NCCL manages epoch internally; no-op
666-
FLAGCX_DEVICE_INLINE_DECORATOR uint64_t getIntraEpoch() const { return 0; }
667-
FLAGCX_DEVICE_INLINE_DECORATOR void setIntraEpoch(uint64_t) {}
668-
FLAGCX_DEVICE_INLINE_DECORATOR uint64_t getInterEpoch() const { return 0; }
669-
FLAGCX_DEVICE_INLINE_DECORATOR void setInterEpoch(uint64_t) {}
670656
};
671657
#endif // NCCL_CHECK_CUDACC
672658

flagcx/kernels/device_api_host_helpers.cu

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ static __global__ void flagcxDevNetConstructKernel(flagcxDevNet *nets,
2828
// synchronizing the stream afterwards.
2929
extern "C" void flagcxDevNetLaunchConstruct(void *devNets, void *devComm,
3030
int count, void *stream) {
31+
if (count <= 0 || devNets == nullptr || devComm == nullptr)
32+
return;
3133
int threads = (count < 256) ? count : 256;
3234
int blocks = (count + threads - 1) / threads;
3335
flagcxDevNetConstructKernel<<<blocks, threads, 0, (cudaStream_t)stream>>>(

0 commit comments

Comments
 (0)