This problem is a variant of subset sum problem and in subset sum problem we have a target sum to achieve, according to which we can size our DP table but in our case we do not have any specific target sum but we want a sum which is divisible by some $m$. In the process we can have arbitrary intermediate sums and we do not have a clear bound to how to size the DP table.
One naive approach would be to have the maximum sum possible in the set divided by $m$, and then we can subtract the mod of that division from this maximum sum. This can be an upper bound to our possible sums in the set, but this can be very large for bigger values.
The solution is divided in two parts ($n$ is the no of elements in set):
$n > m$, for $n > m$ we will always have a subset with sum divisible by $m$.
$n <= m$
For the first case where $n > m$, let us define the set as $X = {X_1, X_2, ..., X_n}$. Now if any value $X_i$ is divisible by $m$, the claim trivially holds. Now, let us consider partial sets as $P_i = \{first\ i\ values\ of\ set\}$ and modular sum
as $S_i = sum(P_i)%m$. So,
$S_1 = (X_1)%m$
$S_2 = (X_1 + X_2)%m$
$S_n = (X_1 + X_2 + ... + X_n)%m$
If any of these values is 0 then the claim trivially holds as we have achieved a sum which is divisible by $m$. Also, if any of these value repeats i.e. some $S_i = S_j$ where $j > i$, then also this claim holds. (why? we have added a multiple of m to Si to achieve $S_j$ (e.g. 5%3 = 2 and 8%3 = 2, but 8-5 = 3)).
So this says that from $S_1$ to $S_N$ we must have distinct values. The range of mod function is 1 to $m-1$. Since
$n > m$, so for $S_1$ to $S_n$ some value should repeat from 1 to $m-1$. This is the pigeonhole principle in application.
For the second case we have the above solution. The mentality of this solution is that we will record all the mod values which can be obtained when partial sums are divided by $m$. If at any stage we capture the mod value to be zero then we are done. Also the bottom up procedure adds one element at each time.