Skip to content

Fix bug in summing QN conserving tensor networks#295

Closed
emstoudenmire wants to merge 7 commits intomainfrom
MS_bug_sum_product_states
Closed

Fix bug in summing QN conserving tensor networks#295
emstoudenmire wants to merge 7 commits intomainfrom
MS_bug_sum_product_states

Conversation

@emstoudenmire
Copy link
Copy Markdown
Contributor

This PR fixes an issue with summing two QN-conserving tensor networks when using the "directsum" backend.

The issue occurs when the input TNs have tensors with varying, non-zero flux, even though each TN has the same total flux. Before this PR, the code would directsum all the local tensors together, resulting in local tensors with "mixed flux" which is not allowed. As a side note, we may want to have directsum throw an error when this happens.

This PR orthogonalizes the input TNs to the same root vertex before proceeding with the directsum algorithm. With this orthogonalization step, the only way the directsum strategy could fail would be if the TNs had different total flux, which would be a user error.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Mar 1, 2026

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

@codecov
Copy link
Copy Markdown

codecov Bot commented Mar 1, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 69.10%. Comparing base (245d23d) to head (e852238).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #295      +/-   ##
==========================================
+ Coverage   69.00%   69.10%   +0.09%     
==========================================
  Files          81       81              
  Lines        4027     4027              
==========================================
+ Hits         2779     2783       +4     
+ Misses       1248     1244       -4     
Flag Coverage Δ
docs ?

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ 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.

@emstoudenmire
Copy link
Copy Markdown
Contributor Author

This PR was based on an out-of-date version of ITensorNetworks, which overcomplicated it.
I'll submit a new PR with only the relevant changes.

@emstoudenmire emstoudenmire deleted the MS_bug_sum_product_states branch March 1, 2026 04:13
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.

1 participant