1
$\begingroup$

I am a newbie to quantum and have been trying qiskit library for learning quantum computing (in order to explore quantum effects on cryptography). I am basically trying to build Grover Oracle for different symmetric key algorithms. For this I am learning various operations mostly performed by these algos in classical counterparts like XOR, Bit Shift, Addition and Modulo operations etc.

I have created a 4 bit circuit for Full Adder in qiskit and extended it to 8 qbits. But when I am trying it for 12 bits, it raises above error

Simulation failed and returned the following error message:
ERROR:  [Experiment 0] Insufficient memory to run circuit circuit-584 using the statevector simulator. Required memory: 67108864M, max memory: 32712M
QiskitError: 'Data for experiment "circuit-584" could not be found.'

I have written a simple quantum implementation of Full Adder and this Error arises when I try to measure the result.

length=12

a = QuantumRegister(length)
b = QuantumRegister(length)
s = QuantumRegister(length)
aux = QuantumRegister(length)

cout = QuantumRegister(1)
cin = QuantumRegister(1)


result = ClassicalRegister(length+1)

input1 = 0xa82
input2 = 0x905

circ=QuantumCircuit(a,b,cin,s,cout,result,aux)

Round_constant_XOR(circ,input1,a,length) # Copying input1 to a
Round_constant_XOR(circ,input2,b,length) # Copying input2 to b 

full_adder(circ,a,b,cin,length,s,cout)

#circ.draw(output='mpl')
print("Operations Completed, now measuring qbits\n")
for i in range(length):
    circ.measure(s[i],result[i])
circ.measure(cout,result[length])

simulator1 = AerSimulator(method='statevector')
results1 = execute(circ,backend=simulator1).result()
print("Result is: " + str(results1.get_counts(circ)))
plot_histogram(results1.get_counts(circ))

Complete Error is

---------------------------------------------------------------------------
QiskitError                               Traceback (most recent call last)
C:\PROGRA~1\KMSpico\temp/ipykernel_12724/2309521244.py in <module>
     31 simulator1 = AerSimulator(method='statevector')
     32 results1 = execute(circ,backend=simulator1).result()
---> 33 print("Result is: " + str(results1.get_counts(circ)))
     34 plot_histogram(results1.get_counts(circ))

~\anaconda3\lib\site-packages\qiskit\result\result.py in get_counts(self, experiment)
    267         dict_list = []
    268         for key in exp_keys:
--> 269             exp = self._get_experiment(key)
    270             try:
    271                 header = exp.header.to_dict()

~\anaconda3\lib\site-packages\qiskit\result\result.py in _get_experiment(self, key)
    378 
    379             if len(exp) == 0:
--> 380                 raise QiskitError('Data for experiment "%s" could not be found.' % key)
    381             if len(exp) == 1:
    382                 exp = exp[0]

Does the problem lie in number of qbits simulator is able to handle or anything else. As I eventually want to perform different operations for at least 128 qbits registers in order to simulate practical symmetric algos.

$\endgroup$
2
  • $\begingroup$ The code that really matters is the one used to create your circuit. How many qubits does it use? Note that in all cases, you won't be able to simulate 128-qubit wide circuits: this would require working with $2^{128}\times2^{128}$ matrices (assuming you work with non-separable states, which is likely if you implement cryptography algorithms), this would just not fit in your computer's memory. $\endgroup$
    – Tristan Nemoz
    Sep 13, 2022 at 7:06
  • $\begingroup$ I have added the code, the overall qbits in circuit are 50. I have downloaded and run some projectq codes on my system which have used plaintext and key of 128 qbits and they worked fine. $\endgroup$
    – aneela
    Sep 13, 2022 at 7:12

1 Answer 1

1
$\begingroup$

I changed the simulator provided by IBM according to my current need (qbits=50)

simulator1 = AerSimulator(method='matrix_product_state')

It worked.

$\endgroup$

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.