Let $n\geq 2$ and $1 \leq r \leq n$. Consider the set $S_r=(A \in M_n(\mathbb{Z}_2), rankA=r)$. Compute the sum $\sum_{X \in S_r}X$
1. **Understanding the problem**: We are given a set \( S_r \) which consists of all \( n \times n \) matrices over the field \(\mathbb{Z}_2\) (the field with two elements, 0 and 1) that have rank \( r \). We need to compute the sum \(\sum_{X \in S_r} X\).

2. **Properties of the sum**: Let \( S = \sum_{X \in S_r} X \). We need to show that \( S \) is the zero matrix \( O_n \).

3. **Action of invertible matrices**: Consider any invertible matrix \( A \in M_n(\mathbb{Z}_2) \). For any matrix \( X \in S_r \), the matrix \( AX \) is also in \( S_r \) because the rank of \( AX \) is the same as the rank of \( X \) (since \( A \) is invertible). Therefore, multiplying \( S \) by \( A \) on the left does not change the sum:
   \[
   AS = \sum_{X \in S_r} AX = \sum_{Y \in S_r} Y = S
   \]
   This implies that \( AS = S \) for all invertible matrices \( A \).

4. **Permutation matrices**: Consider permutation matrices, which are a subset of invertible matrices. Permutation matrices permute the rows of a matrix. Since \( AS = S \) for all permutation matrices \( A \), it follows that all entries of \( S \) must be identical. This is because permutation matrices can move any entry of \( S \) to any other position, implying uniformity in the entries of \( S \).

5. **Entries of \( S \)**: Suppose all entries of \( S \) are 1. Then \( S \) would be the matrix with all entries equal to 1. However, we can find an invertible matrix \( A \) such that \( AS \neq S \). For example, if \( A \) is a permutation matrix that swaps two rows, the resulting matrix \( AS \) would still have all entries as 1, but the positions of the entries would be different, leading to a contradiction. Therefore, all entries of \( S \) cannot be 1.

6. **Conclusion**: Since the entries of \( S \) cannot all be 1 and they must be identical, the only possibility is that all entries of \( S \) are 0. Hence, \( S = O_n \).

\(\blacksquare\)

The final answer is \( \boxed{ O_n } \)