Context
This is the tensor4all-rs counterpart to tensor4all/tenferro-rs#1610. The downstream-usage guidance should cover tensor4all-rs-specific APIs and failure modes rather than only linking to the lower-level tenferro documentation.
Problem
A downstream user who wants to apply tensor-network operations currently has to discover several non-obvious facts from source code:
- the chain-facing
TensorTrain, MPS, and MPO names share the same underlying representation;
- MPO–MPO contraction exists in both
tensor4all-simplett and tensor4all-treetn, but these are different API layers;
- the TreeTN route is the canonical/general path used by the higher-level tensor4all APIs;
- the contraction method changes both cost and reliability;
- ACI tolerance options are easy to misinterpret.
Please add a bundled downstream-usage skill/guide (and link it from the README) following the direction of tenferro-rs#1610. Keep the generic tenferro material reusable, but make the tensor4all-specific examples compile as doctests or through the repository's snippet-test mechanism.
Tensor4all-specific pitfalls to document
1. ACI tolerance scaling
Document the exact option name scale_tolerance (not rescale_tolerance) and show when to enable it.
The guide should explain:
- the difference between absolute and scale-relative convergence;
- why
scale_tolerance = true is generally the appropriate choice for scale-independent ACI tolerances;
- that this option is not an independent accuracy certificate: held-out samples and per-sweep diagnostics are still needed;
- the current early-convergence/held-out-accuracy caveat tracked in #572.
2. MPO–MPO contraction has two layers
Explicitly distinguish:
- SimpleTT: low-level
tensor4all-simplett::mpo routines such as contract_naive, contract_zipup, and contract_fit;
- TreeTN: the topology-aware implementation in
tensor4all-treetn, exposed to chain users through tensor4all-itensorlike::TensorTrain::contract and ContractOptions.
The guide should say that the TreeTN path is the normal/canonical downstream path. SimpleTT should be presented as a lower-level implementation/testing API, not as a second interchangeable public path.
Also call out that TensorContractionLike::contract is not the method to use for TensorTrain; users should call TensorTrain::contract (or the free contract function).
The two representations must not be silently conflated: MPS and MPO are aliases at the type level, so the physical input/output index convention remains the caller's responsibility.
3. Choosing zip-up, fit, and naive
Provide a short decision table:
| Method |
Intended use |
zip-up |
Default production path for large TT/TreeTN contractions; one pass and scalable, with local/partial-environment truncation. |
fit |
Use the TreeTN implementation when variational refinement is worth extra sweeps; document nfullsweeps/with_nsweeps, convergence, and the cost of full sweeps. |
naive |
Dense/reference path for small bond dimensions and correctness tests only; require an explicit dense-size limit where applicable. Never use it as the production algorithm. |
The guide must mention #571: the current SimpleTT contract_fit implementation is not equivalent to the TreeTN fit path and must not be used as the canonical performance/correctness example until that issue is resolved.
Minimal example
Include a compiling example for the canonical TreeTN-backed API, for example:
use tensor4all_core::truncation::SvdTruncationPolicy;
use tensor4all_itensorlike::{ContractOptions, Result, TensorTrain};
fn multiply(a: &TensorTrain, b: &TensorTrain, chi: usize, tol: f64) -> Result<TensorTrain> {
let options = ContractOptions::zipup()
.with_max_rank(chi)
.with_svd_policy(SvdTruncationPolicy::new(tol));
a.contract(b, &options)
}
Also show the corresponding fit and small-reference naive option construction, and a short ACI example demonstrating scale_tolerance.
Acceptance criteria
- A downstream-usage skill or guide exists in the standard in-repository location and is linked from README.md.
- The guide contains the four sections above and links to tenferro-rs#1610, tensor4all-rs#571, and tensor4all-rs#572.
- The canonical TreeTN-backed MPO–MPO example compiles.
- The method-selection guidance makes the dense-only/testing role of
naive explicit.
- The SimpleTT/TreeTN split and the current SimpleTT
fit caveat are visible before users copy an example.
- The ACI section uses the exact
scale_tolerance spelling and recommends held-out validation for convergence-sensitive workflows.
Context
This is the tensor4all-rs counterpart to tensor4all/tenferro-rs#1610. The downstream-usage guidance should cover tensor4all-rs-specific APIs and failure modes rather than only linking to the lower-level tenferro documentation.
Problem
A downstream user who wants to apply tensor-network operations currently has to discover several non-obvious facts from source code:
TensorTrain,MPS, andMPOnames share the same underlying representation;tensor4all-simplettandtensor4all-treetn, but these are different API layers;Please add a bundled downstream-usage skill/guide (and link it from the README) following the direction of tenferro-rs#1610. Keep the generic tenferro material reusable, but make the tensor4all-specific examples compile as doctests or through the repository's snippet-test mechanism.
Tensor4all-specific pitfalls to document
1. ACI tolerance scaling
Document the exact option name
scale_tolerance(notrescale_tolerance) and show when to enable it.The guide should explain:
scale_tolerance = trueis generally the appropriate choice for scale-independent ACI tolerances;2. MPO–MPO contraction has two layers
Explicitly distinguish:
tensor4all-simplett::mporoutines such ascontract_naive,contract_zipup, andcontract_fit;tensor4all-treetn, exposed to chain users throughtensor4all-itensorlike::TensorTrain::contractandContractOptions.The guide should say that the TreeTN path is the normal/canonical downstream path. SimpleTT should be presented as a lower-level implementation/testing API, not as a second interchangeable public path.
Also call out that
TensorContractionLike::contractis not the method to use forTensorTrain; users should callTensorTrain::contract(or the freecontractfunction).The two representations must not be silently conflated: MPS and MPO are aliases at the type level, so the physical input/output index convention remains the caller's responsibility.
3. Choosing
zip-up,fit, andnaiveProvide a short decision table:
zip-upfitnfullsweeps/with_nsweeps, convergence, and the cost of full sweeps.naiveThe guide must mention #571: the current SimpleTT
contract_fitimplementation is not equivalent to the TreeTN fit path and must not be used as the canonical performance/correctness example until that issue is resolved.Minimal example
Include a compiling example for the canonical TreeTN-backed API, for example:
Also show the corresponding
fitand small-referencenaiveoption construction, and a short ACI example demonstratingscale_tolerance.Acceptance criteria
naiveexplicit.fitcaveat are visible before users copy an example.scale_tolerancespelling and recommends held-out validation for convergence-sensitive workflows.