cda-tum / mqt-qecc

MQT QECC - Tools for Quantum Error Correcting Codes
MIT License
92 stars 11 forks source link

Encoding not working correctly on noiseless simulation πŸ› #188

Closed clerusch closed 7 months ago

clerusch commented 7 months ago

Environment information

Description

The error corrected circuit has incorrect output when measuring Z on all data qubits. Therefore, the ECC protocol does not work.

Expected behavior

Correct encoding resulting in correct logical qubit when measuring data qubits

How to Reproduce

file = "./minimalbeispielsource.qasm" ecc = "Q7Steane" ecc_frequency = 10 qc = QuantumCircuit(1) qc.x(0) qc.qasm(filename=file) result = qecc.apply_ecc(file, ecc, ecc_frequency) circ = QuantumCircuit.from_qasm_str(result["circ"])

cr = ClassicalRegister(1,'my_reg')

measure encoded logical qubit by measuring logical Z = ZZZZZZZ

circ.add_register(cr) for i in range(7): circ.measure(circ.qubits[i],cr)

simulator = Aer.get_backend('qasm_simulator')

Transpile the circuit for the simulator

transpiled_circuit = transpile(circ, simulator)

Run the simulation

job = execute(transpiled_circuit, simulator, shots=1024, optimization_level=0) # You can adjust the number of shots as needed result = job.result()

Get the counts from the simulation results

counts = result.get_counts()

get the measurement outcomes

states = [k for k, _ in counts.items()]

get the logical measurement results for encoded qubit

res0, res1 = 0, 0 for state in states: if state[0] == '0': res0 += counts[state] elif state[0] == '1': res1 += counts[state] print(states) print(f"We got 0 {res0} times and 1 {res1} times")

burgholzer commented 7 months ago

Thanks for the report and the reproducer. That definitely looks like a bug. @33Gjl1Xe could you maybe take a look?

clerusch commented 7 months ago

I'm very sorry, this was user error, mqts measurement translation via apply_qecc works fine. Sorry for the inconvenience ^^"

burgholzer commented 7 months ago

Even better. No worries πŸ™‚