qiskit-aer icon indicating copy to clipboard operation
qiskit-aer copied to clipboard

Supported number of qubits are not increasing with multiple nodes

Open intelligi123 opened this issue 1 year ago • 1 comments

Informations

  • 0.14.0:
  • Ubuntu 23.10:

What is the current behavior?

I have a qiskit code which qubits I need to increase, for that reason I am using multiple nodes in order to enhance RAM capacity. With one node, I am able to run circuit with 24 qubits having RAM (15G-CPU+5G-GPU). I have increased total resources by adding another node with same specs. I have now total of 40G memory (30G-CPU+10G-GPU) But still my code is not recognizing this increase in memory and generating below Error which is same as I run it with single process.

mpirun -np 2 -machinefile machinefile.txt python3 12.py
Traceback (most recent call last):
  File "/home/dell/12.py", line 44, in <module>
    job_sim = execute(qc,simulator_gpu,blocking_enable=True, blocking_qubits=block_qubits)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/dist-packages/qiskit/execute_function.py", line 286, in execute
    experiments = transpile(
                  ^^^^^^^^^^
  File "/usr/local/lib/python3.11/dist-packages/qiskit/compiler/transpiler.py", line 335, in transpile
    _check_circuits_coupling_map(circuits, coupling_map, backend)
  File "/usr/local/lib/python3.11/dist-packages/qiskit/compiler/transpiler.py", line 458, in _check_circuits_coupling_map
    raise TranspilerError(
qiskit.transpiler.exceptions.TranspilerError: 'Number of qubits (36) in circuit-158 is greater than maximum (29) in the coupling_map'
Traceback (most recent call last):
  File "/home/dell/12.py", line 44, in <module>
    job_sim = execute(qc,simulator_gpu,blocking_enable=True, blocking_qubits=block_qubits)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/dell/.local/lib/python3.11/site-packages/qiskit/execute_function.py", line 286, in execute
    experiments = transpile(
                  ^^^^^^^^^^
  File "/home/dell/.local/lib/python3.11/site-packages/qiskit/compiler/transpiler.py", line 335, in transpile
    _check_circuits_coupling_map(circuits, coupling_map, backend)
  File "/home/dell/.local/lib/python3.11/site-packages/qiskit/compiler/transpiler.py", line 458, in _check_circuits_coupling_map
    raise TranspilerError(
qiskit.transpiler.exceptions.TranspilerError: 'Number of qubits (36) in circuit-158 is greater than maximum (29) in the coupling_map'
--------------------------------------------------------------------------
Primary job  terminated normally, but 1 process returned
a non-zero exit code. Per user-direction, the job has been aborted.
--------------------------------------------------------------------------
--------------------------------------------------------------------------
mpirun detected that one or more processes exited with non-zero status, thus causing
the job to be terminated. The first process to do so was:

  Process name: [[38546,1],0]
  Exit code:    1

Here is my code


from qiskit import QuantumCircuit, QuantumRegister, ClassicalRegister, execute
from qiskit_aer import *

from qiskit_algorithms.utils import algorithm_globals
algorithm_globals.random_seed = 1

def Round_constant_XOR(circuit, source, target, length):
    for i in range(length):
        if (source >> i & 1):
            circuit.x(target[i])
  
def XOR_operator(circ,x,y,result,length):
    for i in range (int(length/2)):
        circ.cx(x[i],result[i])
        circ.cx(y[i],result[i])            
        
def Encryption(qc,a,b,res,length):
    XOR_operator(qc,a,b,res,length)

message = 0x276
key = 0x399
length = 12
ciphertext=""
plaintext = ""

plain_reg=QuantumRegister(length)
key_reg = QuantumRegister(length)
res_enc=QuantumRegister(length)
output=ClassicalRegister(length)

qc = QuantumCircuit(plain_reg , key_reg, res_enc,output)

Round_constant_XOR(qc,message,plain_reg,length)
Round_constant_XOR(qc,key,key_reg,length)

Encryption(qc,plain_reg,key_reg,res_enc,length)

qc.measure(res_enc, output) 

simulator_gpu = AerSimulator(method='statevector', device='GPU')

block_qubits = qc.num_qubits-5
job_sim = execute(qc,simulator_gpu,blocking_enable=True, blocking_qubits=block_qubits)
result_sim = job_sim.result()

print(result_sim.to_dict())
print(result_sim.get_counts())

Steps to reproduce the problem

Running code with mpirun -np 2 -quiet python3 code.py

What is the expected behavior?

It should run faster over multiple processes.

Suggested solutions

It works fine again when I decrease blocking_qubits


What is the expected behavior?

Qiskit should recognize that available resources are now increased and it can divide statevector onto two nodes.


What is the expected enhancement?

intelligi123 avatar Feb 13 '24 07:02 intelligi123

The statevector simulator requires 16*2^qubits bytes of memory, so you can run up to 30 qubits on 30GB of memory. If you want to add 1 qubit, you have to double the number of MPI nodes

doichanj avatar Mar 06 '24 08:03 doichanj