1: \begin{abstract}
2:
3: We study the subgroup structure of the infinite torsion $p$-groups defined by Gupta and Sidki in 1983.
4: In particular, following results of Grigorchuk and Wilson for the first Grigorchuk group, we show that all infinite finitely generated subgroups of the Gupta--Sidki 3-group $G$ are abstractly commensurable with $G$ or $G\times G$.
5: As a consequence, we show that $G$ is subgroup separable and from this it follows that its membership problem is solvable.
6:
7: Along the way, we obtain a characterization of finite subgroups of $G$ and establish an analogue for the Grigorchuk group.
8:
9: \end{abstract}
10: