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

🐛 Circuits with discontiguous qubit registers are not properly exported since v2.7.0 #729

Open
burgholzer opened this issue Oct 15, 2024 · 0 comments · May be fixed by #763
Open

🐛 Circuits with discontiguous qubit registers are not properly exported since v2.7.0 #729

burgholzer opened this issue Oct 15, 2024 · 0 comments · May be fixed by #763
Labels
bug Something isn't working Core Anything related to the Core library and IR

Comments

@burgholzer
Copy link
Member

burgholzer commented Oct 15, 2024

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:

QuantumComputation qc(2);
qc.x(1);
qc.stripIdleQubits(true, true);

Options include:

// i 0 1
// o 1
OPENQASM 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 0
OPENQASM 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);

  const auto 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 1
OPENQASM 3.0;
include "stdgates.inc";
qubit[1] q;
x ;

which is obviously invalid.

@burgholzer burgholzer added bug Something isn't working Core Anything related to the Core library and IR labels Oct 15, 2024
@burgholzer burgholzer added this to MQT Core and MQT Oct 15, 2024
@github-project-automation github-project-automation bot moved this to In Progress in MQT Oct 15, 2024
@github-project-automation github-project-automation bot moved this to In Progress in MQT Core Oct 15, 2024
@burgholzer burgholzer linked a pull request Nov 27, 2024 that will close this issue
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Core Anything related to the Core library and IR
Projects
Status: In Progress
Status: In Progress
Development

Successfully merging a pull request may close this issue.

1 participant