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

[BUG] MultiBodyMeasure instruction generated instead of MeasurePatch instruction #322

Open
isolatedinformation opened this issue Dec 6, 2022 · 0 comments
Labels
bug Something isn't working

Comments

@isolatedinformation
Copy link
Contributor

Issue Description

When generating the instruction for Quantum Phase Estimation in 4 qubits, the instruction generator in some places generates a MultiBodyMeasure instruction, even when there is just one qubit. This causes an error when using the slicer later.

How to Reproduce

Here is the qasm instrcutions that was used to generate the instructions

OPENQASM 2.0;
include "qelib1.inc";
qreg q[4];
creg c[4];
creg meas[4];
rz(pi/2) q[3];

h q[3];

rz(pi/2) q[3];

h q[3];

rz(3*pi/4) q[3];

cx q[3],q[2];

rz(-pi/4) q[2];

cx q[3],q[2];

rz(3*pi/4) q[2];
rz(pi/8) q[3];

h q[2];
cx q[3],q[1];

rz(-pi/8) q[1];
rz(pi/2) q[2];

h q[2];
cx q[3],q[1];

rz(pi/8) q[1];
rz(3*pi/4) q[2];
rz(pi/16) q[3];

cx q[2],q[1];
cx q[3],q[0];

rz(-pi/16) q[0];
rz(-pi/4) q[1];

cx q[2],q[1];
cx q[3],q[0];

rz(pi/16) q[0];
rz(3*pi/4) q[1];
rz(pi/8) q[2];

h q[1];
cx q[2],q[0];

rz(-pi/8) q[0];
rz(pi/2) q[1];

h q[1];
cx q[2],q[0];

rz(pi/8) q[0];
rz(3*pi/4) q[1];

cx q[1],q[0];

rz(-pi/4) q[0];

cx q[1],q[0];

rz(3*pi/4) q[0];
cx q[1],q[2];

h q[0];
cx q[2],q[1];

rz(pi/2) q[0];
cx q[1],q[2];

h q[0];

rz(pi/2) q[0];

cx q[0],q[3];

cx q[3],q[0];

cx q[0],q[3];


measure q[0] -> meas[0];
measure q[1] -> meas[1];
measure q[2] -> meas[2];
measure q[3] -> meas[3];

Code Snippet

g = LSInstructionsFromGatesGenerator()
shorthand_writer = ShorthandFileWriter(sys.stdout)
for gate in circuit_of_gates.gates:
    instructions = g.gen_instructions(gate)
    lines += len(instructions)
    chars_full += sum([len(repr(s)) + 1 for s in instructions])
    for instruction in instructions:
        shorthand_writer.write_instruction(instruction)
        print(instruction)
    return shorthand_writer

Error Output

In line 15 and line 23, you will have the following instructions

(line15) 2 2:X
(line23) 2 3:Z
@isolatedinformation isolatedinformation added the bug Something isn't working label Dec 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant