Closed tboen1 closed 3 years ago
Hi @tboen1 , thanks for reporting. Can you include the code you used to select a backend, run the circuits and fetch the results?
Thanks for the reply!
circuit_list = [circ, opt0, opt1, opt2, opt3]
device = 'ibmq_ourense'
shots = 8000
backend = qk.IBMQ.get_backend(device)
experiment = qk.execute(circuit_list, backend, shots=shots, optimization_level = 0)
result = experiment.result()
for i in range(len(circuit_list)):
print(result.get_counts(circuit_list[i]))
Hope this helps, the circuits specified in circuit_list
are shown in the original report
All of your circuits probably have the same name.
Try checking circ.name
, opt0.name
, etc.
You can fix this by changing the last line to:
print(result.get_counts(i))
We have to check in the results by name (it gets sent over wire and the QuantumCircuit instance may have been destroyed). The ability to look up by the circuit instance is merely a convenience. But I agree that this can be confusing, and the Result should warn you that multiple experiment results of same name are available.
Information
What is the current behavior?
The device appears to be returning the same results for different circuits. 5 separate circuits were ran, and the exact same results were returned each time:
Steps to reproduce the problem
A state vector was passed to the circuit initializer. The initializer was transpiled with varying optimization levels. When the optimized circuits were ran on the device, the exact same results were returned for each circuit. It seemed as if the device had simply run the first circuit once, and then duplicated the results again and again. It seems as if the other circuits were simply not run. An example is shown below:
init.initialize(state_vector, range(4))
circ = transpile(init, basis_gates = ['u3', 'cx']
opt0 = transpile(circ, backend=backend, seed_transpiler=11, optimization_level=0)
opt1 = transpile(circ, backend=backend, seed_transpiler=11, optimization_level=1)
opt2 = transpile(circ, backend=backend, seed_transpiler=11, optimization_level=2)
opt3 = transpile(circ, backend=backend, seed_transpiler=11, optimization_level=3)
What is the expected behavior?
It would be expected for the circuits transpiled with higher optimization levels to have better performance. However, at the very least, the randomness of the quantum hardware should guarantee that each circuit have different results.
It is evident that different circuits are in fact being passed into the device,
Suggested solutions
It may be that the device is cancelling redundant circuits.