> 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/canonical-forms-and-sweeps.md).

# Canonical forms and sweeps

A tensor network can be rewritten in many equivalent ways. Canonical forms pick one that is numerically stable and makes truncation easy to control. This page explains the idea and how sweeps use it.

## Gauge freedom

Inserting a matrix and its inverse on a bond does not change the network's product. The cores change, but the represented tensor does not. This is the gauge freedom of tensor networks.

## Canonical form

A chain is in canonical form when every core left of a chosen position is a left isometry (its contraction with itself on the physical and left indices gives the identity), and every core right of it is a right isometry. The position is the centre, and the norm of the whole network sits in the centre core.

## Why it helps

* Contractions stay numerically stable, because the norm is not spread across the chain.
* At the centre, the singular values of the bond to either side are the Schmidt coefficients, so truncation error can be read off directly.

## Sweeps

Moving the centre one bond at a time is called a sweep. Each step:

1. Moves the centre to the next core using an SVD.
2. Truncates the bond if the error budget allows.
3. Updates the centre core.

A sweep across the whole chain visits every bond once. Quantaria's planned DMRG-style sweeps use this structure during optimization. See [DMRG-style sweeps](/deep-dives/dmrg-sweeps.md).

## Quantaria's use

Hilbert-1 keeps its cores in canonical form for stable contraction. See [Canonical-form gauging](https://github.com/bhavy2908/dataai_docs/tree/main/architecture/tensor-network-weights.md#canonical-form-gauging). Sweep-based optimization is a research direction, not part of the live models.

## Related

* [SVD and truncation](/deep-dives/svd-and-truncation.md)
* [Matrix product states from scratch](/deep-dives/matrix-product-states.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/canonical-forms-and-sweeps.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.
