It sounds to me that you have the right understanding of everything. Because y is independent, that is, not computed using anything else, it’s essentially the “start” of the autograd graph. You’re right in saying that using a new input will result in a “new” autograd graph that is not connected.
In an LSTM, the hidden state is explicitly computed using the previous part p. Therefore, once we’re starting to work on q, it utilizes that hidden state and therefore depends on p (or at least, how we utilized p to compute this hidden state).
I’m still not sure what you mean with detaching the the hidden state, I don’t believe we do this while in the middle of a sequence since we want to adjust how we compute this hidden state.