Skip to content

Conversation

@borisdevos
Copy link
Member

@borisdevos borisdevos commented Jun 13, 2025

This PR provides the changes required to be able to consider the multifusion categories of (Multi)TensorKit.

All changes boil down to either

  1. not being able to evaluate the unitspace of a BimoduleSector, or
  2. not being able to use braiding tensors for BimoduleSector GradedSpaces,
    and finding ways around to this.

A potential thing to add is tests with BimoduleSector MPS/MPOs or so? For this, I would need to first complete benchmarking MultiTensorKit, hence the draft PR. I might also need to format.

@borisdevos borisdevos marked this pull request as ready for review July 18, 2025 06:48
@codecov
Copy link

codecov bot commented Jul 25, 2025

Codecov Report

❌ Patch coverage is 88.70968% with 7 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/algorithms/fixedpoint.jl 0.00% 3 Missing ⚠️
src/operators/abstractmpo.jl 0.00% 2 Missing ⚠️
...c/algorithms/excitation/quasiparticleexcitation.jl 75.00% 1 Missing ⚠️
src/algorithms/groundstate/gradient_grassmann.jl 0.00% 1 Missing ⚠️
Files with missing lines Coverage Δ
src/algorithms/ED.jl 100.00% <100.00%> (ø)
src/algorithms/correlators.jl 90.90% <100.00%> (ø)
src/algorithms/excitation/chepigaansatz.jl 91.48% <100.00%> (ø)
src/algorithms/timestep/taylorcluster.jl 100.00% <100.00%> (ø)
src/algorithms/timestep/wii.jl 98.14% <100.00%> (ø)
src/algorithms/toolbox.jl 95.15% <100.00%> (ø)
src/environments/abstract_envs.jl 92.10% <100.00%> (ø)
src/operators/mpo.jl 87.38% <100.00%> (ø)
src/operators/mpohamiltonian.jl 90.26% <100.00%> (+0.30%) ⬆️
src/operators/ortho.jl 100.00% <100.00%> (ø)
... and 9 more

... and 2 files with indirect coverage changes

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

@borisdevos
Copy link
Member Author

Wow it's been a while since I messed up so much with git 😅
Multifusion tests fail because IsingBimodule-graded spaces is still a WIP (QuantumKitHub/TensorKit.jl#263).

@borisdevos
Copy link
Member Author

I may have added some confusing terminology with the recent commits, so let me clarify as much as possible.

First of all, I defined a left/rightunit for MPS and MPO. For the MPS this makes most sense, as my virtual space will in general be graded by module objects, so the "coloring" to the left and right of this is different. So in our convention of physical legs down, rightunit captures the coloring of the physical space, while leftunit captures the coloring of auxiliary legs such as in excitations, transfer_spectrum, etc.
For MPOs I'm still on the fence, because while in general my MPO's virtual space can also be graded by module objects, the only thing I've tested up till now is Hamiltonians where it's fully colored by the rightunit of the corresponding MPS. So this notation is introduced to ease notation mostly. I can deal with not having this; this appears only in the keyword argument of exact_diagonalization.

Connected to the last remark, many functions construct an MPS given an MPO based on the latter's virtual spaces. Since the MPOs I've considered up till now don't have different colorings on its virtual spaces, there is currently no difference between the left unit and right unit of an MPO. Thus, there's no difference between the leftunitspace and rightunitspace of the virtual space of an MPO, and I simply systematically chose to put rightunitspace to accentuate the "physicalness" of the coloring.

I've also replaced the remaining oneunits with unitspaces, where I didn't think too hard whether it was a leftunitspace or rightunitspace because I'd have to fiddle a bit everywhere to actually get the information of the coloring (reminder that left/rightunitspace can't be called on a space type), and in my usage I didn't encounter these constructors. If this is wished, I can more extensively test how these behave with a multifusion sector. Most are easy to tell beforehand that they can't be used. For example, anything requiring non-trivial braiding cannot be done.

@borisdevos borisdevos changed the title Compatibility with MultiTensorKit Compatibility with multifusion categories Dec 19, 2025

V_left = left_virtualspace(H[1])
V_left′ = (V_left, oneunit(V_left), oneunit(V_left))
V_left′ = (V_left, rightunitspace(V_left), rightunitspace(V_left))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could this also be leftunitspace?
This looks a bit funny to have V_left call rightunitspace.

To be completely fair, I'm actually surprised it would have to be left or right to begin with, since I always understood that as something you would multiply on the left or right respectively, and not something you can direct sum with, so I would guess that in this case you would have to have \boxtimes is only possible wheneveer leftunitspace = rightunitspace which is just unitspace?
I might be completely wrong here though, this is a bit more intuition based than actual strong thinking based

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Hamiltonian itself is diagonal, meaning its virtual spaces are graded the same way as the physical space. In that sense, taking the left or right unit space is the same. I haven't thought too much about direct summing between different gradings and whether that makes sense.
Either way, unitspace is not the way to go, because we've designed that now to return all the units of a given sector.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah right, I forgot about that! Would this mean that we could take the left unit space of the physical space instead? That at least sounds spatially correct in my head 😂

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can do that, and will do so in other places where MPOHamiltonian is involved. I'd like to add an assertion to make sure this is fine. However, for MPOs I'd like to keep the freedom of potential off-diagonal virtual spaces, even though I haven't tested those yet.

Comment on lines 423 to 425
# avoid using one(S)
somempo = local_mpos[1].second[1]
_rightunit = space(somempo, 1) # should be rightunitspace, but MPOHamiltonians are always diagonal for now
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would this be equal to leftunitspace(physicalspace)?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, in this case that does give the right space. I'd be tempted to put rightunitspace to emphasise the physical coloring, but if you're talking about the physical space anyway it's the same. I changed it to something cleaner now.

"""
function add_util_leg(tensor::AbstractTensorMap{T, S, N1, N2}) where {T, S, N1, N2}
ou = oneunit(_firstspace(tensor))
ou = unitspace(_firstspace(tensor))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we replace this function with insertleftunit etc?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm looking at this and I think the additional function add_util_mpoleg is now redundant if I use insertleft/rightunit here correctly. I can't seem to remember why I had to split them up in the first place. Maybe a remnant of an older version of MPSKit 🤔

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there any chance these things can easily be interspersed with the other tests?
In any case, we should really clean up the tests of MPSKit at some point, so if this isn't too easy I'm fine keeping it like this and tackling it in the future

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's definitely easy to just copy-paste test sets to other related tests, but some test unique properties of the multifusion sectors themselves, and not necessarily the consistency of the algorithms dealing with this sector. I separated the multifusion tests since the other tests don't necessarily probe how the symmetric tensor data play a role. How do you think we should proceed?

@github-actions
Copy link
Contributor

github-actions bot commented Jan 16, 2026

Your PR no longer requires formatting changes. Thank you for your contribution!

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.

2 participants