---
title: 'mochi_class: Stable EFT Solver for Horndeski Models'
url: https://www.emergentmind.com/topics/mochi_class
type: topic
---

# mochi_class: Stable EFT Solver for Horndeski Models

Searching arXiv for the specified topic and closely related papers to ground the article.
mochi_class is an extension of the Einstein–Boltzmann solver hi_class, itself built on CLASS, developed to model the linear cosmology of Horndeski scalar–tensor gravity with arbitrary time-dependent inputs and an explicitly stability-oriented formulation. Its defining feature is the replacement of the conventional Horndeski $\alpha$-parametrisation by a stable effective-field-theory basis, so that broad classes of ghost-free and gradient-stable models can be explored without committing to hard-coded parametrisations or a specific covariant Lagrangian. In the original code paper and in subsequent phenomenological studies, mochi_class is presented both as a numerical solver and as a framework for non-parametric exploration of modified gravity, including weak-gravity sectors of Horndeski theory and minimally coupled kinetic gravity braiding models with phantom crossing [2407.11968].

## 1. Software lineage and scientific scope

mochi_class, whose title expands as “Modelling Optimisation to Compute Horndeski In class,” is a patch on top of hi_class and CLASS that changes how Horndeski gravity is specified and evolved at linear order. Rather than requiring either a covariant Horndeski action $G_i(\phi,X)$ or a small set of fixed functional forms for the EFT functions, it allows the modified-gravity sector and, if desired, the background expansion sector to be supplied as arbitrary precomputed functions of time. The code is publicly available at `https://github.com/mcataneo/mochi_class_public` [2407.11968].

The target theory space is Horndeski gravity in the gravitational-wave-compatible subclass with $\alpha_T=0$, so that tensor waves propagate at the speed of light. Within this sector, mochi_class is designed to compute the background expansion, the evolution of linear perturbations, CMB anisotropy spectra, linear matter power spectra $P(k,z)$, and derived modified-gravity observables such as $\mu(a,k)$ and $\gamma(a,k)$. Later applications explicitly use it to output CMB TT spectra, including the late-time ISW contribution, and linear matter power spectra for large ensembles of generated models [2508.05729].

Its development is motivated by several numerical and phenomenological issues in standard Horndeski scans. Direct sampling in $\alpha_i(a)$ space often allocates most prior volume to unstable or numerically pathological models. Hard-coded parametrisations such as $\alpha_i \propto \Omega_\Lambda(a)$ or $\alpha_i \propto \Omega_{\rm DE}(a)$ can also obscure viable sectors of theory space. mochi_class was introduced precisely to enlarge the accessible Horndeski landscape while improving robustness and reducing the need for fine-tuning [2407.11968].

## 2. Stable EFT basis and reconstruction of Horndeski functions

The theoretical core of mochi_class is a stable basis built from quantities that appear directly in the linear stability conditions. In the code paper, the basis is written as
\[
\{D_{\rm kin}(a),\,M_*^2(a),\,c_s^2(a),\,\alpha_{B0}\},
\]
together with a background descriptor such as $w_\phi(a)$ or $\rho_\phi(a)$. The positivity conditions
\[
D_{\rm kin}(a) > 0,\qquad M_*^2(a) > 0,\qquad c_s^2(a) > 0
\]
enforce the absence of scalar ghosts, a healthy effective Planck mass, and the absence of scalar gradient instabilities by construction [2407.11968].

The stable basis is related to the standard Bellini–Sawicki variables through
\[
D_{\rm kin} \equiv \alpha_K + \frac{3}{2}\alpha_B^2,
\qquad
\alpha_M \equiv \frac{d\ln M_*^2}{d\ln a},
\]
with $\alpha_B(a)$ reconstructed by solving a first-order differential equation and $\alpha_K(a)$ then obtained from
\[
\alpha_K(a) = D_{\rm kin}(a) - \frac{3}{2}\alpha_B(a)^2.
\]
This reconstruction strategy is central: the user specifies positive functions in the stable basis, while mochi_class reconstructs the conventional EFT functions internally [2407.11968].

Subsequent work adopts the same logic in an “inherently stable basis” written as
\[
[H(a),\,\Delta M^2(a),\,D_{\rm kin}(a),\,c_s^2(a),\,\alpha_{B0}],
\]
where $\Delta M^2(a)\equiv M^2(a)-1$. In that notation, $M^2(a)$ is the effective Planck mass and $\alpha_B(a)$ is again not freely input, but obtained by solving an ODE derived from the definition of $c_s^2$. This continuity of notation across code and applications is one of the reasons mochi_class can be used as a backend for non-parametric Horndeski model generation [2508.05729].

A recurrent practical point is that this basis avoids numerical cancellation problems in models where $c_s^2$ is analytically simple but numerically delicate. The code paper highlights designer $f(R)$ gravity as an example: in hi_class, cancellations can spuriously drive the derived $c_s^2$ negative, whereas in mochi_class $c_s^2(a)$ is supplied directly as an input function, preventing stable models from being misclassified as unstable [2407.11968].

## 3. Numerical approximations, activation schemes, and viability controls

A second defining component of mochi_class is its implementation of the quasi-static approximation at the level of the modified metric potentials rather than at the level of the scalar fluctuation equation. In Newtonian gauge, the QSA is written through Poisson-like relations for $\Psi$ and the slip parameter $\gamma(a,k)=\Phi/\Psi$, with modified-gravity functions $\mu(a,k)$ and $\gamma(a,k)$ constructed from precomputed background quantities such as $\mu_p(a)$, $\mu_\infty(a)$, and $\mu_{Z,\infty}(a)$. The code paper emphasizes that this scheme is especially accurate for models transitioning between super- and sub-Compton regimes [2407.11968].

mochi_class also introduces a GR-approximation scheme that activates modified gravity only after a user-chosen redshift. Above $z_{\rm gr}^{\rm smg}$ the code evolves exactly $\Lambda$CDM; at activation, the scalar degree of freedom is introduced with QSA-matched initial conditions so that $\Phi$ and $\Psi$ remain smooth. The implementation includes a braiding activation threshold, allowing the effective onset of modified gravity to be tied to the time when $|\alpha_B|$ exceeds a prescribed small value. This is intended to suppress numerical sensitivity to the poorly constrained very-early-time behavior of the EFT functions [2407.11968].

Beyond the physical stability conditions built into the basis, mochi_class monitors what the papers describe as “mathematical instabilities,” namely exponentially growing modes of the scalar fluctuation equation. The solver evaluates the growth rates implied by the coefficients of the scalar perturbation equation and rejects models whose real growth rates exceed a tunable threshold relative to $H$. Additional runtime checks include rejection of trajectories for which $\alpha_B(a)$ crosses the critical value $\alpha_B=2$, where the synchronous-gauge system inherits a known discontinuity from hi_class [2407.11968].

These numerical controls are not ancillary. They are part of the code’s scientific program: broad scans become feasible precisely because ghost and gradient stability are handled at the level of inputs, while pathological low-$k$ or rapidly growing solutions are filtered during explicit time integration.

## 4. Inputs, outputs, and operational workflow

At the user level, mochi_class separates the cosmological problem into a background sector and a modified-gravity sector. The background can be specified through `expansion_model = lcdm`, `w0wa`, `wext`, or `rho_de`. The modified-gravity side is selected with `gravity_model = stable_params`, in which case the user provides tabulated arrays for the stable basis as functions of $\ln a$ [2407.11968].

| Input block | Options or arrays | Function |
|---|---|---|
| Background | `lcdm`, `w0wa`, `wext`, `rho_de` | Specify $H(a)$, $w_\phi(a)$, or $\rho_\phi(a)$ |
| Stable gravity sector | `Delta_M2(lna)`, `D_kin(lna)`, `cs2(lna)`, `lna_smg`, `alpha_B0` via `parameters_smg` | Reconstruct $\alpha_M(a)$, $\alpha_B(a)$, and $\alpha_K(a)$ |
| Approximation controls | `method_gr_smg`, `z_gr_smg`, `method_qs_smg`, `braid_activation_threshold` | Control GR activation and QSA behavior |

The operational workflow is correspondingly modular. mochi_class reads the background and stable-basis arrays, computes $\rho_\phi(a)$ and $p_\phi(a)$ where needed, reconstructs $M_*^2(a)$ and $\alpha_M(a)$, integrates the braiding equation backward from the present using $\alpha_{B0}$, derives $\alpha_K(a)$ from $D_{\rm kin}$, stores QSA background quantities, and then solves the Einstein–Boltzmann system for the requested observables. In Python, the `classy` interface can pass arrays directly without file I/O [2407.11968].

The outputs are those of a general Einstein–Boltzmann solver specialized to Horndeski EFT: CMB angular power spectra, linear matter power spectra, growth observables, background tables, and effective modified-gravity functions. In the weak-gravity and KGB studies, these outputs are further used to analyze $\mu_\infty(a)$, $\Sigma(a,k)$, the ISW effect, CMB lensing, redshift-space distortions, weak lensing cosmic shear, and the galaxy–ISW cross-correlation [2508.05729].

## 5. Validation and relation to other Einstein–Boltzmann solvers

The code paper validates mochi_class against hi_class, EFTCAMB, and MGCAMB across simple EFT parametrisations and specific models such as cubic Galileon, nKGB, and $f(R)$. For scale-independent models, agreement between mochi_class and hi_class is reported at the $\sim 0.01\%$ level for the matter power spectrum. For Hu–Sawicki $f(R)$ with QSA, mochi_class agrees with MGCAMB within $\lesssim 0.025\%$ up to $k\sim 1\,h/{\rm Mpc}$. For designer $f(R)$, mochi_class with QSA differs from EFTCAMB by $\lesssim 0.2\%$ up to $k\sim 1\,h/{\rm Mpc}$, reaching $\sim 1\%$ at $k\sim 8\,h/{\rm Mpc}$; when QSA is disabled in mochi_class, the agreement is $\sim 10^{-4}$ [2407.11968].

The same comparison program is used to motivate the metric-level QSA. In $f(R)$ models, the original hi_class QSA, which treats the scalar fluctuation equation algebraically, produces percent-level errors on small scales, whereas the mochi_class implementation yields errors $\lesssim 0.25\%$ in linear $P(k)$ out to $k\sim 1\,h/{\rm Mpc}$. CMB spectra, including TT, TE, EE, and lensing, agree at $\lesssim 0.25\%$ across the tested setups, apart from TE zero-crossings where relative differences are not physically informative [2407.11968].

This validation establishes mochi_class as neither a separate phenomenological wrapper nor merely a different parametrisation layer. It is a Horndeski-enabled Einstein–Boltzmann solver whose principal distinctions are the stable EFT basis, the metric-level QSA, the activation scheme for late-time modified gravity, and explicit mathematical-stability diagnostics.

## 6. Non-parametric weak gravity and “stable islands”

A major application of mochi_class is the search for “stable islands of weak gravity” in Horndeski theory space. In “Stable Islands of Weak Gravity,” the solver is described as the computational backbone for a non-parametric exploration in which Gaussian processes generate time-dependent basis functions while directly enforcing stability and phenomenology criteria. The study begins from the inherently stable basis implemented in mochi_class and focuses first on weak-gravity models that suppress the growth of large-scale structure at late times [2508.05729].

In that analysis, weak gravity means $\mu_\infty(a)<1$ in the high-$k$ quasi-static regime. The small-scale effective gravitational coupling is written as
\[
\mu_\infty = \frac{1}{M^2}\left[1+\frac{(\alpha_B+2\alpha_M)^2}{2c_s^2 D_{\rm kin}}\right],
\]
so that a larger effective Planck mass suppresses gravity while the fifth-force contribution is always positive when $c_s^2>0$ and $D_{\rm kin}>0$. The no-slip condition
\[
\alpha_B=-2\alpha_M
\]
eliminates the fifth-force term, leaving
\[
\mu_\infty=\frac{1}{M^2}.
\]
This makes the design of weak gravity largely a question of constructing suitable $M^2(a)$ histories that remain stable when the full perturbation system is evolved [2508.05729].

The models are generated non-parametrically with Gaussian processes, using the public GPtools package and a squared-exponential kernel. The GP realizations are conditioned to approach GR at early times, to bias $M^2>1$ over an intermediate redshift interval relevant for structure growth, and, in some constructions, to satisfy “local-value” or “local-convergence” conditions at $a=1$. mochi_class then reconstructs $\alpha_B(a)$, performs the built-in stability checks, integrates perturbations, and outputs the observables used to identify viable model families. The study reports a broad range of weak-gravity islands and illustrates models that produce a $\sim 12\%$ suppression of linear power at $z=0$ relative to GR. It also shows that replacing the $\Lambda$CDM expansion history with the DESI $w_0w_a$CDM best fit still yields stable islands of weak gravity [2508.05729].

A notable negative result concerns a common intuition about local screening requirements. For no-slip models on a $\Lambda$CDM background, imposing both $M^2(1)=1$ and $\alpha_M(1)=0$ drives $c_s^2$ negative at late times, so there is no stable no-slip local-convergence weak-gravity model in that setting. By contrast, beyond-no-slip constructions with a non-zero fifth force can realize local-convergence solutions while remaining stable. This suggests that the viable weak-gravity sector is structured, rather than generic, even within the stable basis.

## 7. Minimally coupled KGB, phantom crossing, and current interpretive debates

A second major application uses mochi_class to test whether late-time phantom crossing requires non-minimal conformal coupling. “Non-parametric exploration of minimally coupled gravity with phantom crossing” studies the minimally coupled, luminal Horndeski subclass known as kinetic gravity braiding. In this setting,
\[
M_*^2=1,\qquad \alpha_M=0,\qquad \alpha_T=0,
\]
so the only nontrivial perturbation EFT functions are $\alpha_K$ and $\alpha_B$, while the background is specified by $\rho_\phi(a)$ or equivalently $w_\phi(a)$. The study uses mochi_class in its manifestly stable EFT-basis mode to scan these models non-parametrically [2512.13691].

The scan parameterizes the stable functions in terms of $x\equiv \ln a$,
\[
D(x)=\exp\!\left[\zeta_D x+b_D+\mathcal{E}_D(x)\right],
\qquad
c_s^2(x)=C_{c_s}\exp\!\left[\mathcal{E}_{c_s}(x)\right],
\]
where $\mathcal{E}_D$ and $\mathcal{E}_{c_s}$ are Gaussian-process draws with squared-exponential covariance. The background is not reconstructed non-parametrically in this study; instead, it is fixed to CPL forms
\[
w_\phi(a)=w_0+w_a(1-a),
\]
including the DESI DR2 + CMB + DES Y5 best fit $\{w_0,w_a\}=\{-0.75,-0.86\}$ and two mirage-dark-energy cases. Over 250,000 KGB models are generated and passed through mochi_class, which reconstructs $\alpha_B(a)$ and $\alpha_K(a)$, enforces the stable-basis conditions, and rejects models that develop large mathematical instabilities [2512.13691].

The phenomenological filtering is deliberately conservative. The selected models are required to keep the linear matter power spectrum within $3\%$ of $\Lambda$CDM on sub-horizon scales at $z=0$ and to produce a positive late-time galaxy–ISW cross-correlation. The resulting models also remain broadly consistent with CMB temperature and lensing power spectra, redshift-space distortions, and cosmic shear. The central conclusion is explicit: viable phantom-crossing solutions exist without conformal coupling. This directly challenges the interpretation that phantom crossing inferred from DESI-era background fits necessarily points toward $\alpha_M\neq 0$ or a time-varying effective Planck mass [2512.13691].

In this KGB context, mochi_class functions as a stable-basis EFT solver, but also as an instrument for clarifying model-selection biases. A plausible implication is that earlier preferences for non-zero conformal coupling in simple EFT parametrisations may partly reflect the choice of basis and priors, rather than an unavoidable feature of the data. That implication is not a formal theorem of the code; it follows from the fact that a broader, manifestly stable non-parametric scan uncovers minimally coupled phantom-crossing models that had been obscured in more restrictive parametrised analyses.

Source: https://www.emergentmind.com/topics/mochi_class