You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When a circuit is stripped of idle qubits in the middle of its range of qubits, the resulting circuit cannot be exported properly because it accesses out-of-bounds memory.
Before #690, this was mitigated by modifying the circuit before dumping and explicitly adding back missing qubits. This behaviour has been dropped as it was deemed unintuitive that a circuit dumping method would alter the circuit itself.
Expected behavior
It should be possible to dump circuits that had some of their qubits stripped without modifying the circuits themselves.
It is not 100% clear, what the following code should produce:
// i 0 1// o 1OPENQASM 3.0;
include"stdgates.inc";
qubit q[2];
x q[1];
This is how the code worked before v2.7.0, but this required modifying the circuit by adding back the respective qubit before exporting. One could argue that a circuit that has been stripped of its idle qubits should not contain them anymore. The benefit here is that the gates do not need to be touched.
// i 0// o 0OPENQASM 3.0;
include"stdgates.inc";
qubit q[1];
x q;
This method would require the layouts as well as all operations to be updated. On the plus side, it would only require a modification in the function that strips the idle qubits and no updates in the method that dumps the circuits.
How to Reproduce
QuantumComputation qc(2);
qc.x(1);
qc.stripIdleQubits(true, true);
constauto expected = "// i 1\n""// o 1\n""OPENQASM 3.0;\n""include \"stdgates.inc\";\n""qubit q[1];\n""x q;\n";
EXPECT_EQ(qc.toQASM(), expected);
Or any of the other expected alternatives.
Currently, this yields
// I 1// o 1OPENQASM 3.0;
include"stdgates.inc";
qubit[1] q;
x ;
which is obviously invalid.
The text was updated successfully, but these errors were encountered:
Environment information
Description
When a circuit is stripped of idle qubits in the middle of its range of qubits, the resulting circuit cannot be exported properly because it accesses out-of-bounds memory.
Before #690, this was mitigated by modifying the circuit before dumping and explicitly adding back missing qubits. This behaviour has been dropped as it was deemed unintuitive that a circuit dumping method would alter the circuit itself.
Expected behavior
It should be possible to dump circuits that had some of their qubits stripped without modifying the circuits themselves.
It is not 100% clear, what the following code should produce:
Options include:
This is how the code worked before v2.7.0, but this required modifying the circuit by adding back the respective qubit before exporting. One could argue that a circuit that has been stripped of its idle qubits should not contain them anymore. The benefit here is that the gates do not need to be touched.
This method would require the layouts as well as all operations to be updated. On the plus side, it would only require a modification in the function that strips the idle qubits and no updates in the method that dumps the circuits.
How to Reproduce
Or any of the other expected alternatives.
Currently, this yields
which is obviously invalid.
The text was updated successfully, but these errors were encountered: