You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Dec 7, 2021. It is now read-only.
The following code is part of a quantum walk algorithm in a two-dimensional space. We analyze the oracle that tells with what probabilities steps are accepted and determine there is an error in the output of the oracle.
Some comments:
Several other examples (other bitmaps) have been tested and the error happens only when we specify the coordinates with at least 5 bits, not for less.
We initialize the circuit in a position where the oracle should always output 1, the position (26,5).
The correct or incorrect behavior can be assessed from the printout of the following code, after the Check of the algorithm!!! call. Correct behavior will happen when the last qubit (the output of the oracle) is always in state 1, whereas incorrect behavior happens when there is some non-negligible amplitude for the output of the oracle in state 0. The current output of the oracle circuit (when initialized to a state that should always output 1) is
Check of the algorithm!!!
1101000101001 (0.5-9.06544793068824e-14j)
1101000101010 (0.5-6.172219867702362e-14j)
1101000101101 (0.5-1.243934986233914e-13j)
1101000101110 (0.4999999999999999-6.17221986770236e-14j)
Steps to reproduce the problem
Define the bitmap of the oracle (unfortunately, this error only seems to happen for quite large oracles, so I cannot give a smaller version).
We can check that the output at the positions starting by '1101000101' (26,5 is the minimum energy state) is 1using
print(string.count('1'))
print(len(string))
# We have to that in the target positions we should be getting a 1
for i in range(len(string)):
n = np.binary_repr(i, width = int(np.log2(len(string))))
if n[:10] == '1101000101':
print(n, string[i])
We can try to see if we can actually get the output, which will be in register ancilla. We first create the circuit
coord_1 = QuantumRegister(5)
coord_2 = QuantumRegister(5)
move_id = QuantumRegister(1)
move_value = QuantumRegister(1)
ancilla = QuantumRegister(1)
# We order the registers from least to most significant, so that the output of qiskit is from most to least significant is correct:
qc = QuantumCircuit(ancilla,move_value,move_id,coord_2,coord_1)
# encoding the value of (26,5) = 11010 00101
qc.x(coord_1[1])
qc.x(coord_1[3])
qc.x(coord_1[4])
qc.x(coord_2[0])
qc.x(coord_2[2])
# We set the two final registers in a superposition to be able to see what happens in all possibilities
qc.h(move_id)
qc.h(move_value)
Then we create the oracle
# Construct an instruction for the oracle
oracle = TruthTableOracle(string, mct_mode='noancilla')
oracle.construct_circuit()
oracle_circuit = oracle.circuit
print()
oracle_gate = oracle_circuit.to_instruction()
qc.append(oracle_gate, [move_value[0]]+[move_id[0]]
+ [coord_2[j] for j in range(5)]
+ [coord_1[j] for j in range(5)]
+ [ancilla[0]])
And finally, we execute the circuit
experiment = execute(qc,backend=Aer.get_backend('statevector_simulator'))
state_vector = Statevector(experiment.result().get_statevector(qc))
state_vec = state_vector.data
print('Check of the algorithm!!!')
for i in range(len(state_vec)):
if abs(state_vec[i])>1e-7:
print(np.binary_repr(i, width = 13),state_vec[i])
Which outputs
Check of the algorithm!!!
1101000101001 (0.5-9.06544793068824e-14j)
1101000101010 (0.5-6.172219867702362e-14j)
1101000101101 (0.5-1.243934986233914e-13j)
1101000101110 (0.4999999999999999-6.17221986770236e-14j)
We can see that the ancilla (the least significant register) is not always in state 1, which represents a logic failure.
What is the expected behavior?
Something similar to
Check of the algorithm!!!
1101000101001 (0.5-9.06544793068824e-14j)
1101000101011 (0.5-6.172219867702362e-14j)
1101000101101 (0.5-1.243934986233914e-13j)
1101000101111 (0.4999999999999999-6.17221986770236e-14j)
where all the non-zero amplitudes correspond to bitstrings ending in 1.
Suggested solutions
It is unclear to me what could be failing in the logic of the oracle, so I cannot really say.
The text was updated successfully, but these errors were encountered:
PabloAMC
changed the title
TruthTableOracle producing incorrect behaviour for large oracles in some quantum walks
TruthTableOracle producing incorrect logic for large oracles in some quantum walks
Nov 30, 2020
PabloAMC
changed the title
TruthTableOracle producing incorrect logic for large oracles in some quantum walks
TruthTableOracle producing incorrect logic for large oracles in some quantum walks [Please ignore it for the moment while I run additional checks]
Dec 1, 2020
PabloAMC
changed the title
TruthTableOracle producing incorrect logic for large oracles in some quantum walks [Please ignore it for the moment while I run additional checks]
TruthTableOracle producing incorrect logic for large oracles in some quantum walks
Dec 1, 2020
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Information
What is the current behavior?
The following code is part of a quantum walk algorithm in a two-dimensional space. We analyze the oracle that tells with what probabilities steps are accepted and determine there is an error in the output of the oracle.
Some comments:
1
, the position (26,5).The correct or incorrect behavior can be assessed from the printout of the following code, after the
Check of the algorithm!!!
call. Correct behavior will happen when the last qubit (the output of the oracle) is always in state1
, whereas incorrect behavior happens when there is some non-negligible amplitude for the output of the oracle in state0
. The current output of the oracle circuit (when initialized to a state that should always output1
) isSteps to reproduce the problem
Define the bitmap of the oracle (unfortunately, this error only seems to happen for quite large oracles, so I cannot give a smaller version).
We can check that the output at the positions starting by
'1101000101'
(26,5 is the minimum energy state) is1
usingwhich will output
We can try to see if we can actually get the output, which will be in register
ancilla
. We first create the circuitThen we create the oracle
And finally, we execute the circuit
Which outputs
We can see that the ancilla (the least significant register) is not always in state
1
, which represents a logic failure.What is the expected behavior?
Something similar to
where all the non-zero amplitudes correspond to bitstrings ending in
1
.Suggested solutions
It is unclear to me what could be failing in the logic of the oracle, so I cannot really say.
The text was updated successfully, but these errors were encountered: