  A statistical mechanic study of the $XY$ model with nonlinear interaction is
presented on bipartite sparse random graphs. The model properties are compared
to those of the $p$-clock model, in which the planar continuous spins are
discretized into $p$ values. We test the goodness of the discrete approximation
to the XY spins to be used in numerical computations and simulations and its
limits of convergence in given, $p$-dependent, temperature regimes. The models
are applied to describe the mode-locking transition of the phases of
light-modes in lasers at the critical lasing threshold. A frequency is assigned
to each variable node and function nodes implement a frequency matching
condition. A non-trivial unmagnetized phase-locking occurs at the phase
transition, where the frequency dependence of the phases turns out to be linear
in a broad range of frequencies, as in standard mode-locking multimode laser at
the optical power threshold.
