Cirq icon indicating copy to clipboard operation
Cirq copied to clipboard

QSimcirq does not implement measurement noise

Open bramathon opened this issue 1 year ago • 4 comments

When simulating circuits with the qsimcirq simulator, measurement confusion maps are ignored. If this is expected behaviour, I have no been able to find it in the documentation.

How to reproduce the issue

import numpy as np
import cirq
import qsimcirq

print("Cirq: " + cirq.__version__)
print("QSimCirq: " + qsimcirq.__version__)

qubit = cirq.LineQubit(0)

cmap = {(0,): np.array([[0.8, 0.2], [0.2, 0.8]])}

circuit = cirq.Circuit()
circuit += cirq.X(qubit)
circuit += cirq.MeasurementGate(1, confusion_map=cmap)(qubit)

print(circuit)

results = cirq.Simulator(seed=0).run(circuit, repetitions=100)
print("Cirq Simulator: " + str(results))


results = qsimcirq.QSimSimulator(seed=0).run(circuit, repetitions=100)
print("QSim Simulator: " + str(results))

Output:

Cirq: 1.2.0
QSimCirq: 0.16.3
0: ───X───?M('')───
Cirq Simulator: =1111111111111111111111111101111101111111111111011101010111101111110110100011111001111111111101111101
QSim Simulator: =1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111

Cirq version

Cirq: 1.2.0 QSimCirq: 0.16.3

bramathon avatar Sep 28 '23 15:09 bramathon

cirq cynque - let us add confusion_map support to QSimSimulator. Contributors welcome. :)

pavoljuhas avatar Oct 11 '23 17:10 pavoljuhas

I can take a look. Will sync with Angelo after doing some exploration.

nishitkshah avatar Oct 11 '23 17:10 nishitkshah

Created a draft version of code change for the fix: https://github.com/quantumlib/qsim/compare/master...nishitkshah:qsim:measurement_noise

Trying to figure out how to write unit tests for this.

nishitkshah avatar Nov 14 '23 12:11 nishitkshah

Haven't been able to give time to this. Will try to pick it up in the coming week.

nishitkshah avatar Dec 15 '23 17:12 nishitkshah