@@ -96,9 +96,20 @@ def __init__(
9696 self .available = True
9797 self .disabled = False
9898
99+ try :
100+ _flagcx_version = ctypes .c_int ()
101+ self .flagcx ._funcs ["flagcxGetVersion" ](
102+ ctypes .byref (_flagcx_version ))
103+ self ._legacy_unique_id_api = _flagcx_version .value < 1300
104+ except (AttributeError , KeyError , TypeError ):
105+ self ._legacy_unique_id_api = False
106+
99107 if self .rank == 0 :
100108 # get the unique id from NCCL
101- self .unique_id = self .flagcx .flagcxGetUniqueId ()
109+ if self ._legacy_unique_id_api :
110+ self .unique_id = self .flagcx .flagcxGetUniqueId ().contents
111+ else :
112+ self .unique_id = self .flagcx .flagcxGetUniqueId ()
102113 else :
103114 # construct an empty unique id
104115 self .unique_id = flagcxUniqueId ()
@@ -133,8 +144,12 @@ def __init__(
133144 device_ctx = torch .cuda .device (self .device )
134145
135146 with device_ctx :
136- self .comm = self .flagcx .flagcxCommInitRank (
137- self .world_size , self .unique_id , self .rank )
147+ if self ._legacy_unique_id_api :
148+ self .comm = self .flagcx .flagcxCommInitRank (
149+ self .world_size , ctypes .byref (self .unique_id ), self .rank )
150+ else :
151+ self .comm = self .flagcx .flagcxCommInitRank (
152+ self .world_size , self .unique_id , self .rank )
138153
139154 stream = current_stream ()
140155 # A small all_reduce for warmup.
0 commit comments