LLM Parameter Scale Explained: Matrix Multiplication Complexity and the Compute Ledger
Comparing large language models by parameter count alone is misleading. This article explains why parameter count, training data, per-token FLOPs, and deployment conditions must be evaluated together, and how to reason about model scale through a "compute ledger" that separates training cost, inference cost, and return on investment. It covers why sparse MoE architectures decouple total parameters from compute, and how matrix multiplication complexity underpins the whole cost picture: the Ω(n²) lower bound, why naive O(n³) implementations still dominate in practice, the theoretical ~O(n^2.37) upper bounds that remain impractical, and how arithmetic intensity and the Roofline model explain memory-bound behavior during autoregressive decoding. It closes with a practical guide for judging whether a model's parameter scale is justified, including baseline setup, reproducible benchmarks (MFU, throughput, latency), and a decision checklist.
1. Start Here: Unify the Criteria Before Comparing Model Scale
“More parameters means a smarter model” is a common shortcut in discussions about large models. But the parameter count is never an isolated number. It only becomes meaningful alongside four other factors:
- Total parameter count: how much storage the model weights actually occupy.
- Training data volume: the number of tokens “read” during training. Repeating the same token across multiple passes introduces memorization, and the gains decay rapidly after several repetitions.
- Per-token forward compute: the number of floating-point operations (FLOPs) required to process one token. This depends mainly on how many parameters participate in the computation, not on the total parameter count.
- Deployment conditions: single-request inference latency, concurrency, and the inference compute needed to reach comparable quality.
If two models differ in parameter scale, data scale, sparsity, and deployment environment, drawing a conclusion from a single parameter number is easy to get wrong.
First, parameters and data must scale together. Multiple public scaling studies point to the same empirical rule: under a fixed training-compute budget, parameter count and training data volume should grow together in a certain proportion to balance training loss and generalization. Piling on parameters without feeding enough data leads to an “undertrained” model that memorizes the training set without learning patterns; piling on data without enough parameters leads to “underfitting.” The way training tokens are counted is also easy to confuse: some count raw corpus, some count traversal passes, and some count effective samples after deduplication.
Second, sparse architectures decouple “total parameters” from “compute cost.” Sparse architectures such as Mixture-of-Experts (MoE) split the network into multiple “expert” subnetworks, and each token is routed to only a few of them. As a result, the model’s total parameter count can be very large, while the per-token forward compute depends only on the activated parameters. The parameters sit in storage; compute is spent only on the small activated subset. Looking at total parameters alone overestimates compute cost; looking at activated parameters alone underestimates memory and deployment cost.
Third, training cost and inference cost are two different accounts. Training is a one-time capital investment; inference is a long-term, pay-per-use operating expense with a pronounced long tail. During inference, the matrix multiplications, attention computation, and per-token decoding at every layer all grow with parameter scale. Doubling the parameter count typically roughly doubles inference compute, and this cost accompanies the model throughout its entire lifecycle. So whether a given parameter scale is worth it must be measured together with “how much effective capability each unit of compute produces.”
Fourth, matrix multiplication complexity is the backbone running through everything. Most of a large model’s compute comes from matrix multiplication: a linear layer is the product of a weight matrix and an input vector, and the QKᵀ and attention weighting in attention mechanisms are the same. Any discussion of the compute ledger cannot avoid the complexity of matrix multiplication.
2. The Lower Bound of Matrix Multiplication: Why You Can’t Escape O(n²)
First, clear up a common misunderstanding: the “lower bound” of matrix multiplication and the “best implementation” are two different layers of the problem.
2.1 Where the trivial lower bound comes from
Let A and B be two n×n matrices. Their product C is defined as:
$C{ij}=\sum{k=1}^{n}A{ik}B{kj},\qquad 1\le i,j\le n$
Since the output C itself has n² elements, and every input element affects at least one output, any correct algorithm must read all 2n² inputs at least once. So, under the usual assumption that “the computation cannot avoid using the inputs,” the lower bound on the work of matrix multiplication is Ω(n²).
2.2 The real cost of a naive implementation
A naive implementation follows the definition directly: for each (i, j), accumulate k from 1 to n. A single C[i][j] needs n multiplications and n−1 additions, so the whole matrix takes about 2n³ floating-point operations, giving O(n³) complexity.
# Textbook naive implementation: intuitive, but O(n^3) complexitydef matmul_naive(A, B):n = len(A)C = [[0.0] * n for _ in range(n)]for i in range(n): # rows of the result matrixfor j in range(n): # columns of the result matrixs = 0.0for k in range(n): # accumulate along the shared dimensions += A[i][k] * B[k][j]C[i][j] = sreturn C
This code is clear in meaning, but its drawbacks are equally clear:
- The work grows with n cubed;
- Element-by-element access gives a low cache hit rate;
- It struggles to exploit the vectorization and parallelism of modern hardware.
In engineering, a first “lossless” optimization is usually applied: reorder the loops so that repeatedly accessed data stays in high-speed cache as much as possible. This is the basic idea behind tiling.
# Blocked/tiling optimization: same asymptotic complexity, much better data localitydef matmul_blocked(A, B, block=64):n = len(A)C = [[0.0] * n for _ in range(n)]for i0 in range(0, n, block):for k0 in range(0, n, block): # loop order i -> k -> j reuses rows of A and Bfor j0 in range(0, n, block):i_end = min(i0 + block, n)k_end = min(k0 + block, n)j_end = min(j0 + block, n)for i in range(i0, i_end):aik_row = A[i]c_row = C[i]for k in range(k0, k_end):aik = aik_row[k]b_row = B[k]for j in range(j0, j_end):c_row[j] += aik * b_row[j]return C
Mature basic linear algebra libraries and deep learning frameworks essentially deepen this same idea: multi-level cache blocking, register-level blocking, vector instructions, multithreaded parallelism, and instruction scheduling for matrix-multiply hardware units. They push the constant factors very low, but the asymptotic complexity remains O(n³).
2.3 Can we break O(n³): the gap between theory and engineering
From complexity theory, O(n³) is far from the upper limit of matrix multiplication complexity:
- Divide and conquer. The classic divide-and-conquer algorithm proposed in 1969 reduces the multiplication of two 2×2 block matrices from 8 submatrix multiplications to 7 (trading more additions for fewer multiplications). Once expanded recursively, its complexity is O(n^{log₂7}) ≈ O(n^2.807).
- Tensor rank. The series of “fast matrix multiplication” works since 1990 pushed the exponent down to around 2.376; after several rounds of improvement, the best known upper bound today is around 2.37. This approach essentially searches for low-rank decompositions of the matrix multiplication tensor.
- Still hovering near 2. The lower bound stays at Ω(n²) and the upper bound sits near 2.37. The gap between them remains a famous open problem in computational complexity theory.
- Impractical in engineering. These algorithms only offer asymptotic advantages for extremely large matrices, and they come with huge constant factors, amplified numerical error, and difficulty in parallelization. They are almost never used in real systems; a gap between engineering practice and the theoretical optimum has long persisted.
Back to the original observation: the implementations used in practice really do “fail to reach” O(n²). But the root cause of this fact is not a lack of engineering capability; it is that the algorithms themselves lack practical value. Extending this directly into “some technical approach is unsustainable” is an over-generalization.
2.4 Another angle: arithmetic intensity
The Roofline model characterizes the hardware performance ceiling from the perspective of “work / data movement”:
- If arithmetic intensity is below the hardware’s “peak FLOPs / memory bandwidth” ratio, the program is in the memory-bound region and its utilization is determined by bandwidth;
- Above that ratio, it enters the compute-bound region, and performance can approach the hardware peak.
For matrix multiplication, arithmetic intensity under ideal blocking can reach Θ(n), and the larger the scale, the more easily it enters the compute-bound region. A naive element-by-element implementation is the opposite: its arithmetic intensity is very low, and most of the time is spent waiting on memory.
Autoregressive decoding is yet another case: generating each token requires reading the entire model weights once, giving even lower arithmetic intensity, usually manifesting as memory-bound. This explains why parameter scale often affects inference cost even more than the per-token FLOPs number suggests.
3. Putting Parameter Scale Back into the Compute Ledger
Combining the previous two sections, the sustainability of parameter scale can be broken into three accounts:
- Training account. Training compute is approximately 6 × parameters × training tokens (forward is about 2N, backward about 4N, in FLOPs, plus additional terms such as weight updates). When training data approaches saturation, further scaling parameters only makes the training account more expensive while newly added effective capability diminishes.
- Inference account. Inference cost is roughly proportional to parameters × inference tokens. It accumulates linearly with service time and is the major driver of long-term total cost of ownership (TCO). Within it, the decoding stage is memory-bandwidth-bound, and techniques such as low-precision quantization, operator fusion, and batch scheduling usually reduce per-token cost more than simply adding parameters.
- Return account. Whether a parameter scale is reasonable should be judged by “how much capability gain each additional unit of compute buys.” When comparing models, it is better to compare “quality per unit cost” under a fixed task set and fixed inference budget, rather than comparing parameter numbers directly.
From this we can derive a relatively pragmatic rule:
- When training data can still scale and inference scale is limited, moderately increasing parameter count is reasonable;
- When data approaches saturation, or when large-scale serving is required, prioritize sparse designs, quantization, distillation, context compression, and similar techniques rather than piling on parameters without limit.
4. Practical Guide: How to Evaluate Whether a Model’s Parameter Scale Is Reasonable
4.1 Define the needs first, then the scale
- Clarify the task boundary: classification, extraction, generation, and multi-turn dialogue have very different parameter requirements. Most vertical tasks can be handled with a small-to-medium model combined with retrieval augmentation or domain-specific fine-tuning.
- Clarify latency and concurrency: real-time scenarios are sensitive to single-request inference latency; offline batch processing can tolerate higher latency in exchange for higher throughput.
- Clarify the budget structure: separate the one-time training investment from long-term inference spending; avoid looking at training cost alone.
4.2 Establish comparison baselines
- Use a baseline configuration built from three points — parameter count, training data volume, and compute — and vary one dimension at a time, observing the curve of quality versus cost.
- Record the comparison between dense and sparse models of the same scale: a sparse model has more parameters, but its activated parameters and compute may be lower, and deployment cost must be calculated separately.
- Record quality and speed differences before and after quantization; judge quantization precision by task evaluation rather than perplexity alone.
4.3 Establish reproducible benchmarks
- Use small matrix multiplications to verify implementation correctness: naive and optimized implementations should match within a small tolerance.
- Record throughput, arithmetic intensity, and bandwidth utilization at different scales, and use real data to judge whether the bottleneck is on the compute side or the memory side.
- For training, track Model FLOPs Utilization (MFU): the ratio of achieved FLOPs to the hardware’s theoretical peak. Higher MFU means less waste of cluster resources.
- For inference, track time-to-first-token, per-token latency, cost per token, and the relationship between memory usage and batch concurrency.
An example benchmark logic to reference:
import timedef measure_throughput(run_once, n, repeats=20, warmup=2):# run_once: a closure that runs a single execution, e.g. one forward passfor _ in range(warmup):run_once()t0 = time.perf_counter()for _ in range(repeats):run_once()elapsed = time.perf_counter() - t0return elapsed / repeats # average time per run# Arithmetic intensity estimate: ~2 * n^3 FLOPs, naive data movement ~3 * n^2def arithmetic_intensity(n):return (2 * n ** 3) / (3 * n ** 2)
4.4 Establish a decision checklist
- Is the evaluation set for the target task fixed and reproducible?
- Is the ratio among parameter count, training data volume, and compute supported by controlled experiments?
- Is inference cost accounted for on a “per million tokens” basis, including long-tail traffic?
- Have sparse designs, quantization, and distillation been evaluated, rather than defaulting to “pile on parameters”?
- Is there a fallback: a cascade router of a main model plus a small model that cuts costs on most simple requests?
5. Revisiting the Original Argument
The core claim of the original is: unboundedly piling on parameters is “unsustainable,” and a relatively restrained scaling strategy is smarter. This direction has its merits, but the argument chain is incomplete:
- Over-generalization. Inferring the fate of an entire technical approach from a matrix-multiplication benchmark on a single piece of hardware spans too wide an evidence gap; a single experiment can only show a local phenomenon.
- Conflating layers. The asymptotic complexity of matrix multiplication belongs to the theory layer, engineering implementation belongs to the systems layer, and model scale strategy belongs to the product and business layer. The three cannot directly substitute for one another.
- Conclusions need data support. Whether “smarter” holds ultimately comes down to quality comparisons and unit-cost comparisons on a fixed task set; comparing only parameter numbers can both overestimate a large model and underestimate a small one.
A more rigorous statement is: parameter scale is not “the bigger the better,” nor “the smaller the better”; it should be treated as an engineering variable determined jointly by data scale, compute budget, inference cost, and task needs. This is exactly the approach mature teams generally adopt when making model selections, and it aligns with the principle of “on-demand selection with controllable cost” emphasized in Baidu AI Cloud’s model serving and compute platform design. For most enterprise users, the reasonable approach is to clarify business needs first, then validate the scale choice with benchmarks and a cost model, rather than chasing the parameter number itself.
