azure-quantum-python icon indicating copy to clipboard operation
azure-quantum-python copied to clipboard

endianness of classical registers

Open qci-amos opened this issue 3 years ago • 0 comments

If I execute a circuit that looks like this in Azure Quantum:

2022-08-01 09:15:28,499 - INFO - __main__ - ================== Running circuit endian0cr3:
2022-08-01 09:15:28,499 - INFO - __main__ -
      ┌───┐┌─┐
q3_0: ┤ X ├┤M├
      └───┘└╥┘
q3_1: ──────╫─
            ║
q3_2: ──────╫─
            ║
c3: 3/══════╩═
            0

c4: 3/════════

c5: 3/════════

created like this:

        pos = 0
        qr = QuantumRegister(3)
        cr = [ClassicalRegister(3) for _ in range(3)]
        qc = QuantumCircuit(qr, *cr, name=f"endian{pos}cr3")
        qc.x(pos)
        qc.measure(qr[pos], cr[pos][pos])

Which I then execute against both qci.simulator and qasm_simulator to compare.

When running on azure-quantum[qiskit] version 0.25.222597, I get the result:

{'[0, 0, 1], [0, 0, 0], [0, 0, 0]': 100}

while on qasm_simulator I get:

{'000 000 001': 10000}

That is, the ordering within each classical register matches, but the ordering of the classical registers themselves are reversed.

Is this a bug or is this just a difference in conventions?

Also, as an aside, it's worth pointing out that I have my own code to convert conventions from "tuple of lists" to a "space separated bits". In this code, I simply reverse the order I traverse tuples in order to get results I can compare with hellinger_fidelity.

qci-amos avatar Aug 01 '22 13:08 qci-amos