We introduce the notion of compatibility dimension for a set of quantum measurements: it is the largest dimension of a Hilbert space on which the given measurements are compatible. In the Schrödinger picture, this notion corresponds to testing compatibility with ensembles of quantum states supported on a subspace, using the incompatibility witnesses of Carmeli, Heinosaari, and Toigo. We provide several bounds for the compatibility dimension, using approximate quantum cloning or algebraic techniques inspired by quantum error correction. We analyze in detail the case of two orthonormal bases, and, in particular, that of mutually unbiased bases.