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

How to add Global Phase gate to CUDAQ kernels #1821

Open
ACE07-Sev opened this issue Jun 16, 2024 · 1 comment
Open

How to add Global Phase gate to CUDAQ kernels #1821

ACE07-Sev opened this issue Jun 16, 2024 · 1 comment
Labels
language Anything related to the CUDA Quantum language specification
Milestone

Comments

@ACE07-Sev
Copy link

Greetings there,

Hope all are well. I would like to know how I can add a global phase gate. I initially wanted to do this by adding its unitary matrix form, but since that is not currently supported, I'd like to know how I can add it with the current 0.7.x releases.

@bettinaheim bettinaheim added this to the release 0.8.0 milestone Jul 1, 2024
@schweitzpgi schweitzpgi added the language Anything related to the CUDA Quantum language specification label Jul 5, 2024
@1tnguyen
Copy link
Collaborator

Hi @ACE07-Sev,

Global phase rotation can be accommodated by the custom unitary matrix gate feature (upcoming 0.8 release) or by using a gate decomposition.

The latter leveraged the fact that r1 and rz gates (CUDA-Q supported gates) are equivalent up to a global phase.
Here is a simple example demonstrating that:

import cudaq
import math

@cudaq.kernel
def global_phase(theta: float):
    # Global phase e(i*theta) == r1(2*theta) * rz(-2*theta)
    qubit = cudaq.qubit()
    # make it |0> + |1>
    h(qubit)
    rz(-2*theta, qubit)
    r1(2*theta, qubit)

# Global phase of pi == multiply the state by -1
state = cudaq.get_state(global_phase, math.pi)
print(state) # expect (-(|0> + |1>))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
language Anything related to the CUDA Quantum language specification
Projects
None yet
Development

No branches or pull requests

4 participants