So in general, if we perform a loss function on the output of a model, we would expect that any module (parameters) that the input came across would receive a gradient. If we’re finding that some of your parameters are not being given a gradient (thus not changing after a step), then they must not be affecting the output.
It’s possible that some parameters are being used, but are perfect such that their gradient is 0. But I’m going to assume that this isn’t the case.
Is the len(input) suppose to be at least k? I notice that if input isn’t long enough, some encoders in your module list might not be accessed. I would print out k here and assure that all your encoders are being touched. Otherwise it appears to me that the data is flowing correctly.
Something else you can do is iterate over the encoders and make sure that their gradients are not None and have non-zero values in them. It could be that some gradients are so small that they’re appearing to not be changing (but they are).