let $g$ be a finite group. a subset $x$ of $g$ is a set of pairwise non-commuting elements if any two distinct elements of $x$ do not commute. in this paper we determine the maximum size of these subsets in any finite non-abelian metacyclic $2$-group and in any finite non-abelian $p$-group with an abelian maximal subgroup.