Skip to content

Rework index manipulation API#416

Merged
lkdvos merged 35 commits into
mainfrom
ld-indexmanipulations
May 30, 2026
Merged

Rework index manipulation API#416
lkdvos merged 35 commits into
mainfrom
ld-indexmanipulations

Conversation

@lkdvos
Copy link
Copy Markdown
Member

@lkdvos lkdvos commented Apr 26, 2026

Summary

This PR overhauls the index manipulation API in src/tensors/indexmanipulations.jl to match TensorOperations dispatch conventions, reduces code duplication in the implementation, and adds a dedicated documentation page.
The goal was a bunch of code simplification, (overall number of lines reduced, even though I added some docs 🎉 )

API changes

  • Unified in-place interface: permute!, braid!, transpose!, and repartition! now directly accept α, β, backend, and allocator as optional arguments (with defaults One(), Zero(), DefaultBackend(), DefaultAllocator()), following the TensorOperations dispatch pattern. The old add_permute!, add_braid!, and add_transpose! are deprecated and forward to the new functions.
  • allocator support: previously, the index manipulation functions did not support a custom allocator at all. It is now a positional argument in both the public and internal interfaces, consistent with TensorOperations convention.
  • Out-of-place functions (permute, braid, transpose, repartition) gain backend as a new keyword argument alongside the now-supported allocator keyword.

Implementation changes

  • All permutation operations now route through braid!, eliminating duplicate codepaths.
  • Dedicated braid! method added for AdjointTensorMap.
  • add_transform! kernels for TensorMap refactored to operate on the raw data vector rather than the full TensorMap. Because the data vector has no symmetry type, this avoids recompilation for every TensorMap type combination, improving compilation time.
  • Various minor simplifications throughout.

@github-actions
Copy link
Copy Markdown
Contributor

After the build completes, the updated documentation will be available here

@lkdvos lkdvos force-pushed the ld-indexmanipulations branch from f45ab42 to 2841304 Compare April 26, 2026 12:57
@lkdvos
Copy link
Copy Markdown
Member Author

lkdvos commented Apr 26, 2026

This might also resolve #413, where I tried to compute cond with eigh_vals instead of LinearAlgebra.eigvals.

@lkdvos lkdvos force-pushed the ld-indexmanipulations branch 3 times, most recently from ff15f1e to c4408b3 Compare April 26, 2026 21:33
@lkdvos lkdvos marked this pull request as ready for review April 26, 2026 22:02
@lkdvos lkdvos requested review from Jutho and kshyatt April 26, 2026 22:03
@lkdvos lkdvos linked an issue Apr 26, 2026 that may be closed by this pull request
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 26, 2026

Codecov Report

❌ Patch coverage is 89.83957% with 19 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/tensors/indexmanipulations.jl 89.44% 17 Missing ⚠️
ext/TensorKitMooncakeExt/indexmanipulations.jl 90.00% 1 Missing ⚠️
src/tensors/tensoroperations.jl 50.00% 1 Missing ⚠️
Files with missing lines Coverage Δ
ext/TensorKitAMDGPUExt/roctensormap.jl 52.11% <100.00%> (+0.68%) ⬆️
ext/TensorKitCUDAExt/cutensormap.jl 74.32% <100.00%> (-0.35%) ⬇️
src/TensorKit.jl 13.79% <ø> (ø)
src/planar/planaroperations.jl 72.79% <100.00%> (ø)
src/tensors/braidingtensor.jl 70.39% <100.00%> (ø)
src/tensors/treetransformers.jl 83.16% <100.00%> (+0.44%) ⬆️
ext/TensorKitMooncakeExt/indexmanipulations.jl 96.11% <90.00%> (ø)
src/tensors/tensoroperations.jl 93.95% <50.00%> (ø)
src/tensors/indexmanipulations.jl 90.04% <89.44%> (+16.10%) ⬆️

... and 1 file with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@lkdvos lkdvos force-pushed the ld-indexmanipulations branch 3 times, most recently from a0bc84b to 2c44dca Compare April 28, 2026 20:41
@lkdvos lkdvos force-pushed the ld-indexmanipulations branch 2 times, most recently from b833340 to 5a576f0 Compare May 12, 2026 12:46
Comment thread src/tensors/braidingtensor.jl Outdated
Comment thread src/tensors/indexmanipulations.jl Outdated
Comment thread src/tensors/indexmanipulations.jl Outdated
Comment thread docs/src/man/indexmanipulations.md Outdated
Comment thread docs/src/man/indexmanipulations.md Outdated
Comment thread docs/src/man/indexmanipulations.md Outdated
Comment thread docs/src/man/indexmanipulations.md Outdated
Comment thread docs/src/man/indexmanipulations.md Outdated
Comment thread docs/src/man/indexmanipulations.md Outdated
Comment thread docs/src/man/indexmanipulations.md Outdated
Comment thread docs/src/man/linearalgebra.md Outdated
Comment thread docs/src/man/contractions.md Outdated
@lkdvos lkdvos force-pushed the ld-indexmanipulations branch from 26c844a to 35f4d65 Compare May 30, 2026 18:20
@lkdvos lkdvos merged commit afb4286 into main May 30, 2026
47 of 49 checks passed
@lkdvos lkdvos deleted the ld-indexmanipulations branch May 30, 2026 19:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants