0
$\begingroup$

I am trying to implement the partial trace operation on IBMs quantum computer. I am simulating the depolarising channel with the following code

#aim here is to build the decoherence channel
p=0.1;
z=0.5+0.5*math.sqrt(1-p);
desiredvec=[
    math.sqrt(1-z),
    math.sqrt(z)]
circuit2 = QuantumCircuit(4,3);
circuit2.initialize(desiredvec,0)
circuit2.initialize(desiredvec,1)
circuit2.initialize(desiredvec,2)
circuit2.cx(0,3)
circuit2.h(3)
circuit2.s(3)
circuit2.cx(1,3)
circuit2.h(3)
circuit2.s(3)
circuit2.cx(2,3)
circuit2.h(3)
circuit2.s(3)
circuit2.draw()

I would now like to trace out all but qubit 3 as it is the only qubit I am interested in. I can get around this by just ignoring the other qubits but I would rather not do this. Is there any easy way to trace out unwanted qubits?

Or equivalently is there a way to initalise the qubit in a mixed state so that the extra ancillary qubits aren't needed in the first place?

$\endgroup$
1
$\begingroup$

qiskit.quantum_info has a partial_trace method you can use for this.

It takes as input either a Statevector or a DensityMatrix object. Both these classes implement the from_instruction routine that you can use with the QuantumCircuit object you already have. You would have to do something along the lines of:

circuit2 = QuantumCircuit(4,3)

...
# your operations
...

statevec = Statevector.from_instruction(circuit2)
trace = partial_trace(statevec, 3)

Hope this helps!

| improve this answer | |
$\endgroup$
1
$\begingroup$

On a quantum computer, there is no point in implementing a partial trace. Just ignore the qubits which you want to trace.

| improve this answer | |
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.