  In the present paper we study the rigidity of 2-step Carnot groups, or
equivalently, of graded 2-step nilpotent Lie algebras. We prove the alternative
that depending on bi-dimensions of the algebra, the Lie algebra structure makes
it either always of infinite type or generically rigid, and we specify the
bi-dimensions for each of the choices. Explicit criteria for rigidity of pseudo
$H$- and $J$-type algebras are given. In particular, we establish the relation
of the so-called $J^2$-condition to rigidity, and we explore these conditions
in relation to pseudo $H$-type algebras.
