Skip to content

Support measuring into runtime-defined register indices #15986

@jakelishman

Description

@jakelishman

For QEC research purposes, there is a desire to be able to represent structures like

OPENQASM 3.0;
bit[1000] reps;
for uint i in [0:999] {
   reps[i] = measure $0;
}

This is not easily possible in Qiskit. There are a couple of concerns:

  • Our loop variables are currently Parameter and will need to be able to be Var instead (related: Add real-time Var support for ForLoopOp range #13729)
  • IBM hardware and the primitives interfaces are defined only in terms of returning values in classical registers, not arbitrary Vars
  • Qiskit's QuantumCircuit and DAGCircuit data structures are both defined in terms of individual, compile-time known references to individual qubits and clbits, meaning that the storage location of a Measure must be a clbit with an integer-literal index

There are ways around this, such as by instead rewriting the circuit as

OPENQASM 3.0;
bit tmp;
bit[1000] reps;
for uint i in [0:999] {
   tmp = measure $0;
   reps[i] = tmp;
}

This is representable in current Qiskit, but the potential trouble is that the number of reps might want to be very large (let's say order of 1 million, for sake of argument), and this would imply that the ForLoopOp in such a circuit will act on 1,000,001 classical bits and have that many incoming and outgoing wires.

We should investigate what the best way to do this and to represent such circuits is. We should take care that any solution we can propose will scale to 1million+ iterations.

Metadata

Metadata

Assignees

Type

No type

Projects

Status

Ready

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions