You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Why remove tolerate_dup_recv from LocaRendezvous. #11825
I did not find a PR for this patch. Maybe this discussion belongs to that particular commit page. If so, I will move it there.
Can somebody explain the rationale behind this patch? Current contrib/verbs uses exactly this flag to transfer tensors. Note it is set true here. Removing it totally breaks verbs. I am asking if this patch is absolutely needed since there is no simple workaround for contrib/verbs without this flag.
Can we revert this patch? Just looking at the patch alone, I feel it is cosmetic (cleaning up a parameter that is not used in the core code). Or maybe I missed something important.
It was removed because we no longer needed it for our internal networking, where it was needed to deal with hardware errors in an earlier generation of machines. Turning this feature on comes at a cost of higher memory use, since tensors backing sent values cannot be garbage collected until the end of the step. Also, there may be some upcoming feature whose implementation was made more difficult by allowing this option.
I should have noticed you were using this, and pinged you: sorry! How important is this feature to verbs support? It is a convenience, or is it not possible to make the service reliable without it?
@poxvoculi This is a corner stone of the current verbs design, where the receiving side could make multiple Recv attempts. Since the pinned memory is shared, a single Recv attempt may not be successful if the shared memory is used by other transmission.
But no worries, let us see if we can do without it.
@junshi15 You mentioned about shared pinned memory, and I am wondering if this could be resolved by increasing the amount of pinned memory permitted for multiple concurrent transmissions. For sake of easier implementation, a memory pool allowing growth may fit your needs, e.g. BFCAllocator or PoolAllocator.
@byronyi Using more memory can alleviate memory access conflicts, but can not totally eliminate it, since we don't know a priori what is the max parallelism. Once a conflict happens, some kind of retry is needed. We have been relying on tolerate_dup_recv for the re-tries.
@junshi15
Maybe I'm missing something, but I don't see where we have a shared pinned memory in the design.
Each RdmaTensorBuffer (hashed by its name) has it's own pinned buffer on both sides.
I thought the necessity of the tolerate_dup_recv in the verbs code is the RDMA_BUFFER_REQUEST (first Tensor transfer, change in tensor size) which will follow a second RecvAsyncLocal.
@shamoya Yes, there are three cases we have multiple RecvAsyncLocal. You listed the first two.
initial transfer, both sides need to step up the buffer first, then transfer. Two calls to RecvAsyncLocal.
change of tensor size. similar to (1).
concurrent transfer. Note the buffer is hashed by the tensor name, without the step_id. If the same tensor with two different step_ids need to be transferred at the same time, there will be a collision at the buffer. When this happens, one tensor needs a re-try. I think I have seen this kind of situation in Async training cases, but I did not dig deeper.
So, how do we go from here?
Assuming we don't have duplicated recv support, we need to send the Tensor in one shot in all cases.
Maybe we can revert to RDMA_SEND on those cases ?
@shamoya With my limited understanding of RDMA_SEND, I do not see how it can solve the problem.
With RDMA_SEND, the receiver specifies destination MR. But the MR needs to be created first. To create it, the receiver needs to know its size. The size is on the sender side. So it seems to me you still need to duplicate recv at least twice, first, get the size; second, send the tensor.
Correct me if I am wrong, my understanding of RDMA_SEND is that it requires the same ordering at both sender and receiver. If the sender post_send A, B and C, in that order, but the receiver post_recv B, C and A. Then A goes to B's buffer, B goes to C's buffer, C goes to A's buffer. I do not know if we can enforce the ordering strictly.
I do not have a simple solution to work around duplicate_recv. One solution will be to buffer the tensors and its callback, if any, inside RDMARendezvous. We do local_recv once, if that tensor can not be sent for any reason, i.e. MR not initialized, size changed, buffer busy, etc, we will just make a full copy of the tensor and put it in a table inside RDMARendezvous. For future recv of the same tensor, we look it up here instead of going to that waiter-table. Basically, we need to duplicate that waiter-table inside RDMARendezvous. Not a clean solution, but maybe doable.
Thanks @junshi15 for the feedback.
For the first issue I thought about maybe having some kind of a tensor buffers pools (max size), and maybe use it for the above cases, but you're about the second issue (ordering) and overall this is a not a good plan.
Your idea sounds good and maybe we could progress with it.
Let me try to do a quick check and get back to you.
Do you want me to get in on this?
I was thinking of duplicating the waiter table into the Tensor-Buffer, instead of the rendezvous.
So the reaction to RDMA_MESSAGE_BUFFER_RESPONSE would be similar to SendNextItem() but would replace RecvLocalAsync with a lookup in it's local table.
I think a seperate queue for items is also required for this to work.
@yanivbl6@junshi15
Since we are now buffer and the tensor (to be sent), need to think how to tell the device (in which the tensor reside) not to free the it (device->context->Ref() ) or we can already allocate the local buffer and copy it to there already ?
@yanivbl6 Feel free to contribute. You may want to coordinate with @shamoya who has spent a lot time on this. I have been occupied by projects at work and won't have much time on this in the near future. @shamoya I think the waiter should handle reference counting. The original reference counting was wrong, as you pointed out. We need to fix this in the new patch.
Thanks @junshi15 , me and @yanivbl6 are working together.
BTW, I found what did the missing UnRef() we had in the tolerate_dup_recv - Here
At the end of the step, someone is pulling all the remaining items in the table and deleting them.
Activity
reedwm commentedon Jul 27, 2017
/CC @zffchen78
shamoya commentedon Aug 9, 2017
@junshi15 @reedwm @poxvoculi - How do we proceed here ?
The tolerate_dup_recv is needed by the verbs code.
junshi15 commentedon Aug 9, 2017
Can we revert this patch? Just looking at the patch alone, I feel it is cosmetic (cleaning up a parameter that is not used in the core code). Or maybe I missed something important.
junshi15 commentedon Aug 9, 2017
While we are looking for the motivation behind this change, we will also investigate how to adapt verbs code to accommodate this change.
poxvoculi commentedon Aug 9, 2017
It was removed because we no longer needed it for our internal networking, where it was needed to deal with hardware errors in an earlier generation of machines. Turning this feature on comes at a cost of higher memory use, since tensors backing sent values cannot be garbage collected until the end of the step. Also, there may be some upcoming feature whose implementation was made more difficult by allowing this option.
I should have noticed you were using this, and pinged you: sorry! How important is this feature to verbs support? It is a convenience, or is it not possible to make the service reliable without it?
junshi15 commentedon Aug 9, 2017
@poxvoculi This is a corner stone of the current verbs design, where the receiving side could make multiple Recv attempts. Since the pinned memory is shared, a single Recv attempt may not be successful if the shared memory is used by other transmission.
But no worries, let us see if we can do without it.
byronyi commentedon Aug 9, 2017
@junshi15 You mentioned about shared pinned memory, and I am wondering if this could be resolved by increasing the amount of pinned memory permitted for multiple concurrent transmissions. For sake of easier implementation, a memory pool allowing growth may fit your needs, e.g. BFCAllocator or PoolAllocator.
junshi15 commentedon Aug 9, 2017
@byronyi Using more memory can alleviate memory access conflicts, but can not totally eliminate it, since we don't know a priori what is the max parallelism. Once a conflict happens, some kind of retry is needed. We have been relying on tolerate_dup_recv for the re-tries.
shamoya commentedon Aug 15, 2017
@junshi15
Maybe I'm missing something, but I don't see where we have a shared pinned memory in the design.
Each RdmaTensorBuffer (hashed by its name) has it's own pinned buffer on both sides.
I thought the necessity of the tolerate_dup_recv in the verbs code is the RDMA_BUFFER_REQUEST (first Tensor transfer, change in tensor size) which will follow a second RecvAsyncLocal.
junshi15 commentedon Aug 15, 2017
@shamoya Yes, there are three cases we have multiple RecvAsyncLocal. You listed the first two.
initial transfer, both sides need to step up the buffer first, then transfer. Two calls to RecvAsyncLocal.
change of tensor size. similar to (1).
concurrent transfer. Note the buffer is hashed by the tensor name, without the step_id. If the same tensor with two different step_ids need to be transferred at the same time, there will be a collision at the buffer. When this happens, one tensor needs a re-try. I think I have seen this kind of situation in Async training cases, but I did not dig deeper.
shamoya commentedon Aug 17, 2017
Thanks @junshi15 for explaining.
So, how do we go from here?
Assuming we don't have duplicated recv support, we need to send the Tensor in one shot in all cases.
Maybe we can revert to RDMA_SEND on those cases ?
Ido
junshi15 commentedon Aug 17, 2017
@shamoya With my limited understanding of RDMA_SEND, I do not see how it can solve the problem.
With RDMA_SEND, the receiver specifies destination MR. But the MR needs to be created first. To create it, the receiver needs to know its size. The size is on the sender side. So it seems to me you still need to duplicate recv at least twice, first, get the size; second, send the tensor.
Correct me if I am wrong, my understanding of RDMA_SEND is that it requires the same ordering at both sender and receiver. If the sender post_send A, B and C, in that order, but the receiver post_recv B, C and A. Then A goes to B's buffer, B goes to C's buffer, C goes to A's buffer. I do not know if we can enforce the ordering strictly.
I do not have a simple solution to work around duplicate_recv. One solution will be to buffer the tensors and its callback, if any, inside RDMARendezvous. We do local_recv once, if that tensor can not be sent for any reason, i.e. MR not initialized, size changed, buffer busy, etc, we will just make a full copy of the tensor and put it in a table inside RDMARendezvous. For future recv of the same tensor, we look it up here instead of going to that waiter-table. Basically, we need to duplicate that waiter-table inside RDMARendezvous. Not a clean solution, but maybe doable.
What do you think?
shamoya commentedon Aug 22, 2017
Thanks @junshi15 for the feedback.
For the first issue I thought about maybe having some kind of a tensor buffers pools (max size), and maybe use it for the above cases, but you're about the second issue (ordering) and overall this is a not a good plan.
Your idea sounds good and maybe we could progress with it.
Let me try to do a quick check and get back to you.
yanivbl6 commentedon Aug 27, 2017
Do you want me to get in on this?
I was thinking of duplicating the waiter table into the Tensor-Buffer, instead of the rendezvous.
So the reaction to RDMA_MESSAGE_BUFFER_RESPONSE would be similar to SendNextItem() but would replace RecvLocalAsync with a lookup in it's local table.
I think a seperate queue for items is also required for this to work.
shamoya commentedon Aug 27, 2017
@yanivbl6 @junshi15
Since we are now buffer and the tensor (to be sent), need to think how to tell the device (in which the tensor reside) not to free the it (device->context->Ref() ) or we can already allocate the local buffer and copy it to there already ?
junshi15 commentedon Aug 27, 2017
@yanivbl6 Feel free to contribute. You may want to coordinate with @shamoya who has spent a lot time on this. I have been occupied by projects at work and won't have much time on this in the near future.
@shamoya I think the waiter should handle reference counting. The original reference counting was wrong, as you pointed out. We need to fix this in the new patch.
shamoya commentedon Aug 28, 2017
Thanks @junshi15 , me and @yanivbl6 are working together.
BTW, I found what did the missing UnRef() we had in the tolerate_dup_recv - Here
At the end of the step, someone is pulling all the remaining items in the table and deleting them.
tensorflowbutler commentedon Dec 20, 2017
It has been 14 days with no activity and this issue has an assignee.Please update the label and/or status accordingly.
junshi15 commentedon Dec 20, 2017
This issue is addressed by #12705