Skip to content

Prevent construction of multifusion tensors with incompatible coloring - #515

Merged
lkdvos merged 22 commits into
mainfrom
bd/fusiontree-iterate
Sep 10, 2026
Merged

Prevent construction of multifusion tensors with incompatible coloring#515
lkdvos merged 22 commits into
mainfrom
bd/fusiontree-iterate

Conversation

@borisdevos

@borisdevos borisdevos commented Aug 26, 2026

Copy link
Copy Markdown
Member

Deals with #514, at least partially.
Now we have

julia> Wis
(Vect[IsingBimodule]((1, 1, 0) => 1)  Vect[IsingBimodule]((1, 1, 0) => 1))  Vect[IsingBimodule]((2, 2, 0) => 1)

julia> blocksectors(Wis)
0-element Dictionaries.Indices{IsingBimodule}

which behaves the same way as

julia> Wu1
Rep[U₁](1 => 1)  (Rep[U₁](0 => 1)  Rep[U₁](0 => 1))

julia> blocksectors(Wu1)
0-element Dictionaries.Indices{U1Irrep}

Edit: decided to actually prevent construction of these kinds of tensors at the level of the product space and hom space.
Since this was incompatible with the previous implementation of unitspace, this now errors for GenericUnit sector types.

@lkdvos lkdvos left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I do think this is probably quite a big performance hit right in the hot path of the fusiontree constructors though, I don't think there is typically a fast implementation of this. Additionally, I was kind of expecting to convert more things to Nsymbol, to actually make them error if the fusion is disallowed?

@borisdevos

Copy link
Copy Markdown
Member Author

I'm misunderstanding then what kind of behavior we want. So we want Nsymbol checks there, such that forbidden fusion trees shouldn't ever be able to be looked at? And then at the tensor construction level, when colors mismatch this should throw an error, thus preventing constructing forbidden tensors?

@lkdvos

lkdvos commented Aug 26, 2026

Copy link
Copy Markdown
Member

I think that was what I was expecting, especially since we decided Nsymbol errors instead of returning 0

@codecov

codecov Bot commented Aug 26, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 94.28571% with 4 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/spaces/vectorspaces.jl 84.21% 3 Missing ⚠️
src/spaces/homspace.jl 96.29% 1 Missing ⚠️
Files with missing lines Coverage Δ
src/spaces/gradedspace.jl 72.52% <100.00%> (-20.01%) ⬇️
src/spaces/productspace.jl 81.54% <100.00%> (-6.36%) ⬇️
src/tensors/tensoroperations.jl 96.53% <100.00%> (ø)
src/spaces/homspace.jl 89.63% <96.29%> (-1.74%) ⬇️
src/spaces/vectorspaces.jl 65.07% <84.21%> (-4.60%) ⬇️

... and 21 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 borisdevos changed the title Replace Nsymbol calls or add guards in fusion tree iteration Prevent construction of multifusion tensors with incompatible coloring Sep 2, 2026

@lkdvos lkdvos left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Other than the comments, looks good, thanks for looking into this!

Comment thread src/spaces/gradedspace.jl
Comment thread src/spaces/productspace.jl Outdated
Comment thread src/spaces/productspace.jl Outdated
Comment thread src/spaces/homspace.jl Outdated
Comment thread src/spaces/vectorspaces.jl Outdated
Comment thread src/spaces/gradedspace.jl
@lkdvos

lkdvos commented Sep 9, 2026

Copy link
Copy Markdown
Member

I made another small change that handles more edge cases, in particular I was kind of worried about your any(isempty(...))) checks, in the sense that while these don't allow us to check that particular factor, it still means we can check the other ones, so I've slightly refactored that, basically treating isempty spaces as a wildcard.

@lkdvos
lkdvos requested a review from Jutho September 9, 2026 20:55
Comment thread src/spaces/vectorspaces.jl Outdated

# Return the `(leftunit, rightunit)` shared by all sectors of `V`, or `nothing` for the zero
# space, whose coloring is unconstrained and thus acts as a wildcard in unit checks.
function _units(V::ElementarySpace)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I would be more explicit and call this function _leftrightunit

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Also, since we are now checking a lot, I think the question is whether this check should already appear in the GradedSpace constructors. Currently, I can still construct something like GradedSpace(c=>1 for c in allunits(I)), but as soon as I take tensor products with this space, I get errors? That does not sound like the correct behaviour.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

implemented. This was slightly annoying since our tests were not fully compatible with that, but I think I managed to bypass this.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Just to motivate why I didn't do it at the GradedSpace level: I treat GradedSpace as some semi-simple object of a sector type. Only from ProductSpace onwards is it really seen as "a leg of a tensor". But it's fine as-is

Comment thread src/spaces/vectorspaces.jl Outdated
@lkdvos
lkdvos requested a review from Jutho September 10, 2026 13:52
Comment thread src/spaces/gradedspace.jl Outdated
Comment thread src/spaces/vectorspaces.jl Outdated
@Jutho

Jutho commented Sep 10, 2026

Copy link
Copy Markdown
Member

Seems to cause an error in some tests, but I don't understand/see where it is coming from. The line numbers in test/symmetries/singletree.jl seem off.

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

lkdvos commented Sep 10, 2026

Copy link
Copy Markdown
Member

Can confirm the test failures are solely due to v1 switching from 1.12 to 1.13, so I'll address these in separate PRs to keep things contained. This should then be good to go once the other tests turn green, and I'll merge.

@borisdevos

Copy link
Copy Markdown
Member Author

Thanks a lot for your help on this!

@lkdvos

lkdvos commented Sep 10, 2026

Copy link
Copy Markdown
Member

rebase/remerge is not necessary, will just wait for tests to run and then merge into main directly.

@lkdvos
lkdvos merged commit 01d3927 into main Sep 10, 2026
58 of 72 checks passed
@lkdvos
lkdvos deleted the bd/fusiontree-iterate branch September 10, 2026 22:50
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