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
@borisdevos
Copy link
Member Author

I managed to fix the last bug I mentioned in the beginning. It turns out I should've known it was that, because I encountered that issue twice already previously 😭

I ended up putting all IsingBimodule-dependent functions in one file. I'm not sure if this is preferred, or if I should spread them out in the existing files.

Copy link

codecov bot commented Aug 7, 2025

Codecov Report

❌ Patch coverage is 92.95775% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 83.49%. Comparing base (87d4662) to head (9b5ba0b).

Files with missing lines Patch % Lines
src/spaces/multifusionspace.jl 91.93% 5 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #263      +/-   ##
==========================================
+ Coverage   83.39%   83.49%   +0.10%     
==========================================
  Files          44       45       +1     
  Lines        5757     5823      +66     
==========================================
+ Hits         4801     4862      +61     
- Misses        956      961       +5     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

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

@borisdevos borisdevos changed the title [WIP] IsingBimodule for testing multifusion category within TensorKit IsingBimodule for testing multifusion category within TensorKit Aug 7, 2025
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

@@ -268,28 +272,27 @@ for V in spacelist
end
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?

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