Motivation
BubbleTeaCI Task9 migration exposed that repeated Tensor4all TreeTN/TensorTrain evaluation is too expensive for TCI-style sampling. Tensor4all.jl currently calls the C API in a way that rebuilds backend handles per evaluation call, and evaluate returns ComplexF64 even for real TreeTNs.
Proposed API
Expose a reusable evaluator wrapper after tensor4all-rs provides the C API:
ev = TensorNetworks.Evaluator(tt, site_indices)
values = ... # shape (n_site_indices, n_points), 1-based Julia indices
out = ev(values)
Return type should follow scalar kind:
- real TreeTN/TensorTrain ->
Vector{Float64}
- complex TreeTN/TensorTrain ->
Vector{ComplexF64}
Conventions
Keep Tensor4all.jl aligned with tensor4all-rs:
- batch input shape is
(n_site_indices, n_points)
- the point/batch dimension is rightmost
- Julia wrapper converts 1-based input values to Rust's 0-based values
Python bindings may expose torch-style (batch, n_sites) separately; Julia should not change the core convention.
Acceptance criteria
TensorNetworks.Evaluator(tt, indices) reuses backend evaluator state across calls.
- Real evaluation returns
Vector{Float64} and scalar Float64 where applicable.
- Complex evaluation returns
Vector{ComplexF64} / ComplexF64.
- Existing
evaluate(tt, indices, values) remains compatible or has a documented migration path.
- Tests cover real and complex TreeTNs and repeated evaluator calls.
Upstream dependencies
Motivation
BubbleTeaCI Task9 migration exposed that repeated Tensor4all TreeTN/TensorTrain evaluation is too expensive for TCI-style sampling. Tensor4all.jl currently calls the C API in a way that rebuilds backend handles per evaluation call, and
evaluatereturnsComplexF64even for real TreeTNs.Proposed API
Expose a reusable evaluator wrapper after tensor4all-rs provides the C API:
Return type should follow scalar kind:
Vector{Float64}Vector{ComplexF64}Conventions
Keep Tensor4all.jl aligned with tensor4all-rs:
(n_site_indices, n_points)Python bindings may expose torch-style
(batch, n_sites)separately; Julia should not change the core convention.Acceptance criteria
TensorNetworks.Evaluator(tt, indices)reuses backend evaluator state across calls.Vector{Float64}and scalarFloat64where applicable.Vector{ComplexF64}/ComplexF64.evaluate(tt, indices, values)remains compatible or has a documented migration path.Upstream dependencies