Right this is a different question:
The short answer is that the .grad field is only populated for leaf Tensors (Tensors with no history). And the result of the repeat/expand is not a leaf. So what you see is expected.
You will need to have 2 Tensors, one that is the original Parameter with a single element that is a leaf. And the expanded/repeated one that is used in the forward (that won’t get gradient).
Or you can move the repeat/expand to the forward (the safest bet as it does not rely on internal implementation details of expand/repeat).