Skip to content

Conversation

@sagnikpal2004
Copy link
Collaborator

@sagnikpal2004 sagnikpal2004 commented Jul 23, 2025

Adds the apply_right! function into QuantumClifford to apply a Clifford Operator (dense or symbolic) to the right of another clifford operator, modifying it inplace.

  • The code is properly formatted and commented.
  • Substantial new functionality is documented within the docs.
  • All new functionality is tested.
  • All of the automated tests on github pass.

Changelog:

  • added apply_right! that applies a clifford operator to the right of another

Notes:

  • The symbolic operations make use of three basic operations: rowswap!(r1, r2), mul_right_ignore_anticommute!(r1, r2) and phase_flip!(r1). There could be macros built that definte the operations from these basic ones.

Closes #555
Is a dependency to PR #551

Adaptation of Stim's prepend_

Copy link
Member

@Krastanov Krastanov left a comment

Choose a reason for hiding this comment

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

feel free to merge after these are addressed if there are no new issues and all tests pass

@codecov
Copy link

codecov bot commented Jul 28, 2025

Codecov Report

❌ Patch coverage is 94.73684% with 12 lines in your changes missing coverage. Please review.
✅ Project coverage is 84.66%. Comparing base (09f2172) to head (8e2fb74).
⚠️ Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
src/mul_leftright.jl 0.00% 8 Missing ⚠️
src/apply_right.jl 98.18% 4 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #561      +/-   ##
==========================================
+ Coverage   84.33%   84.66%   +0.33%     
==========================================
  Files         108      109       +1     
  Lines        6581     6809     +228     
==========================================
+ Hits         5550     5765     +215     
- Misses       1031     1044      +13     

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

Copy link
Member

@Krastanov Krastanov left a comment

Choose a reason for hiding this comment

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

let's have the the other PR merged and potentially have this rebased (or fix the merge conflict in another way)

Left some potential suggestions for fixing the allocation issue (forcing the compiler to move the runtime choice on phases into the type domain), but that is a bit embarrassing (the compiler should be smarter than this)

Feel free to merge after these are addressed (and add changelog) if all tests pass

new_lrow.phase[] -= 0x1
end
if x
mul_left!(new_lrow, l_tab_copy, qubit, phases=Val(phases))
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
mul_left!(new_lrow, l_tab_copy, qubit, phases=Val(phases))
mul_left!(new_lrow, l_tab_copy, qubit, phases=B)

mul_left!(new_lrow, l_tab_copy, qubit, phases=Val(phases))
end
if z
mul_left!(new_lrow, l_tab_copy, qubit+n, phases=Val(phases))
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
mul_left!(new_lrow, l_tab_copy, qubit+n, phases=Val(phases))
mul_left!(new_lrow, l_tab_copy, qubit+n, phases=B)

end

"""helper for computing the right multiplication of a row of a Clifford operator with another Clifford operator."""
@inline function apply_right_row_kernel!(new_lrow, l_tab, row, l_tab_copy, r_tab; phases=true)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
@inline function apply_right_row_kernel!(new_lrow, l_tab, row, l_tab_copy, r_tab; phases=true)
@inline function apply_right_row_kernel!(new_lrow, l_tab, row, l_tab_copy, r_tab; phases::B=Val{true}()) where {B}

threadlocal = l.buffer
@inbounds for row_r in eachindex(r_tab)
zero!(threadlocal)
apply_right_row_kernel!(threadlocal, l_tab, row_r, l_tab_copy, r_tab; phases)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
apply_right_row_kernel!(threadlocal, l_tab, row_r, l_tab_copy, r_tab; phases)
apply_right_row_kernel!(threadlocal, l_tab, row_r, l_tab_copy, r_tab; phases=Val{phases}())

@sagnikpal2004 sagnikpal2004 force-pushed the apply_right branch 2 times, most recently from 4e6af0b to c7d6f04 Compare August 10, 2025 02:17
@sagnikpal2004 sagnikpal2004 merged commit 9fc98a3 into QuantumSavory:master Aug 11, 2025
26 checks passed
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.

apply_right! and apply_inv_right!

2 participants