Skip to content

Conversation

@borisdevos
Copy link
Member

@borisdevos borisdevos commented Dec 18, 2025

This PR is a proposal to fix QuantumKitHub/TensorKit.jl#245. This allows us to keep UniqueFusion the way it is, and is an easier solution to rewriting TensorKit.foldright itself. Specifically, https://github.com/QuantumKitHub/TensorKit.jl/blob/155aa8997ef8eba1dfa53cd368097ae41aa2a10b/src/fusiontrees/manipulations.jl#L352 would then have an additional && FusionDataStyle(I) isa TrivialFusionData check. Testing locally with I = Z2Element{1} and this passes the transpose tests.*

I didn't think too hard about the name. Other options I can think of are AssociatorStyle and RecouplingStyle. All these names have their merits and demerits. I also didn't think if this was the ideal approach, but I just wanted to get the ball rolling.

*Unrelated to this PR, but as of now Z2Element{1} passes all TensorKit tests, and Z3Element{1} passes the transpose tests, but fail at braiding tests. Still looking into this, but it seems that the non-self-dual nature and non-trivial F-symbols are messing things up somewhere, even if I blindly add the FusionDataStyle check where UniqueFusion is checked. This is a WIP, just wanted to mention it here already.

@codecov
Copy link

codecov bot commented Dec 18, 2025

Codecov Report

❌ Patch coverage is 79.16667% with 5 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/sectors.jl 75.00% 2 Missing ⚠️
src/anyons.jl 66.66% 1 Missing ⚠️
src/groupelements.jl 50.00% 1 Missing ⚠️
src/trivial.jl 0.00% 1 Missing ⚠️
Files with missing lines Coverage Δ
src/TensorKitSectors.jl 16.66% <ø> (ø)
src/fermions.jl 73.80% <100.00%> (+0.63%) ⬆️
src/irreps/a4irrep.jl 100.00% <100.00%> (ø)
src/irreps/cu1irrep.jl 96.45% <100.00%> (+0.02%) ⬆️
src/irreps/dnirrep.jl 97.35% <100.00%> (+0.01%) ⬆️
src/irreps/irreps.jl 96.66% <100.00%> (+0.11%) ⬆️
src/irreps/su2irrep.jl 97.36% <100.00%> (+0.07%) ⬆️
src/multifusion.jl 91.30% <100.00%> (+0.19%) ⬆️
src/product.jl 91.73% <100.00%> (+0.07%) ⬆️
src/timereversed.jl 97.05% <100.00%> (+0.08%) ⬆️
... and 4 more
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Member

@lkdvos lkdvos left a comment

Choose a reason for hiding this comment

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

I'm not entirely sure how I feel about this, since I would say there are some conflicting things that influence this decision.

On the one hand, I agree that it would be nice to keep things non-breaking. However, at least in the current design, I'm not sure this is still non-breaking. If we add a call to FusionDataStyle in TensorKit, we are assuming this is implemented for all Sectors, which at least would require a default of NonTrivialFusionData to be registered.

I also just feel like the "cleanest" solution in the long run would just be to have an additional TrivialFusion <: FusionStyle step to the ladder of FusionStyles, however this might also be breaking, since we are using things like FusionStyle(x) isa UniqueFusion to detect anything that doesn't have multiple fusion outputs, which would now fail for TrivialFusion.

If we really want this to be non-breaking, I think we should just fix the foldright implementation to not assume that the Fsymbols are 1, and just specialize that function for <:AbelianIrrep in order to not have any performance regressions there. I don't think the performance is that crucial here anyways, in the sense that even the SimpleFusion implementations might just be fast enough?

I'm slightly hesitant to really add a new style specifically for this, since FusionDataStyle really isn't something that is independent of the FusionStyle, so that feels a bit off to me

@borisdevos
Copy link
Member Author

I'm down to look into fixing foldright for UniqueFusion if that's the only guaranteed non-breaking change, but I'm assuming this will look just like the non-UniqueFusion case with some manual fusion tree constructions and less for-loops, which I can't tell will boost performance.

I also just want to add that you would specialise to more than just abelian irreps, but also fermions, D2Irrep and ZNElement{0}. This latter part was my main motivation for a new style to differentiate "cleanly" (arguable), but it is indeed independent of FusionStyle (which was the motivation of the name).

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.

foldright assumptions for UniqueFusion

3 participants