Closed JRGit4UE closed 2 months ago
Hi, I think there are two missunderstandings here:
print(b)
will call get_measurement
again but with the default simulator and 100 000 shots. If you want to see the result returned from the Qiskit backend, please use
print(b.get_measurement(backend=VirtualQiskitBackend(qiskit_backend), shots=1))
The get_measurement
method has no influence on the compiled circuit - instead it allows you to probe the state at that point. If you want to compile a measurement use c = measure(b)
. This will give you a list of classical bits. Ok, now it's clear - thank you. @1.) Although I would have expected that randomness is inherently in every qubit I measure...
If you feel like it, you can also simulate noise :) For that use the noisy qiskit backends
from qrisp import QuantumArray, QuantumFloat, gidney_adder, cx, h
import qiskit_aer as Aer # v1.1.1
from qiskit_ibm_runtime.fake_provider import FakeWashington
from qrisp.interface import VirtualQiskitBackend
a = QuantumFloat(3)
b = QuantumFloat(3)
a[:] = 1
b[:] = 2
print(a) # {1: 1.0}
print(b) # {2: 1.0}
b += a
qiskit_backend = FakeWashington()
print(b.get_measurement(backend=VirtualQiskitBackend(qiskit_backend), shots=10))
# {3: 0.4, 7: 0.3, 5: 0.2, 2: 0.1}
On my Qrisp 0.4.10 when I test adding numbers, it is unclear to me how to handle the number of shots in simulation, as the result of the adder seems to always be correct, no matter if
shots=1
orshots=100000
.Example