Skip to content

feat: add general upstream primitives for downstream migration#407

Merged
shinaoka merged 21 commits intomainfrom
feat/issues-404-405-upstream-apis
Apr 10, 2026
Merged

feat: add general upstream primitives for downstream migration#407
shinaoka merged 21 commits intomainfrom
feat/issues-404-405-upstream-apis

Conversation

@shinaoka
Copy link
Copy Markdown
Member

@shinaoka shinaoka commented Apr 10, 2026

Summary

  • add exact unfuse primitives and dynamic-scalar constructors in tensor4all-core
  • add a public simple-TT to TreeTN bridge plus general site-space helpers in tensor4all-treetn
  • generalize partial contraction and keep the open-boundary negative shift fix in quanticstransform
  • remove the grid_aware public API so this PR only keeps general-purpose primitives upstream

Verification

  • cargo fmt --all
  • cargo clippy --workspace
  • cargo nextest run --release --workspace
  • cargo doc --workspace --no-deps

Notes

  • cargo doc still reports pre-existing rustdoc broken-link warnings in crates/tensor4all-quanticstransform/src/cumsum.rs and crates/tensor4all-capi/src/simplett.rs
  • this branch intentionally keeps application semantics downstream and does not add grid-aware / variable-name convenience APIs upstream

Refs #404
Refs #405

shinaoka and others added 19 commits April 8, 2026 16:56
Design document covering upstream API additions needed for
BubbleTeaCI-rs migration: PartialEq for DiscretizedGrid,
grid-aware operator constructors, batched TCI, partial site
contraction, and Index::Id → Index API unification.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Add shift_operator_on_grid_by_tag for Julia-style tag="x" variable
selection. Document tag propagation from grid variable names to
operator site indices.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
9-task bottom-up plan: quanticsgrids PartialEq, grid-aware operators
with tag-based variable selection, batched TCI, partial site
contraction, and Index-based API unification.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Add Index-based wrappers for evaluate and all_site_index_ids that accept
T::Index objects directly instead of raw IDs, simplifying downstream usage.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Add swap_site_indices_by_index and swap_on_edge_by_index as
Index-based alternatives accepting T::Index keys instead of
T::Index::Id. Includes integration tests.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Add PartialContractionSpec and partial_contract() to tensor4all-treetn,
enabling fine-grained control over which index pairs are contracted
(summed over) vs. kept as separate output indices during TreeTN
contraction.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Add quanticscrossinterpolate_batched which interpolates vector or
tensor-valued functions by running scalar TCI independently per
component with shared evaluation caching, then combining the
per-component tensor trains into a single block-diagonal TT with a
component selector site appended.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Add shift_operator_on_grid, shift_operator_on_grid_by_tag, and
detect_unfolding_scheme to the quanticstransform crate. These functions
accept a DiscretizedGrid and automatically dispatch to the correct
implementation based on the grid's unfolding scheme (Grouped, Fused,
or Interleaved).

- Grouped: concatenates per-variable shift TensorTrains into a single chain
- Fused: uses shift_operator_multivar with MPO-MPO composition for
  multi-variable shifts
- Interleaved multi-variable: returns "not yet implemented" error

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Add a convenience method that updates both input and output true_index
mappings to match a target state's site indices, enabling operators
constructed with independent site indices to be applied to arbitrary
states without manual mapping rewrite.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Add affine_operator_on_grid with Fused/Grouped layout support.
Grouped delegates to fused-form for now (TODO: native grouped).

Part of #405

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The test reveals a limitation where multiply_pairs with shared nodes
causes contract() to fail. Marked as ignored pending improved
implementation.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Add validation that contract_pairs and multiply_pairs must target
different nodes. When both share a node, replaceind makes all shared
indices identical and contract() cannot distinguish them.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Fix unused imports (IndexLike, TensorIndex)
- Fix clippy type_complexity by introducing PartialContractionInputs struct
- Add validation tests for dimension mismatch, index not found,
  contract-only, and empty spec cases to improve coverage

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Fix clippy clone-on-Copy (DynId) in treetn ops tests
- Fix clippy needless_range_loop in quanticstransform grid_aware tests
- Add coverage tests: topology mismatch, second-network same-node,
  dimension mismatch, index-not-found, contract-only, empty-spec

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@shinaoka shinaoka changed the title feat: add upstream primitives for BubbleTea migration feat: add general upstream primitives for downstream migration Apr 10, 2026
@shinaoka shinaoka enabled auto-merge (squash) April 10, 2026 01:24
@shinaoka shinaoka merged commit b1a00d2 into main Apr 10, 2026
5 checks passed
@shinaoka shinaoka deleted the feat/issues-404-405-upstream-apis branch April 10, 2026 01:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant