Skip to content

Expose TensorNetworks.Evaluator and typed evaluate_batch #85

@shinaoka

Description

@shinaoka

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions