0
$\begingroup$

Can we initialize two different arrays in two different qubits in a 2 qubit quantum circuit? I tried in IBMq but it showing error. So don't understand.

enter image description here

from qiskit import QuantumRegister, ClassicalRegister, QuantumCircuit num_of_qubits = 2 q1,q2 = QuantumRegister(1, 'q1'),QuantumRegister(1, 'q2') creg_c = ClassicalRegister(2, 'c') qc = QuantumCircuit(q1,q2,creg_c) qc.initialize(message_chunks,q1) qc.initialize(key_chunks,q2)

tried with this. but this error is showing.."'Desired statevector length not a positive power of 2.'" kindly help..

$\endgroup$
3
  • $\begingroup$ It should work. Can you add the error message to your question? $\endgroup$ Jun 21, 2023 at 16:32
  • $\begingroup$ I added the SS above. It is not running. Waited for a long time but no response. $\endgroup$
    – Arpita
    Jun 22, 2023 at 6:16
  • $\begingroup$ and after some time showing "The kernel for Untitled6.ipynb appears to have died. It will restart automatically." $\endgroup$
    – Arpita
    Jun 22, 2023 at 6:37

1 Answer 1

0
$\begingroup$

You code converts the content an image file into sequence of zeros and ones then for each bit inserts Initialize instruction in the quantum circuit. That means even for a small image you will insert thousands of Initialize instructions. Most probably this is the root cause of the issue. You can easily check this by limiting the number of Initialize instructions by replacing this line:

for x in range(len(message_chunks)):

by

for x in range(20):

Note: you insert all these instructions to the same qubit. Are you sure this is what you are trying to do? because Initialize resets the value of the qubit before adding the gates needed to prepare the state. So, it is seems pointless to add a sequence of Initialize instructions to the same qubit without any processing after each instruction.

$\endgroup$
3
  • $\begingroup$ i understand mam.. else how i do i insert the message chuck and key chuck in the qubits? by which method? $\endgroup$
    – Arpita
    Jun 22, 2023 at 10:00
  • $\begingroup$ I will use another operator after this and will measure it. but how to insert? $\endgroup$
    – Arpita
    Jun 22, 2023 at 11:33
  • $\begingroup$ I think you need to know more about how to represent and input data into a quantum computer. This link can be a good starting point. $\endgroup$ Jun 23, 2023 at 5:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.