Skip to content

Conversation

dstrain115
Copy link
Collaborator

@dstrain115 dstrain115 commented Jul 25, 2025

  • There were a few issues with the new strategy to fall back to super-operator calculations using apply_channels.
  • First, the super_operator_to_kraus function is generally not precise or numerically stable enough to support an atol of 1e-10 so loosened this to 1e-6 and also allowed the ability to specify this as a parameter.
  • Next, some operators define decomposition, so cirq.kraus should try to decompose and get a unitary before falling back to using apply_channel.

Fixes: #7536

- There were a few issues with the new strategy to fall back
to super-operator calculations using apply_channels.
- First, the super_operator_to_kraus function is generally not
precise or numerically stable enough to support an atol of 1e-10
so loosened this to 1e-6 and also allowed the ability to specify
this as a parameter.
- Next, some operators define decomposition, so cirq.kraus should
try to decompose and get a unitary before falling back to
using apply_channel.
@dstrain115 dstrain115 requested review from vtomole and a team as code owners July 25, 2025 18:05
@dstrain115 dstrain115 requested a review from fdmalone July 25, 2025 18:05
@github-actions github-actions bot added the size: S 10< lines changed <50 label Jul 25, 2025
Copy link
Contributor

@mhucka mhucka left a comment

Choose a reason for hiding this comment

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

LGTM with requests for some minor docstring adjustments.

@@ -149,6 +153,8 @@ def kraus(
default: Determines the fallback behavior when `val` doesn't have
a channel. If `default` is not set, a TypeError is raised. If
default is set to a value, that value is returned.
atol: If calculating kraus channels from channels, use this tolerance
Copy link
Contributor

Choose a reason for hiding this comment

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

Typo: kraus → Kraus



def test_kraus_channel_with_has_unitary():
"""CZSWAP is a gate with no unitary but has a unitary."""
Copy link
Contributor

Choose a reason for hiding this comment

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

I think there is something wrong with this docstring ;-)

@dstrain115 dstrain115 requested a review from mhucka July 25, 2025 22:17
Copy link

codecov bot commented Jul 25, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.53%. Comparing base (31df8ef) to head (2835273).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #7537      +/-   ##
==========================================
- Coverage   97.53%   97.53%   -0.01%     
==========================================
  Files        1095     1095              
  Lines       99006    99014       +8     
==========================================
+ Hits        96570    96576       +6     
- Misses       2436     2438       +2     

☔ 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.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Contributor

@mhucka mhucka left a comment

Choose a reason for hiding this comment

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

LGTM

@mhucka mhucka added this pull request to the merge queue Jul 25, 2025
Merged via the queue into quantumlib:main with commit 6d10979 Jul 25, 2025
35 checks passed
pavoljuhas pushed a commit that referenced this pull request Aug 14, 2025
- There were a few issues with the new strategy to fall back to
super-operator calculations using apply_channels.
- First, the super_operator_to_kraus function is generally not precise
or numerically stable enough to support an atol of 1e-10 so loosened
this to 1e-6 and also allowed the ability to specify this as a
parameter.
- Next, some operators define decomposition, so cirq.kraus should try to
decompose and get a unitary before falling back to using apply_channel.

Fixes: #7536
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size: S 10< lines changed <50
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Kraus channels of CZSWAP are broken
2 participants