Closed DanPuzzuoli closed 1 year ago
I am interested to know how classical registers map onto the results as well.
One thing that might be helpful to clarify for someone coming this: generally when working with QuantumCircuit
you don't consider any mapping to pulse MemorySlot
s, but DynamicsBackend
is converting the circuit to a schedule for simulation, so the register to memory slot correspondence is coming in that step.
This conversions happens in transpilation, so DynamicsBackend
impacts this process only as far as the backend is configured.
I'm starting to lean towards just dropping the num_memory_slots
determination from QuantumCircuit
s and applying the dynamic determination of this for Schedule
s to this case as well.
That sounds reasonable -- might as well be consistent for all input types since they are all getting converted to schedule any way. I think summing the sizes of all the cregs might also be good. It seems odd to go off the size of only the first one here:
Also, note that the conversion from circuit to schedule happens in that build_schedule
call which is separate from transpilation.
This example in this issue https://github.com/Qiskit-Extensions/qiskit-experiments/issues/1235 contains an error resulting from
DynamicsBackend
miscounting the number of classical registers in a circuit/schedule.DynamicsBackend
counts the number of classical registers in a circuit viaThe above error occurs as the
cregs
is of the formSo,
DynamicsBackend
miscounts the number as1
but it should be2
. This is obviously an easy fix, changing the count toThe only thing I'm worried about here is that I don't know how these
ClassicalRegister
lists are handled and would like to confirm. What I'm guessing is the case is:sum(creg size for creg in circ.cregs)
. (I guess implicit in this is the assumption that the classical registers correspond toMemorySlot
s?)cregs[0]
are indexed0, ..., len(cregs[0])-1
, the bits incregs[1]
are indexedlen(cregs[0]), ..., len(cregs[0]) + len(cregs[1]) - 1
, etc.