> 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/parameter-counting.md).

# Parameter counting for tensor-network layers

This page shows how to count the parameters of a tensor-network layer, so you can check the sizes quoted in these docs.

## The general formula

For an MPO with d cores, where core k maps an input size nₖ to an output size mₖ and has bond dimensions χₖ₋₁ and χₖ, the parameter count is

params = Σₖ χₖ₋₁ · mₖ · nₖ · χₖ

with the boundary bonds χ₀ = χ\_d = 1.

If every internal bond is χ and every mₖ = nₖ = m, this simplifies to roughly d · m² · χ² for the internal cores.

## The worked example

The layer used in the docs is a 4096 × 4096 matrix, with d = 4, mₖ = nₖ = 8 and χ = 64 on the internal bonds. The dense layer has 4096 × 4096 = 16,777,216 parameters.

Counting the cores:

* Core 1 (χ₀ = 1, χ₁ = 64): 1 · 8 · 8 · 64 = 4,096
* Core 2 (64 to 64): 64 · 8 · 8 · 64 = 262,144
* Core 3 (64 to 64): 64 · 8 · 8 · 64 = 262,144
* Core 4 (64 to 1): 64 · 8 · 8 · 1 = 4,096

Total: 4,096 + 262,144 + 262,144 + 4,096 = 532,480 parameters.

The ratio is 16,777,216 / 532,480, about 31.5×.

## Why the internal cores dominate

The internal cores carry χ² and so account for most of the cost. Reducing χ has a much bigger effect than reducing the physical dimensions. This is the main reason rank-adaptive training targets the bonds.

## Checking a quoted number

To check a figure in the docs, you need the shape, the number of cores, and the bond dimensions. Without those, a quoted reduction cannot be reproduced.

## Related

* [Matrix product operators as weight matrices](/deep-dives/matrix-product-operators.md)
* [Tensor-Network Weights](https://github.com/bhavy2908/dataai_docs/tree/main/architecture/tensor-network-weights.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/parameter-counting.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.
