# How to use "break" in DistributedDataParallel training

**URL:** <https://discuss.pytorch.org/t/how-to-use-break-in-distributeddataparallel-training/88296>\
**Category:** distributed-rpc\
**Created:** [July 7, 2020, 10:13pm UTC](https://discuss.pytorch.org/t/how-to-use-break-in-distributeddataparallel-training/88296 "2020-07-07T22:13:59Z")\
**Posts on this page:** 1\
**Showing post:** 7

<div class="post-metadata">

**Author:** ![Rakshith\_V](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/rakshith_v/32/46078_2.png) [@Rakshith\_V](https://discuss.pytorch.org/u/Rakshith_V)\
**Post date:** [June 2, 2022, 4:52am UTC](https://discuss.pytorch.org/t/how-to-use-break-in-distributeddataparallel-training/88296/7 "2022-06-02T04:52:57Z")

</div>

flag\_tensor = torch.zeros(1).to(device)  
if local\_rank = 0:  
----------#Conditions for breaking the loop :  
-------------------flag\_tensor += 1  
dist.all\_reduce(flag\_tensor,op=ReduceOp.SUM)  
if flag\_tensor == 1:  
----------print(“Training stopped”)  
----------break

---

_[View the full topic](https://discuss.pytorch.org/t/how-to-use-break-in-distributeddataparallel-training/88296)._
