---
title: Compute‐Optimal Model Design
url: https://www.emergentmind.com/topics/compute-optimal-model-design
type: topic
---

# Compute‐Optimal Model Design

Compute‐optimal model design encompasses a mathematically rigorous framework for selecting architecture size, data volume, and fine-tuning protocol that jointly minimizes error (e.g., final task loss) under a strict compute (FLOP) budget. In the context of repurposing pre-trained decoder-only language models into contrastive embedding models, Ziarko et al. provide the first explicit parameterization and enumeration of compute-optimal fine-tuning strategies, model scaling, and data allocation, grounded in empirical scaling laws, analytic cost accounting, and a discrete phase-diagram of fine-tuning algorithms [2406.04165].

## 1. Formal Optimization Problem

The compute-optimal embedding model design problem is cast as a constrained minimization:

\[
\begin{aligned}
&\text{minimize}_{N, D, M,\ldots}\quad L(N, D, M,\ldots) \\
&\text{subject to}\hspace{2em} C(N, D, M,\ldots) \leq C_\text{budget}
\end{aligned}
\]

**Decision variables:**
- $N$: non-embedding model parameters (model size)
- $D$: number of tokens used for contrastive fine-tuning
- $M \in \{\text{full, freeze, bias, LoRA}\}$: fine-tuning method
- $s \in [0, 1]$: fraction of active transformer blocks (for block-freezing)
- $r \in \mathbb{N}$: rank in LoRA adaptation

Here, $L(N, D, M, ...)$ is the final (contrastive) loss and $C(N, D, M, ...)$ is the total incurred FLOP count. The goal is to select the configuration achieving the best embedding quality for a given training compute.

## 2. Compute-Cost and Scaling Law Formulation

**Compute cost:**

Let $N_F$ and $N_B$ be the numbers of parameters participating in forward and backward passes per token, respectively. The total training compute for $D$ tokens is

\[
C_\text{total} = N_{F} \cdot D + N_{B} \cdot D
\]

which reduces to $2ND$ in full fine-tuning (all parameters active during forward and backward). For partial/freezing/LoRA, $N_{F}$ and $N_{B}$ are correspondingly reduced.

**Empirical scaling laws:**

The final embedding error (contrastive loss) typically follows a power law over both $N$ and $D$:

\[
L(N, D) \approx A\, N^{-a} + B\, D^{-b} + L_\infty
\]

where $A, B, a, b$ are empirically fitted, and $L_\infty$ is the irreducible loss floor. This law is central to compute-optimality: it quantifies diminishing returns to model and data scaling.

## 3. Search Algorithm for Optimal Configuration

Given a set of pretrained LMs indexed by $N$, a grid of data budgets $D$ (total tokens), and candidate fine-tuning schemes $M$, Ziarko et al. introduce a brute-force search over the grid:

```python
# Pseudocode (paraphrased for essential algorithm)
best_config, best_loss = None, float('inf')
for N in available_model_sizes:
    for D in token_budgets:
        for M in fine_tune_methods:
            C = compute_cost(N, D, M)
            if C <= budget:
                loss = evaluate_scaling_law(N, D, M)
                if loss < best_loss:
                    best_config, best_loss = (N, D, M), loss
return best_config
```

This systematic grid search is justified by the low dimensionality (few model sizes and data points) and discrete fine-tuning choices. Moreover, block freezing fraction $s$ and LoRA rank $r$ are similarly swept for their respective methods.

## 4. Fine-Tuning Method Phase Diagram

Empirical results reveal a phase diagram in which the compute-optimal fine-tuning method varies with budget:
- **Full fine-tuning** dominates at limited compute ($C_\text{budget} \lesssim 1\text{–}3 \times 10^{21}$ FLOP); it utilizes all parameters for maximum flexibility when few updates are available.
- **LoRA (Low-Rank Adaptation)** with moderate-to-high rank $r$ becomes optimal at larger budgets ($C_\text{budget} \gtrsim 1\text{–}3 \times 10^{21}$ FLOP), leveraging parameter-efficient adaptation for continued gains as data quantity grows large.
- **Freeze** or **bias-only** methods are never optimal at any realistic budget, as their performance saturates rapidly with compute.

Optimal adaptation settings (block-freezing ratio $s$, LoRA rank $r$) depend smoothly on $C_\text{budget}$. The phase boundary is empirically sharp, cross-validated on multiple embedding tasks.

## 5. Compute-Optimal Model Design Recipe

For practitioners, the following explicit recipe emerges:

- **Step 1**: Choose the largest pretrained LM $(N)$ feasible under your compute budget, subject to cost constraints for the planned fine-tuning method.
- **Step 2**: Allocate as much fine-tuning data $(D)$ as can fit with the selected $N$ and method $M$ while not exceeding $C$.
- **Step 3**: For $C_\text{budget}$ below $10^{21}$–$10^{22}$ FLOP, prefer full fine-tuning; above this threshold, switch to LoRA with rank $r$ maximizing downstream performance within $C$.
- **Step 4**: Never select parameter-freezing or bias-only unless explicitly compute-constrained beyond the points evaluated in [2406.04165] (as they underperform).
- **Step 5**: For block freezing in “full” fine-tuning, set $s \approx 1$ unless compute limitations force more aggressive pruning.

Empirical validation demonstrates that these guidelines track the true compute-loss envelope within 0.03–0.05 absolute loss, i.e., near-optimality across retrieval and semantic similarity benchmarks.

| Compute Budget (FLOP) | Model Size ($N$) | Data ($D$, tokens) | Fine-tuning Method $M$ | LoRA Rank ($r$) |
|-----------------------|------------------|-------------------|-----------------------|-----------------|
| $<10^{21}$–$10^{22}$  | largest possible | largest possible  | full                  | —               |
| $>10^{21}$–$10^{22}$  | up to limit      | as above          | LoRA                  | 8–32            |

**Note:** Specific numerical boundaries may vary according to hardware and candidate pool.

## 6. Practical and Methodological Significance

The compute-optimal model design framework for embedding models formalizes the allocation of training resources, contrasts competing fine-tuning approaches, and provides a quantitative tool for architecture and data scaling under real-world constraints. This integrated methodology bridges empirical scaling laws and actionable design guidance, remedying the limitations of ad hoc model or data scaling. The phase transition between full and LoRA adaptation substantiates parameter-efficient fine-tuning as not only memory efficient, but provably optimal beyond certain compute thresholds [2406.04165].

The discretized search procedure and empirical phase diagram approach also anticipate the practical regime that embedding practitioners operate in: constrained resource pools and highly nonconvex choices over model, data, and adaptation protocol. The outlined recipe is robust over a range of language model backbones and downstream embedding tasks.

Source: https://www.emergentmind.com/topics/compute-optimal-model-design