For what finite groups is the cardinality of a minimal generating set well defined? Recently I learned that the cardinality of a minimal set of generators of a finite $p$-group
$G$ is well defined namely it is equal to the dimension of $H^1(G,\mathbb{F}_p)$. Moreover, if
$S:=\{g_1,\ldots,g_s\}$ is a minimal generating set of $G$ then the cardinality of a minimal set of relations with respect to $S$ is also a well defined integer, namely it is equal to the
dimension of $H^2(G,\mathbb{F}_p)$.
For a general group, the cardinality of a minimal set of generators is not well defined. Take for example the symmetric group of degree $n$. For instance you may get a cardinality equal to $2$ or $n-1$.
Q1: So for what class of finite groups do we expect the cardinality of a minimal generating set to be well defined?
P.S. By "a minimal set of generators" I mean "irredundant", that is the set that generates the group, but no proper subset does.
 A: This is an answer for the abelian case only. 
For a finite abelian group (let us exclude the trivial one) there are two standard ways to decompose it as a direct sum of cyclic groups. One into cyclic groups of order $n_1,\dots,n_r$ (not $1$) such that $n_i \mid n_{i+1}$ and the other one into cyclic groups of order $m_1, \dots, m_s$ such that each $m_i$ is a prime power (not $1$). [Under each of the assumptions 'divisibility' and 'prime power' the repective decomposition is unique, in the latter case of course up to the ordering.]
The parameter $r$ is sometimes called the rank and the parameter $s$ the total rank of the group (although terminology here is not completely uniform).
Now, it is known that the rank is the minimal cardinality of a generating set, in the sense that there does not exists a set of a smaller cardinality that generates the group.
And, that the total rank is the maximal cardinality of a minimal generating set, that is there exists a generating set of cardinailty $s$ such that no subset of this set generates the group.
Thus, the cardinality of all minimal/irredundant generating set is uniquely determined if and only if the rank equals the total rank. 
This is the case if and only if the group is an (abelian) $p$-groups. 
Note that for a non-$p$-group on can first consider the first decomposition into cycylic groups, and then decompose each cyclic component as the sum of cyclic groups of prime power order (more or less Chines Remainder Theorem); so only if all the orders in the first decomposition are also prime powers (and thus necessarily powers of the same prime) does one not get a different value for rank and total rank.   
