# Matrix math, the work AI runs on

> What a matrix is, how two are multiplied, why GPUs and AI models love it, and Pearl's idea: make mining work that could also be useful.

Source: https://pearlcodex.com/beginners/matrix-math/ · Last updated: 2026-10-21 · Checked against Pearl's source code at v1.5.5

Strip away the buzzwords, and a modern AI model is mostly a long list of grids full of numbers, multiplied together over and over.

Pearl’s mining uses exactly that kind of multiplication. To see why that’s a clever idea, and where its limits are, start with the grids.

## What is a matrix?

A [matrix](https://pearlcodex.com/glossary/#matrix) is a grid of numbers arranged in rows and columns, like a small spreadsheet with no labels.

A photo is a matrix, if you write down each pixel’s brightness. So is a table of prices, with one row per shop and one column per product. And so is most of what an AI model has learned: its knowledge is stored as huge matrices of numbers called weights.

## How do you multiply two matrices?

Here’s the rule, which is simpler than it sounds. To get one cell of the answer, take one row of the first matrix and one column of the second. Multiply them pair by pair, then add the results.

That operation is called a [dot product](https://pearlcodex.com/glossary/#dot-product). Let’s do a small one by hand.

$$
\begin{pmatrix} 1 & 2 \\ 3 & 4 \end{pmatrix} \times \begin{pmatrix} 5 & 6 \\ 7 & 8 \end{pmatrix} = \begin{pmatrix} 19 & 22 \\ 43 & 50 \end{pmatrix}
$$

A 2 × 2 example

1. **Pick a row and a column**

   For the top-left cell, take the first row, (1, 2), and the first column, (5, 7).

2. **Multiply the pairs**

   1 × 5 = 5, and 2 × 7 = 14.

3. **Add them up**

   5 + 14 = 19. That’s the top-left cell.

4. **Repeat for every cell**

   Top-right uses row (1, 2) and column (6, 8): 6 + 16 = 22. The bottom row works the same way, giving 43 and 50.

Each “multiply, then add to the running total” step is one [multiply-accumulate](https://pearlcodex.com/glossary/#multiply-accumulate). Remember that word: it’s the unit Pearl uses to count mining work.

Hover over or tap the cells below to see which row and column make each one.

_Interactive: Matrix multiplier. Try it on the page: <https://pearlcodex.com/beginners/matrix-math/>_

## Why is it so much work?

Because the steps multiply quickly. For two 3 × 3 matrices, each of the 9 answer cells needs 3 multiply-accumulates: 27 in total.

For two 1,000 × 1,000 matrices, there are a million answer cells, each needing 1,000 steps. That’s a billion multiply-accumulates for one multiplication. AI models do multiplications like that constantly.

**Make a guess:** To multiply two 4 × 4 matrices, how many multiply-accumulate steps do you need?

**Answer:** 64.

The answer has 4 × 4 = 16 cells, and each cell is a dot product of 4 pairs, so 16 × 4 = 64. In general, an n × n multiplication takes n × n × n steps, which is why the work grows so fast.

## Why do AI models need it?

When a chatbot reads your question, it turns the words into numbers and passes them through dozens of layers. Each layer multiplies the incoming numbers by its weight matrix.

Running a trained model like this is called [inference](https://pearlcodex.com/glossary/#inference), and for large models most of its time goes into matrix multiplication. That’s why the demand for this one kind of math has exploded.

## Why are GPUs so good at it?

A [GPU](https://pearlcodex.com/glossary/#gpu) was built to draw video game graphics, which also means doing the same simple math on huge numbers of pixels at once. It has thousands of small cores working in parallel.

Matrix multiplication suits that perfectly, because no cell of the answer depends on any other. Hand each cell to a different core and they all work at once. Modern GPUs go further, with [tensor cores](https://pearlcodex.com/glossary/#tensor-core): circuits that multiply a small block of a matrix in a single step.

Smaller numbers go faster still. Pearl’s mining uses whole numbers in the range \[−64, 64], which fit the GPU’s fast 8-bit integer mode. Squeezing an AI model’s numbers into a small range like that is called [quantization](https://pearlcodex.com/glossary/#quantization).

## What is Pearl’s big idea?

Bitcoin’s mining burns a vast amount of computing on guesses that protect the network and do nothing else.

Pearl asks: what if the protective work were also work people actually want done? Matrix multiplication is the natural choice, because so much of AI is made of it. Pearl calls this [proof of useful work](https://pearlcodex.com/glossary/#proof-of-useful-work).

In Pearl’s official miner, mining happens inside a real AI model. The miner plugs into a popular serving program called vLLM and runs language models published for it. When the model handles a big enough batch, at least 1,024 tokens (word pieces) at once, its multiplications double as mining. The extra cost on top of the model’s normal work is reported to be a few percent.

## Does Pearl check that the work is useful?

No, and it’s worth being clear about this.

Pearl’s rules check that the multiplication was done honestly. They can’t check what the numbers mean, so a matrix full of random numbers counts exactly the same as a real AI layer. Pearl’s own reference CPU miner multiplies random matrices.

> **Note: Useful, but not enforced**
>
> Pearl makes useful mining possible and cheap, but not required. The difference between the work that is rewarded and the work that is actually useful is sometimes called the [usefulness gap](https://pearlcodex.com/glossary/#usefulness-gap). A 2026 research paper reported that the most widely used third-party mining program contains no AI inference code at all. How much of the network’s mining does useful work today is an open question.

There’s one more problem to solve. If the puzzle were simply “multiply these matrices”, a miner could do it once and reuse the answer forever. The next page shows how Pearl stops that, and how a miner proves its work to everyone else.

## In short

- A matrix is a grid of numbers. Multiplying two matrices means pairing each row of the first with each column of the second.
- Each cell of the result is a dot product, a run of multiply-and-add steps, so big multiplications take billions of steps.
- AI models spend most of their time multiplying matrices, and GPUs are built to do it massively in parallel.
- Pearl makes matrix multiplication its mining work, so the same computation can also run an AI model.
- Pearl’s rules accept any matrices of small whole numbers. Whether the work is useful depends on the miner, not on the rules.

## Read the code

- [The reference CPU miner, which multiplies random matrices](https://github.com/pearl-research-labs/pearl/blob/v1.5.5/zk-pow/src/ffi/mine.rs#L19-L128) `zk-pow/src/ffi/mine.rs:19-128`
- [Mining inside an AI model's matrix multiplications (vLLM)](https://github.com/pearl-research-labs/pearl/blob/v1.5.5/miner/vllm-miner/src/vllm_miner/gemm_operators.py#L68-L217) `miner/vllm-miner/src/vllm_miner/gemm_operators.py:68-217`
- [The minimum sizes for a multiplication to mine](https://github.com/pearl-research-labs/pearl/blob/v1.5.5/miner/vllm-miner/src/vllm_miner/config.yaml#L9-L12) `miner/vllm-miner/src/vllm_miner/config.yaml:9-12`

## Sources

### Pearl docs

- [Pearl INT whitepaper](https://pearlresearch.ai/research/int-whitepaper)
- [Proof of Useful Work from the Ground Up (Pearl Research Labs blog)](https://pearlresearch.ai/research/blog/proof-of-useful-work)

### Papers

- [Komargodski and Weinstein, proofs of useful work from matrix multiplication (arXiv 2504.09971)](https://arxiv.org/abs/2504.09971)
- [Basu, “Usefulness Gap” (arXiv 2606.04819)](https://arxiv.org/abs/2606.04819)
