Based on your code it looks you would like to learn the addition of two numbers in binary representation by passing one bit at a time. Is this correct?
Currently it seems you are not detaching the hidden state at any time, just in the initialization step of your model. Could you try to create a new hidden state for each new addition?