> For the complete documentation index, see [llms.txt](https://docs.quantaria.xyz/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.quantaria.xyz/deep-dives/matrix-product-operators.md).

# Matrix product operators as weight matrices

A matrix product operator (MPO) is the matrix version of an MPS. Quantaria's layers are MPOs, so this page explains how a dense weight matrix becomes a chain of cores.

## From a matrix to a chain

A dense layer computes y = Wx, where W is an M × N matrix. Reshape the input and output indices into multi-index form:

* x has indices (j₁, …, j\_d), with the j-th dimension size nₖ
* y has indices (i₁, …, i\_d), with the i-th dimension size mₖ

Then W is written as a product of cores:

W\[(i₁…i\_d), (j₁…j\_d)] = G¹\[i₁, j₁] · G²\[i₂, j₂] · … · Gᵈ\[i\_d, j\_d]

Each core Gᵏ has size χₖ₋₁ × mₖ × nₖ × χₖ. The bond dimensions χₖ connect neighbouring cores.

## Worked example

The layer in the [Quantaria Overview](https://github.com/bhavy2908/dataai_docs/tree/main/overview/quantaria-overview.md) is a 4096 × 4096 matrix, so it has 16,777,216 dense parameters. Split into d = 4 cores, with mₖ = nₖ = 8 and χ = 64 on the internal bonds, the core sizes add up to 532,480 parameters. That is about 31.5× fewer.

The example is illustrative. The per-layer setting of χ determines the actual size.

## Applying the layer

The layer is applied by contracting the input vector with the chain one core at a time. The cost scales with the bond dimension, not with the full matrix, which is why a well-chosen χ can make the layer both smaller and cheaper to compute.

## Limits

* An MPO can only represent matrices whose correlations fit within the chosen bonds. A small χ is cheaper but may lose accuracy.
* Reordering the index splits changes the result. The grouping of dimensions into cores is a design choice.

## Quantaria's use

Every weight layer in Hilbert-1 is an MPO. The factorization is trained from the first step, not applied to a dense model afterwards. See [Native, not compressed](https://github.com/bhavy2908/dataai_docs/tree/main/architecture/tensor-network-weights.md#native-not-compressed).

## Related

* [Tensor-train decomposition of a weight matrix](/deep-dives/tensor-train-decomposition.md)
* [Parameter counting for tensor-network layers](/deep-dives/parameter-counting.md)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.quantaria.xyz/deep-dives/matrix-product-operators.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
