Skip to content

Conversation

@borisdevos
Copy link
Member

@borisdevos borisdevos commented Aug 4, 2025

This PR makes use of the newly introduced IsingBimodule multifusion category in QuantumKitHub/TensorKitSectors.jl#14 to test the changes in #247 within TensorKit itself. This was needed because MultiTensorKit depends on TensorKit itself.

What's new:

  • leftoneunit and rightoneunit are introduced to naturally extend oneunit, but not for Type{GradedSpace{...}} because it needs to know the objects within the GradedSpace.
  • artin_braid had an isone check replaced with a multifusion-friendly check (although this might be excessive, since as of now we don't consider braiding within multifusion categories)
  • various custom constructors to deal with not being able to evaluate one(IsingBimodule)
  • tests for IsingBimodule fusion trees, spaces and tensors
  • few changes to existing tests

I left a bunch of comments everywhere to remind me of certain choices I made in the implementation. It would be nice if these were addressed. I can clean most of them afterwards, but should probably keep some of them, or at least the ones in the tests to help whoever might need to maintain those in the future.

As I started on this before #247 got merged, its commit history is here as well, and I'm not sure what kind of rebase I need to do to get rid of it. I tried something and files seemed to want to vanish, so I aborted that attempt 😅 Those luckily don't appear in the files changed though.

IsingBimodule still needs to get renamed to that, so currently everything is IsingBimod. I'm assuming we're waiting on QuantumKitHub/TensorKitSectors.jl#19 to merge to release v0.2 though.

Edit: I forgot to mention, but currently there's one thing broken which I can't find the error in. It appears in the full trace test. Ignoring the part where I don't know what to do with tracing module legs, it seems that the behavior is different for the two fusion categories in IsingBimodule. In particular, the full trace test passes for the "C" fusion category, but not for "D", the latter tracing to zero via @planar. I checked this quickly in MultiTensorKit with the multifusion category I got there, and it is consistent there.

Edit 2: I also forgot that @Jutho and I briefly discussed trying to increase code coverage, most prominently for GenericFusion but also here and there for other functions. I can do this in a separate PR.

borisdevos and others added 30 commits March 17, 2025 17:58
update TensorOperations scalartype determination
sector = leftone(first(sectors(S)))
return spacetype(S)(sector => 1)
end
leftoneunit(S::GradedSpace{I}) where {I<:Sector} = oneunit(typeof(S))
Copy link
Member

Choose a reason for hiding this comment

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

What was wrong with the previous implementations? This looks like it will always fail for multifusion things

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 wanted left/rightoneunit to also work on empty spaces, because oneunit does so. This will indeed fail for multifusion things, hence the specialisation.

Copy link
Member

Choose a reason for hiding this comment

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

I see, but what do you think about this then:

function leftoneunit(V::GradedSpace{I}) where {I<:Sector}
    s = sectors(V)
    u = leftoneunit(isempty(s) ? I : first(s))
    return spacetype(V)(u => 1)
end

Copy link
Member

Choose a reason for hiding this comment

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

It's not great if we have to specialize everything specifically for Vect[IsingBimodule], since this would mean we have to redo all that work for any multifusion category. In that sense, we would either need a fusion type that specifies this, such that we can specialize properly, or write these methods in a generic way that works for everything

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 not sure what you mean by redoing all that work. IsingBimodule should be the only multifusion category tested within TensorKit itself. This infrastructure already exists in MultiTensorKit (albeit in a PR for now), which will support all the other multifusion categories.

Copy link
Member

Choose a reason for hiding this comment

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

What I mean is that if all we are testing is the specializations that are written solely for IsingBimodule, which is used mainly for testing, this doesn't actually help all that much, since it would have to be both reimplemented and retested for other multifusion categories as well

end
@timedtestset "Full trace: test self-consistency" begin
t = rand(ComplexF64, V1 V2' V2 V1')
t2 = permute(t, ((1, 2), (4, 3)))
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 a reason for removing this t2 call?

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 removed all the permutations in tests which weren't explicitely testing for permutations, which I had to do anyway for the multifusion tests. This would allow for testing anyonic sectors if we decide to expand the space list.

Copy link
Member

Choose a reason for hiding this comment

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

That's fair. I think I would like to keep both though, to actually have coverage of as much as possible. Probably it is better to just separate these things out a bit further.

Comment on lines +285 to +287
@planar s2 = t[a b; a b]
@planar t3[a; b] := t[a c; b c]
@planar s3 = t3[a; a]
Copy link
Member

Choose a reason for hiding this comment

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

It's definitely good to test both @planar and @tensor, but we probably want to test both?

Copy link
Member Author

Choose a reason for hiding this comment

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

This was also with expanding to non-symmetric braidings in mind. I could put a SymmetricBraiding check here to then evaluate @tensor if you want?

Comment on lines +51 to +54
allequal(a.col for a in sectors(S)) ||
throw(ArgumentError("sectors of $S do not have the same rightone"))

sector = rightone(first(sectors(S)))
Copy link
Member

@Jutho Jutho Sep 10, 2025

Choose a reason for hiding this comment

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

Suggested change
allequal(a.col for a in sectors(S)) ||
throw(ArgumentError("sectors of $S do not have the same rightone"))
sector = rightone(first(sectors(S)))
allequal(rightone, sectors(S)) || throw(throw(ArgumentError("sectors of $S do not have the same rightone"))
return spacetype(S)(rightone(first(list))=>1)

borisdevos added a commit that referenced this pull request Sep 26, 2025
lkdvos pushed a commit that referenced this pull request Oct 14, 2025
lkdvos added a commit that referenced this pull request Oct 15, 2025
* change TensorKitSectors compat

* add `unitspace`

* one -> unit + left/rightone -> left/rightunit + isone -> isunit when concerning sectors + some more unitspace

* change conj to dual for sectors

* export new functions from TensorKitSectors

* introduce `zerospace` to replace `zero` of a space

* add `oneunit` for type of space

* format

* minor changes from #263

* use the const `TK` in tests where appropriate

* `otimes` between tensormaps to account for `sectorscalartype`

* formatter

* update frobeniusschur

* reimplement otimes

* remove todo comment that breaks docstring

* fix test

* docs fixes

* Reorganize exports in TensorKit.jl

* More reorganization of exports

* Fix typo in export reorganization

---------

Co-authored-by: Lukas Devos <ldevos98@gmail.com>
Co-authored-by: Jutho <Jutho@users.noreply.github.com>
borisdevos added a commit that referenced this pull request Nov 3, 2025
@borisdevos borisdevos closed this Dec 2, 2025
borisdevos added a commit that referenced this pull request Dec 3, 2025
* change TensorKitSectors compat

* add `unitspace`

* one -> unit + left/rightone -> left/rightunit + isone -> isunit when concerning sectors + some more unitspace

* change conj to dual for sectors

* export new functions from TensorKitSectors

* introduce `zerospace` to replace `zero` of a space

* add `oneunit` for type of space

* format

* minor changes from #263

* use the const `TK` in tests where appropriate

* format

* `otimes` between tensormaps to account for `sectorscalartype`

* generalise `unitspace` and `zerospace`

* have `dim` of graded space depend on sectorscalartype

* introduce `left/rightunitspace`

* generalise `blocksectors` of homspace

* generalise `scalar`

* some exports

* rename `insertleft/rightunit` and `removeunit` to `insertleft/rightunitspace` and `removeunitspace`

* undo the renaming in the changelog

* update `insertleft/rightunitspace`

* add fixme

* fix bad merge conflict choices

* remove TensorKit shortcuts where they don't exist

* another merge fix

* more merge changes + add `IsingBimodule` to sectorlist

* make spaces tests multifusion-friendly

* apply tensors test changes from #263

* avoid `one` call in `rank` of tensormap

* use `sum` in `dim` of `GradedSpace`

* change one more `oneunit` to `unitspace`

* changes to `(left/right)unitspace` and `zerospace`

* remove module specification

* Revert "remove module specification"

This reverts commit 9ffa2dc.

* keep `init` in `dim` and deal with repercussions in src

* change `removeunitspace` to look for any unit instead of all

* add `IsingBimodule` spaces and help functions for fusiontree tests

* rewrite and reorganise fusiontree tests

* rewrite and reorganise factorisation tests

* rewrite and reorganise tensor tests

* another float dim thingie correction

* remove comment

* bring back `insertleft/rightunit` and `removeunit`

* remove dupe exports

* fix `dim` and revert unnecessary Int converts

* change blocksectors of empty productspace

* fix gradedspace tests for product sectors including multifusion

* bring back `Int` for truncrank dimensions

* bump TensorKitSectors compat

* suggestions to dim and pinv

* fix doc error

* add docstring to `unitspace`

* fix `allequal` version dep

* format

* move code around + docstring extension

* introduce `isunitspace` + use in `removeunit`

* `isunit` change

* clean up some tests + reduce git diff

* have `blocksectors` always return a vector

* rename + add todo

* rewrite spaces tests to not specialise to fusion or multifusion

* potential fix to isometry test

* keep `@tensor` for symmetric braiding test

* keep `@tensor` tests + add todo

* fix return type of rank + test

* more isunits

* clean up `random_fusion` + remove redundant setup function

* assert spaces are suitable for factorization tests + deal with float dim

* get `insertleft/rightunit` working without explicit indices + edit some homspaces

* reduce git diff

* variable renames

* tests for `is/left/rightunitspace`

* format

* get some trace tests working for multifusion + remove some todos

* revert `isunit` change to `isone`

* fix full trace test for fermions

* return error for `fusiontrees` without coupled sector for `GenericUnit`

* get double fusion tree tests working for `GenericUnit`

* suggested source changes

* factorisations test  changes

* let full and partial trace tests run for every sector

* accidently removed part of test

* Update test/tensors/factorizations.jl

Co-authored-by: Lukas Devos <ldevos98@gmail.com>

* code suggestions

* get rid of try-catch block

* code suggestions

* format

* deal with different error type thrown

* make spaces compatible in isometric projections

* Update test/symmetries/spaces.jl

Co-authored-by: Jutho <Jutho@users.noreply.github.com>

* help `random_fusion` in while loop

* `isa`'s, CI friendliness, braiding conditions and todos

* import `HasBraiding` manually

* Revert "import `HasBraiding` manually"

This reverts commit 9fc7aa8.

* export `HasBraiding` in TensorKit

---------

Co-authored-by: Lukas Devos <ldevos98@gmail.com>
Co-authored-by: Jutho <Jutho@users.noreply.github.com>
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.

3 participants