  The current theoretical framework for topological phases of matter is based
on the thermodynamic limit of a system with geometrically local interactions. A
natural question is to what extent the notion of a phase of matter remains
well-defined if we relax the constraint of geometric locality, and replace it
with a weaker graph-theoretic notion of $k$-locality. As a step towards
answering this question, we analyze the stability of the energy gap to
perturbations for Hamiltonians corresponding to general quantum low-density
parity-check codes, extending work of Bravyi and Hastings [Commun. Math. Phys.
307, 609 (2011)]. A corollary of our main result is that if there exist
constants $\varepsilon_1,\varepsilon_2>0$ such that the size $\Gamma(r)$ of
balls of radius $r$ on the interaction graph satisfy $\Gamma(r) =
O(\exp(r^{1-\varepsilon_1}))$ and the local ground states of balls of radius
$r\le\rho^\ast = O(\log(n)^{1+\varepsilon_2})$ are locally indistinguishable,
then the energy gap of the associated Hamiltonian is stable against local
perturbations. This gives an almost exponential improvement over the
$D$-dimensional Euclidean case, which requires $\Gamma(r) = O(r^D)$ and
$\rho^\ast = O(n^\alpha)$ for some $\alpha > 0$. The approach we follow falls
just short of proving stability of finite-rate qLDPC codes, which have
$\varepsilon_1 = 0$; we discuss some strategies to extend the result to these
cases. We discuss implications for the third law of thermodynamics, as
$k$-local Hamiltonians can have extensive zero-temperature entropy.
