  We study generalized quasirandom graphs whose vertex set consists of $q$
parts (of not necessarily the same sizes) with edges within each part and
between each pair of parts distributed quasirandomly; such graphs correspond to
the stochastic block model studied in statistics and network science. Lov\'asz
and S\'os showed that the structure of such graphs is forced by homomorphism
densities of graphs with at most $(10q)^q+q$ vertices; subsequently, Lov\'asz
refined the argument to show that graphs with $4(2q+3)^8$ vertices suffice. Our
results imply that the structure of generalized quasirandom graphs with $q\ge
2$ parts is forced by homomorphism densities of graphs with at most $4q^2-q$
vertices, and, if vertices in distinct parts have distinct degrees, then $2q+1$
vertices suffice. The latter improves the bound of $8q-4$ due to Spencer.

Combinatorics