Cannot use a QReg with consumed or uninitialized qubits: [0]

Posted almost 2 years ago by Razeen Ud Din

Post a topic
Un Answered
R
Razeen Ud Din

Here is some sample code in classiq in which I intialized circuit with some specific state and applying some specific gates:

probabilities = (0.25, 0.25, 0, 0, 0.25, 0, 0, 0.25)

from classiq.builtin_functions import StatePreparation

State = StatePreparation(probabilities=probabilities, error_metric={"KL": {"upper_bound": 0.3}})

from classiq.builtin_functions import RZGate,StatePreparation,CXGate,XGate, IGate

from classiq import Model

model = Model()

Initialized_state = model.StatePreparation(State)

pre_check = model.XGate(XGate(), in_wires={"TARGET":Initialized_state["OUT"][1]})

check = model.CXGate(CXGate(), in_wires={"TARGET":pre_check["TARGET"],"CTRL":Initialized_state["OUT"][0]})

post_check1 = model.XGate(XGate(), in_wires={"TARGET":check["CTRL"]})

I_check =  model.IGate(IGate(), in_wires={"TARGET":post_check1["TARGET"]})

from classiq import synthesize , show

qprog = synthesize(model.get_model())

show(qprog)

As one can easily see to use the same qubit again we have to name it with some variable so that we can use this qubit further in the next step otherwise if we didn't give the name Classiq framework through error that you can't used consumable qubit again. But this practice become very cumbersome if we have to use conditional statements to apply. Can we do the the programming of circuit without using this practice like as we can do in QISKIT where we have to just name the qubit like X.qc[1] and it apply X gate on qubit one. Can we do the same in Classiq and How? Any help is appreciated. Thank you

0 Votes


0 Comments

Login or Sign up to post a comment