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 we use Reset Qubits without using measurement in Project Q? #477

Open
saifawan2703 opened this issue Oct 8, 2024 · 1 comment
Open

Comments

@saifawan2703
Copy link

Hi everyone,

I would like to know if there is a way to reset a qubit to the |0⟩ state in ProjectQ without performing a measurement. The reason is that after measuring, I am unable to use the compute-uncompute pattern.
like that

with Compute(eng):
    All(H) | k0
    All(H) | k1
    All(X) | k0
    All(X) | k1

with Control(eng, k0[0:4]):
        with Control(eng, k1[0:-1]):
            Z | k1[-1]  
Uncompute(eng)  #

Any guidance on this would be appreciated.

@saifawan2703 saifawan2703 changed the title Reset Qubits without using measurement in Project Q How we use Reset Qubits without using measurement in Project Q? Oct 8, 2024
@damiansteiger
Copy link
Contributor

You want to use a measurement within the with Compute section?

A reset or measurement of a qubit within the compute section is not possible (compiler would need to automatically generate an inverse for the uncompute section which is not possible in general, i.e., unknown quantum state before reset or measurement)

Ancilla qubits can be allocated with the compute section and deallocated if they are returned to 0 deterministically. See doc

For more advanced use cases there is always the option to specify the uncompute section with a CustomUncompute

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

No branches or pull requests

2 participants