Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make Clifford plus T decomposition output shorter circuits #6131

Open
cvjjm opened this issue Aug 22, 2024 · 4 comments
Open

Make Clifford plus T decomposition output shorter circuits #6131

cvjjm opened this issue Aug 22, 2024 · 4 comments
Labels
enhancement ✨ New feature or request

Comments

@cvjjm
Copy link
Contributor

cvjjm commented Aug 22, 2024

Feature details

It is very cool that PL ships a Clifford plus T decomposition transform!

However it does seem to struggle in certain cases. An extreme example is:

print(qml.draw(qml.transforms.clifford_t_decomposition(qml.adjoint(qml.S)))(0))

which produces the gate sequence:

0: ──H──T──H──T†──T†──T†──H──T──H──T──T──H──T†──H──T──H──T──H──T†──T†──T†──T†──H──T──H──T──T──T──H

───T†──H──T†──H──T──H──T†──T†──H──T†──H──T──T──GlobalPhase(0.79)─┤  <Z>

Clearly this is not optimal :-)

Implementation

No response

How important would you say this feature is?

1: Not important. Would be nice to have.

Additional information

No response

@cvjjm cvjjm added the enhancement ✨ New feature or request label Aug 22, 2024
@josh146
Copy link
Member

josh146 commented Aug 23, 2024

Thanks @cvjjm! from chatting to the team, this seems to come from the adjoint modifier; exchanging the decomposition and the qml.adjoint resolves the problem (compiling to S^\dagger). I wonder if the ability to smartly swap transforms that are associative might help here 🤔

Some other thoughts:

@josh146
Copy link
Member

josh146 commented Aug 23, 2024

We're curious if you've encountered any other cases where the clifford decomposition struggles?

@cvjjm
Copy link
Contributor Author

cvjjm commented Aug 23, 2024

I noticed that I got very deep circuits for a circuit that should have been Clifford in the first place. I wanted to use clifford_t_decomposition to verify that and got very long circuits with T gates. I then tried simpler and simpler circuits until I arrived at the minimal example above.

Another good example that should not need T gates but produces loads is:

>>>print(qml.draw(qml.transforms.clifford_t_decomposition(qml.adjoint(qml.IsingXX)))(np.pi/2, [0, 1]))
0: ─╭●──T──H──T†──T†──T†──H──T──H──T──T──H──T†──H──T──H──T──H──T†──T†──T†──T†──H──T──H──T──T──T──H
1: ─╰X────────────────────────────────────────────────────────────────────────────────────────────

───T†──H──T†──H──T──H──T†──T†──H──T†──H──T──T──H─╭●─┤
─────────────────────────────────────────────────╰X─┤

@isaacdevlugt
Copy link
Contributor

@cvjjm thanks for reporting this! We'll leave the issue open for now and investigate a fix for this. We will update here if there is any movement.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement ✨ New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants