Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 10 additions & 28 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

---

The package is currently at a pre-alpha stage.
The package is currently an early version and will be updated frequently in the near future.

The implementation is based on combining algebraic algorithms like ALS (see, e.g., the [textbook by Kolda and Ballard](https://users.wfu.edu/ballard/pdfs/tensor_textbook.pdf)) and Riemannian optimization from [Manopt.jl](https://manoptjl.org/stable/).

Expand All @@ -30,9 +30,9 @@ See [PIPELINE.md](docs/src/PIPELINE.md) for the current execution flow.

The next updates will include

- Handling of swamps/plateaus in the optimization step
- Documentation
- Improved User Interface
- ProgressMeter
- GPU Support
- LL1 Decomposition (3-way specialized BTD)
- Symmetric CP / Waring Decomposition
Expand Down Expand Up @@ -77,6 +77,12 @@ We get the whole reconstructed tensor by
 = reconstruct(res)
```

Per default, `cpd` finds the initial point by running ALS and then refines it using Riemannian optimization. To use ALS-only one can set the `:solver` flag:
```julia
cpd(A, r; solver = :als)
````
For a detailed overview on all the options see the documentation.

<br>

## Tucker Decomposition
Expand Down Expand Up @@ -194,34 +200,10 @@ reconstruct(join_res)
```
<br>

## References

#### General Tensor Decomposition

- **Tensor decompositions (CP, Tucker):** T. G. Kolda and B. W. Bader, "Tensor decompositions and applications," *SIAM Review*, vol. 51, no. 3, pp. 455–500, 2009.

#### Tucker Methods

- **HOSVD:** L. De Lathauwer, B. De Moor, and J. Vandewalle, "A multilinear singular value decomposition," *SIAM J. Matrix Anal. Appl.*, vol. 21, no. 4, pp. 1253–1278, 2000.
- **ST-HOSVD:** N. Vannieuwenhoven, R. Vandebril, K. Meerbergen, "A new truncation strategy for the higher-order singular value decomposition," *SIAM J. Sci. Comput.*, vol. 34, no. 2, pp. A1027–A1052, 2012.
- **HOOI:** L. De Lathauwer, B. De Moor, and J. Vandewalle, "On the best rank-1 and rank-(R_1,R_2,...,R_N) approximation of higher-order tensors," *SIAM J. Matrix Anal. Appl.*, vol. 21, no. 4, pp. 1324–1342, 2000.

#### Block and Structured Models (BTD / LL1)

- **Block-term decomposition (BTD):** L. De Lathauwer, "Decompositions of a higher-order tensor in block terms—Part I: Lemmas for partitioned matrices," *SIAM J. Matrix Anal. Appl.*, vol. 30, no. 3, pp. 1022–1032, 2008.
- L. De Lathauwer, "Decompositions of a higher-order tensor in block terms—Part II: Definitions and uniqueness," *SIAM J. Matrix Anal. Appl.*, vol. 30, no. 3, pp. 1033–1066, 2008.
- **BTD-ALS:** L. De Lathauwer and D. Nion, "Decompositions of a higher-order tensor in block terms—Part III: Alternating least squares algorithms," *SIAM Journal on Matrix Analysis and Applications*, vol. 30, no. 3, pp. 1067–1083, 2008. [PDF](http://dimitri.nion.free.fr/Publications/Revues/DeLatNion_TensorBlock3.pdf).

#### Join decompositions

- **Conditioning of join decompositions:** P. Breiding and N. Vannieuwenhoven, "The condition number of join decompositions," *SIAM Journal on Matrix Analysis and Applications*, vol. 39, no. 1, pp. 287–309, 2018. [arXiv:1611.08117 (PDF)](https://arxiv.org/pdf/1611.08117).

#### Riemannian Optimization and Julia Ecosystem

- **Riemannian trust-region / Gauss–Newton for canonical rank (CP) approximation:** P. Breiding and N. Vannieuwenhoven, "A Riemannian Trust Region Method for the Canonical Tensor Rank Approximation Problem," *SIAM Journal on Optimization*, vol. 28, no. 3, pp. 2435–2465, 2018. [arXiv:1709.00033 (PDF)](https://arxiv.org/pdf/1709.00033).
- **Riemannian optimization:** P.-A. Absil, R. Mahony, and R. Sepulchre, *Optimization Algorithms on Matrix Manifolds*. Princeton University Press, 2008.
- **Julia manifold optimization ecosystem:** R. Bergmann *et al.*, [ManifoldsBase.jl](https://github.com/JuliaManifolds/ManifoldsBase.jl), [Manifolds.jl](https://github.com/JuliaManifolds/Manifolds.jl), and [Manopt.jl](https://manoptjl.org).
## Usage of AI

AI coding assitants have been used to support the implementation process. All implemented functions have been designed and reviewed by humans. The documentation was written by humans.


[docs-img]: https://img.shields.io/badge/docs-online-blue.svg
Expand Down
2 changes: 1 addition & 1 deletion docs/PIPELINE/index.html

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions docs/Project.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
[deps]
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
TensorKitchen = "3630a16b-0f2f-4d88-afbf-c7d59eccf553"

[sources]
TensorKitchen = {path = ".."}
14 changes: 10 additions & 4 deletions docs/btd/index.html

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions docs/build/.documenter-siteinfo.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"documenter":{"documenter_version":"1.17.0","generation_timestamp":"2026-05-06T18:22:38","julia_version":"1.12.0"}}
2 changes: 2 additions & 0 deletions docs/build/PIPELINE/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<!DOCTYPE html>
<html lang="en"><head><meta charset="UTF-8"/><meta name="viewport" content="width=device-width, initial-scale=1.0"/><title>Pipeline · Documentation</title><meta name="title" content="Pipeline · Documentation"/><meta property="og:title" content="Pipeline · Documentation"/><meta property="twitter:title" content="Pipeline · Documentation"/><meta name="description" content="Documentation for Documentation."/><meta property="og:description" content="Documentation for Documentation."/><meta property="twitter:description" content="Documentation for Documentation."/><script data-outdated-warner src="../assets/warner.js"></script><link href="https://cdnjs.cloudflare.com/ajax/libs/lato-font/3.0.0/css/lato-font.min.css" rel="stylesheet" type="text/css"/><link href="https://cdnjs.cloudflare.com/ajax/libs/juliamono/0.050/juliamono.min.css" rel="stylesheet" type="text/css"/><link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.2/css/fontawesome.min.css" rel="stylesheet" type="text/css"/><link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.2/css/solid.min.css" rel="stylesheet" type="text/css"/><link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.2/css/brands.min.css" rel="stylesheet" type="text/css"/><link href="https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.16.8/katex.min.css" rel="stylesheet" type="text/css"/><script>documenterBaseURL=".."</script><script src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.6/require.min.js" data-main="../assets/documenter.js"></script><script src="../search_index.js"></script><script src="../siteinfo.js"></script><script src="../../versions.js"></script><link class="docs-theme-link" rel="stylesheet" type="text/css" href="../assets/themes/catppuccin-mocha.css" data-theme-name="catppuccin-mocha"/><link class="docs-theme-link" rel="stylesheet" type="text/css" href="../assets/themes/catppuccin-macchiato.css" data-theme-name="catppuccin-macchiato"/><link class="docs-theme-link" rel="stylesheet" type="text/css" href="../assets/themes/catppuccin-frappe.css" data-theme-name="catppuccin-frappe"/><link class="docs-theme-link" rel="stylesheet" type="text/css" href="../assets/themes/catppuccin-latte.css" data-theme-name="catppuccin-latte"/><link class="docs-theme-link" rel="stylesheet" type="text/css" href="../assets/themes/documenter-dark.css" data-theme-name="documenter-dark" data-theme-primary-dark/><link class="docs-theme-link" rel="stylesheet" type="text/css" href="../assets/themes/documenter-light.css" data-theme-name="documenter-light" data-theme-primary/><script src="../assets/themeswap.js"></script></head><body><div id="documenter"><nav class="docs-sidebar"><div class="docs-package-name"><span class="docs-autofit"><a href="../">Documentation</a></span></div><button class="docs-search-query input is-rounded is-small is-clickable my-2 mx-auto py-1 px-2" id="documenter-search-query">Search docs (Ctrl + /)</button><ul class="docs-menu"><li><a class="tocitem" href="../">Home</a></li><li><a class="tocitem" href="../cpd/">CPD</a></li><li><a class="tocitem" href="../tucker/">Tucker</a></li><li><a class="tocitem" href="../btd/">BTD</a></li><li><a class="tocitem" href="../join/">Join</a></li><li><a class="tocitem" href="../utils/">Utilities</a></li><li class="is-active"><a class="tocitem" href>Pipeline</a><ul class="internal"><li><a class="tocitem" href="#Public-entry-points"><span>Public entry points</span></a></li><li><a class="tocitem" href="#Default-behavior-(quick-reference)"><span>Default behavior (quick reference)</span></a></li><li><a class="tocitem" href="#Core-execution-architecture"><span>Core execution architecture</span></a></li><li><a class="tocitem" href="#API-flows"><span>API flows</span></a></li><li><a class="tocitem" href="#Generic-approx(...)-routing"><span>Generic <code>approx(...)</code> routing</span></a></li><li><a class="tocitem" href="#Result-types-and-post-processing"><span>Result types and post-processing</span></a></li><li><a class="tocitem" href="#File-map"><span>File map</span></a></li></ul></li><li><a class="tocitem" href="../references/">References</a></li></ul><div class="docs-version-selector field has-addons"><div class="control"><span class="docs-label button is-static is-size-7">Version</span></div><div class="docs-selector control is-expanded"><div class="select is-fullwidth is-size-7"><select id="documenter-version-selector"></select></div></div></div></nav><div class="docs-main"><header class="docs-navbar"><a class="docs-sidebar-button docs-navbar-link fa-solid fa-bars is-hidden-desktop" id="documenter-sidebar-button" href="#"></a><nav class="breadcrumb"><ul class="is-hidden-mobile"><li class="is-active"><a href>Pipeline</a></li></ul><ul class="is-hidden-tablet"><li class="is-active"><a href>Pipeline</a></li></ul></nav><div class="docs-right"><a class="docs-navbar-link" href="https://github.com/TensorKitchen/TensorKitchen.jl" title="View the repository on GitHub"><span class="docs-icon fa-brands"></span><span class="docs-label is-hidden-touch">GitHub</span></a><a class="docs-navbar-link" href="https://github.com/TensorKitchen/TensorKitchen.jl/blob/main/docs/src/PIPELINE.md" title="Edit source on GitHub"><span class="docs-icon fa-solid"></span></a><a class="docs-settings-button docs-navbar-link fa-solid fa-gear" id="documenter-settings-button" href="#" title="Settings"></a><a class="docs-article-toggle-button fa-solid fa-chevron-up" id="documenter-article-toggle-button" href="javascript:;" title="Collapse all docstrings"></a></div></header><article class="content" id="documenter-page"><h1 id="TensorKitchen-Pipeline"><a class="docs-heading-anchor" href="#TensorKitchen-Pipeline">TensorKitchen Pipeline</a><a id="TensorKitchen-Pipeline-1"></a><a class="docs-heading-anchor-permalink" href="#TensorKitchen-Pipeline" title="Permalink"></a></h1><p>This document explains how public APIs route into models, solvers, and result converters.</p><h2 id="Public-entry-points"><a class="docs-heading-anchor" href="#Public-entry-points">Public entry points</a><a id="Public-entry-points-1"></a><a class="docs-heading-anchor-permalink" href="#Public-entry-points" title="Permalink"></a></h2><ul><li><code>cpd(A, r; ...)</code> -&gt; <code>CPDResult</code></li><li><code>nncpd(A, r; ...)</code> -&gt; <code>CPDResult</code></li><li><code>btd(A, blocks, ranks; ...)</code> -&gt; <code>BTDResult</code></li><li><code>tucker(A, ranks; method=...)</code> -&gt; <code>TuckerResult</code></li><li><code>approx(...)</code> -&gt; <code>ApproxResult</code> or auto-routed <code>CPDResult</code>/<code>BTDResult</code></li></ul><h2 id="Default-behavior-(quick-reference)"><a class="docs-heading-anchor" href="#Default-behavior-(quick-reference)">Default behavior (quick reference)</a><a id="Default-behavior-(quick-reference)-1"></a><a class="docs-heading-anchor-permalink" href="#Default-behavior-(quick-reference)" title="Permalink"></a></h2><ul><li><code>cpd(A, r)</code>:<ul><li><code>init = :alswarm</code></li><li><code>solver = :rgd</code></li></ul></li><li><code>nncpd(A, r)</code>:<ul><li><code>init = :alswarm</code></li><li><code>solver = :rgd</code></li></ul></li><li><code>btd(A, blocks, ranks)</code>:<ul><li><code>init = :alswarm</code></li><li><code>warm_steps = 200</code></li><li><code>warm_init = BTDHOSVDMultistartInit(candidates=64, screening_steps=10, block_maxiter=12)</code></li><li><code>warm_rel_error_gate = nothing</code> (run manifold refinement by default; set e.g. <code>5e-2</code> to short-circuit on poor warm starts)</li><li><code>solver = :rgd</code></li><li>final BTD-ALS polish enabled by default for non-ALS solvers</li><li><code>max_stagnation_restarts = 1</code> (retry with stronger multistart when ALS fit-change stalls at high rel-error)</li></ul></li><li><code>tucker(A, ranks)</code>:<ul><li><code>method = :sthosvd</code></li></ul></li><li><code>approx(model::JoinModel)</code>:<ul><li><code>init = :alswarm</code></li><li><code>warm_steps = 500</code></li><li><code>solver = :rgd</code></li></ul></li></ul><h2 id="Core-execution-architecture"><a class="docs-heading-anchor" href="#Core-execution-architecture">Core execution architecture</a><a id="Core-execution-architecture-1"></a><a class="docs-heading-anchor-permalink" href="#Core-execution-architecture" title="Permalink"></a></h2><p>Most optimization APIs share this core pattern:</p><ol><li>Build a model (<code>JoinModel</code> + backend)</li><li>Call <code>_solve_model(...)</code></li><li>Convert to a public result struct</li></ol><p><code>_solve_model</code> lives in <code>src/solvers/solve_dispatch.jl</code> and is the common symbol-to-solver dispatch layer (<code>:rgd</code>, <code>:rcg</code>, <code>:lbfgs</code>, <code>:als</code>, <code>:btd_tsd</code>).</p><h2 id="API-flows"><a class="docs-heading-anchor" href="#API-flows">API flows</a><a id="API-flows-1"></a><a class="docs-heading-anchor-permalink" href="#API-flows" title="Permalink"></a></h2><h3 id="CPD-(cpd,-nncpd)"><a class="docs-heading-anchor" href="#CPD-(cpd,-nncpd)">CPD (<code>cpd</code>, <code>nncpd</code>)</a><a id="CPD-(cpd,-nncpd)-1"></a><a class="docs-heading-anchor-permalink" href="#CPD-(cpd,-nncpd)" title="Permalink"></a></h3><p><code>cpd(A, r; ...)</code>:</p><ol><li>Build <code>JoinModel(A, r; geometry=...)</code> with <code>CPDBackend</code></li><li>Normalize/validate options (<code>solver</code>, <code>geometry</code>, <code>gradient_mode</code>, normalization policy)</li><li>Solve through <code>_solve_model(...)</code></li><li>Optionally run nonnegative ALS polishing (for selected nonnegative paths)</li><li>Convert to <code>CPDResult</code></li></ol><p>Notes:</p><ul><li><code>:als</code> means CP-ALS.</li><li>Manifold solvers (<code>:rgd</code>, <code>:rgd_fixed</code>, <code>:rcg</code>, <code>:lbfgs</code>) share dispatch with other pipelines.</li></ul><h3 id="BTD-(btd)"><a class="docs-heading-anchor" href="#BTD-(btd)">BTD (<code>btd</code>)</a><a id="BTD-(btd)-1"></a><a class="docs-heading-anchor-permalink" href="#BTD-(btd)" title="Permalink"></a></h3><p><code>btd(A, blocks, ranks; ...)</code>:</p><ol><li>Build a uniform Tucker family via <code>TuckerJoin(...)</code></li><li>Wrap as <code>JoinModel</code> with <code>BTDBackend</code></li><li>Choose effective initializer:<ul><li><code>solver == :als</code>: use requested init directly (default multistart)</li><li><code>solver != :als</code>: use <code>BTDALSWarmStartInit(...)</code> so first-order methods start from a good BTD-ALS warm point</li></ul></li><li>If the warm-start rel-error exceeds <code>warm_rel_error_gate</code>, return the warm BTD-ALS result directly</li><li>Otherwise solve through <code>_solve_model(...)</code></li><li>If <code>solver != :als</code>, optionally polish with BTD-ALS (<code>btd_als_polish_maxiter</code>)</li><li>Convert to <code>BTDResult</code></li></ol><p>Polish step usefulness (brief):</p><ul><li>Usually helpful for a small final <code>rel_error</code> reduction after RGD converges near a good basin.</li><li>Most useful for quality-focused runs (benchmarks, final fits).</li><li>Can be skipped for speed-sensitive runs (<code>btd_als_polish_maxiter=0</code>) when small extra gains are not worth runtime.</li></ul><p>BTD-specific initialization options:</p><ul><li><code>:hosvd</code>: sequential block initialization on residual</li><li><code>:hosvd_multistart</code>: HOSVD subspace split candidates, optional screening ALS, keep lowest-cost candidate</li><li><code>:alswarm</code>: short BTD-ALS warm-start wrapper around base initializer</li></ul><p>BTD-ALS stabilization behavior:</p><ul><li>Tracks per-iteration fit change (<code>|rel_t - rel_{t-1}|</code>)</li><li>Detects stagnation when fit change is tiny but <code>rel_error</code> remains high</li><li>Can restart from fresh multistart pool (<code>max_stagnation_restarts</code>)</li><li>Reports true final Riemannian gradient norm (<code>grad_norm</code>) instead of a placeholder</li></ul><h3 id="Tucker-(tucker)"><a class="docs-heading-anchor" href="#Tucker-(tucker)">Tucker (<code>tucker</code>)</a><a id="Tucker-(tucker)-1"></a><a class="docs-heading-anchor-permalink" href="#Tucker-(tucker)" title="Permalink"></a></h3><p><code>tucker(A, ranks; method=...)</code> does not use <code>_solve_model</code>. It dispatches directly to decomposition routines:</p><ul><li><code>:sthosvd</code></li><li><code>:hooi</code></li></ul><h2 id="Generic-approx(...)-routing"><a class="docs-heading-anchor" href="#Generic-approx(...)-routing">Generic <code>approx(...)</code> routing</a><a id="Generic-approx(...)-routing-1"></a><a class="docs-heading-anchor-permalink" href="#Generic-approx(...)-routing" title="Permalink"></a></h2><p><code>approx(manifolds, target; dispatch=:auto)</code> routes by manifold family:</p><ul><li>uniform <code>Manifolds.Segre</code> -&gt; <code>cpd(...)</code></li><li>uniform <code>Manifolds.Tucker</code> matching target shape/rank -&gt; <code>btd(...)</code></li><li>mixed or non-uniform family -&gt; generic <code>JoinModel(...)</code> path -&gt; <code>ApproxResult</code></li></ul><p><code>dispatch=:cpd</code>, <code>:btd</code>, and <code>:generic</code> force behavior.</p><h2 id="Result-types-and-post-processing"><a class="docs-heading-anchor" href="#Result-types-and-post-processing">Result types and post-processing</a><a id="Result-types-and-post-processing-1"></a><a class="docs-heading-anchor-permalink" href="#Result-types-and-post-processing" title="Permalink"></a></h2><ul><li><code>CPDResult</code></li><li><code>BTDResult</code></li><li><code>TuckerResult</code></li><li><code>ApproxResult</code></li></ul><p>Common utilities:</p><ul><li><code>reconstruct(result)</code></li><li><code>rel_error(A, result)</code></li></ul><h2 id="File-map"><a class="docs-heading-anchor" href="#File-map">File map</a><a id="File-map-1"></a><a class="docs-heading-anchor-permalink" href="#File-map" title="Permalink"></a></h2><ul><li>API entry points: <code>src/api/approx.jl</code>, <code>src/api/cpd.jl</code>, <code>src/api/nncpd.jl</code>, <code>src/api/btd.jl</code></li><li>Routing helpers: <code>src/dispatch/approx_routing.jl</code></li><li>Solver dispatch core: <code>src/solvers/solve_dispatch.jl</code></li><li>BTD backend/init details: <code>src/btd/model.jl</code>, <code>src/solvers/btd_als.jl</code></li></ul></article><nav class="docs-footer"><a class="docs-footer-prevpage" href="../utils/">« Utilities</a><a class="docs-footer-nextpage" href="../references/">References »</a><div class="flexbox-break"></div><p class="footer-message">Powered by <a href="https://github.com/JuliaDocs/Documenter.jl">Documenter.jl</a> and the <a href="https://julialang.org/">Julia Programming Language</a>.</p></nav></div><div class="modal" id="documenter-settings"><div class="modal-background"></div><div class="modal-card"><header class="modal-card-head"><p class="modal-card-title">Settings</p><button class="delete"></button></header><section class="modal-card-body"><p><label class="label">Theme</label><div class="select"><select id="documenter-themepicker"><option value="auto">Automatic (OS)</option><option value="documenter-light">documenter-light</option><option value="documenter-dark">documenter-dark</option><option value="catppuccin-latte">catppuccin-latte</option><option value="catppuccin-frappe">catppuccin-frappe</option><option value="catppuccin-macchiato">catppuccin-macchiato</option><option value="catppuccin-mocha">catppuccin-mocha</option></select></div></p><hr/><p>This document was generated with <a href="https://github.com/JuliaDocs/Documenter.jl">Documenter.jl</a> version 1.17.0 on <span class="colophon-date" title="Wednesday 6 May 2026 18:22">Wednesday 6 May 2026</span>. Using Julia version 1.12.0.</p></section><footer class="modal-card-foot"></footer></div></div></div></body></html>
Loading
Loading