AbstractLet$p\gt 2$be prime. We state and prove (under mild hypotheses on the residual representation) a geometric refinement of the Breuil–Mézard conjecture for two-dimensional mod$p$representations of the absolute Galois group of${ \mathbb{Q} }_{p} $. We also state a conjectural generalization to$n$-dimensional representations of the absolute Galois group of an arbitrary finite extension of${ \mathbb{Q} }_{p} $, and give a conditional proof of this conjecture, subject to a certain$R= \mathbb{T} $-type theorem together with a strong version of the weight part of Serre’s conjecture for rank $n$unitary groups. We deduce an unconditional result in the case of two-dimensional potentially Barsotti–Tate representations.