Skip to content

Fix controlled GF2MulK decomposition when control is 0 - #1966

Open
rupasri118 wants to merge 2 commits into
quantumlib:mainfrom
rupasri118:fix-controlled-gf2mulk
Open

rupasri118 wants to merge 2 commits into
quantumlib:mainfrom
rupasri118:fix-controlled-gf2mulk

Conversation

@rupasri118

Copy link
Copy Markdown

Summary

Fixes #1951.

The permutation step in SynthesizeLRCircuit was implemented using direct Soquet rewiring. When GF2MulK was controlled, this permutation remained unconditional, causing the decomposed circuit to modify the target register even when the control qubit was 0.

This change represents the permutation using TwoBitSwap, making it an explicit Bloq that can be correctly controlled during decomposition.

Changes

  • Replace direct Soquet swapping with TwoBitSwap in SynthesizeLRCircuit.
  • Add a regression test for controlled GF2MulK decomposition.
  • Verify that:
    • ctrl=0 leaves the input unchanged.
    • ctrl=1 performs multiplication by the specified constant.

Testing

  • test_multiply_by_constant_controlled_decomposition — passed
  • test_synthesize_lr_circuit — 8 passed
  • gf2_multiplication_test.py excluding notebook tests — 78 passed before a long-running test was interrupted.

@google-cla

google-cla Bot commented Oct 7, 2026

Copy link
Copy Markdown

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@rupasri118

Copy link
Copy Markdown
Author

Updated the controlled GF2 multiplication decomposition to use explicit TwoBitSwap operations for controlled permutations while preserving wire reordering for uncontrolled synthesis.

Validation:

  • Controlled multiplication decomposition test: passed.
  • FLASQ Karatsuba span test: passed.
  • Multiplication test suite: 299 passed, 3 skipped, 3 expected failures.
  • Notebook test: passed after installing Graphviz.

@rupasri118
rupasri118 force-pushed the fix-controlled-gf2mulk branch from 3924131 to a4b8900 Compare October 16, 2026 07:05
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.

GF2MulK().controlled().decompose_bloq().flatten() is not identity when ctrl=0

1 participant