Closed shinich1 closed 9 months ago
Hi @shinich1, I'm interested in working on this issue as part of the Unitary Hack. Can I be assigned to this challenge? Thank you!
Hi @shinich1, I'm interested in working on this issue as part of the Unitary Hack. Can I be assigned to this challenge?
Thank you!
Yes please go ahead and work on this issue, thanks for your interest! According to unitaryHack guide, assigning to issue indicates successful merging of associated PR - so it should wait until there's a PR ready to merge.
Feel free to ask any question regarding graphix or the issue on this page :)
Oh, I misunderstood that I have to be assigned prior to the PR. Thank you for the correction.
Hi, I have a question. I used a textbook method to decompose Toffili gate as follows, and it seems like running pattern.perform_pauli_measurements()
will give a wrong result $\ket{111}$ instead of $\ket{110}$. Am I missing out on something?
circuit = Circuit(3)
# prepare |000>
circuit.h(0)
circuit.h(1)
circuit.h(2)
# prepare |111>
circuit.x(0)
circuit.x(1)
circuit.x(2)
# toffoli
circuit.h(2)
circuit.cnot(1, 2)
circuit.rz(2, -np.pi/4)
circuit.cnot(0, 2)
circuit.rz(2, np.pi/4)
circuit.cnot(1, 2)
circuit.rz(1, np.pi/4)
circuit.rz(2, -np.pi/4)
circuit.cnot(0, 2)
circuit.cnot(0, 1)
circuit.rz(2, np.pi/4)
circuit.rz(0, np.pi/4)
circuit.rz(1, -np.pi/4)
circuit.h(2)
circuit.cnot(0, 1)
# transpile
pattern = circuit.transpile()
pattern.standardize()
pattern.shift_signals()
# pattern.perform_pauli_measurements() # <- Running this will break the rule of Toffoli gate?
pattern.minimize_space()
# draw with latex
from qiskit.quantum_info import Statevector
ket = pattern.simulate_pattern(backend='statevector').flatten()
ket = Statevector(ket)
ket.draw(output='latex')
@king-p3nguin thanks for your question - could you let us know the reference for this Toffoli decomposition? either way it's strange that the Pauli measurement preprocessing change the outcome of the computation; I will look into it and respond over the weekend.
Thank you for investigating! I used the Toffoli decomposition method implemented in qiskit.
from qiskit import QuantumCircuit
qc = QuantumCircuit(3)
qc.ccx(0, 1, 2)
qc.decompose(reps=1).draw()
@king-p3nguin please try again after incorporating (merge/rebase) 5a47704 to your forked repo.
Thank you for the bug fix! pattern.perform_pauli_measurements()
seems to be working correctly now.
Implement measurement pattern for Toffoli gate in
graphix.Circuit
class for transpilation. Please consider:Circuit.simulate_statevector()
runs with Toffoli gate.Circuit._rz_command_opt
and `_rzz_command_opt):Circuit._rz_command
), it is possible to implement a significantly shorter measurement pattern for a gate, with the cost of added local Clifford commands (seeCircuit._rz_command_opt
).tests/test_transpiler.py
see alsotests/test_pattern.py
) and make sure the pattern simulation results are as expected even after various forms of pattern optimizations (seetests/test_pattern.py
).Please see our contribution guide before starting, and do not forget to comment on this issue to show your interest. We are always happy to answer questions, so do not hesitate to ask on this page.
Thank you for your interest, and good luck!