Because when you do generation you usually do a single pass in the encoder and reuse it’s output for the subsequent token generation for efficiency so you need to access the encoder output from the first forward pass.