@@ -141,6 +141,7 @@ def shuffle_layer(
141141
142142 p2p_ops : list [P2POp ] = []
143143
144+
144145 # 2. Initiate sending of weights.
145146 experts_send_loc : dict [int , int ] = {}
146147 for src in range (num_local_experts ):
@@ -224,11 +225,42 @@ def shuffle_layer(
224225 for weight in expert_weights_buffer
225226 ]
226227
228+ # op_info = []
229+ # for op in p2p_ops:
230+ # if op is None:
231+ # op_info.append(None)
232+ # continue
233+
234+ # op_data = {
235+ # 'isend': op.op.__name__ == "isend",
236+ # 'peer': op.peer,
237+ # 'tag': getattr(op, 'tag', 0),
238+ # 'tensor_shape': op.tensor.shape,
239+ # 'tensor_dtype': op.tensor.dtype,
240+ # 'tensor_device': op.tensor.device,
241+ # }
242+ # op_info.append(op_data)
243+ # torch.save({"op":op_info}, f"op_info_device_{ep_rank}.pt")
244+
227245 # 4. Execute the P2P operations. The real communication happens here.
228246 if p2p_ops :
229247 reqs = batch_isend_irecv (p2p_ops )
230248 for req in reqs :
231249 req .wait ()
250+ # if p2p_ops:
251+ # reqs = []
252+ # for op in p2p_ops:
253+ # if op is None:
254+ # continue
255+ # if op.op.__name__ == "isend":
256+ # print("isend: ", op.peer)
257+ # req = torch.distributed.isend(op.tensor, op.peer, op.group, op.tag)
258+ # else:
259+ # print("irecv: ", op.peer)
260+ # req = torch.distributed.irecv(op.tensor, op.peer, op.group, op.tag)
261+ # reqs.append(req)
262+ # for req in reqs:
263+ # req.wait()
232264
233265 # 5. Copy the weights from the buffer back to the original weights.
234266 for dst in range (num_local_experts ):
@@ -325,6 +357,7 @@ def rearrange_expert_weights_inplace(
325357 # NOTE(bowen): We need this synchronize to run, but I don't know why.
326358 # If you figure out the reason, please let me know -- thank you!
327359 torch .cuda .synchronize ()
360+ print ("layer: " , layer )
328361 shuffle_layer (
329362 num_local_physical_experts ,
330363 ep_rank ,
0 commit comments