Skip to content

Unusual Memory Usage Patterns with 40 and 60 Qubits in ProjectQ #480

@saifawan2703

Description

@saifawan2703

#479 According to the response _(@damiansteiger),_ the memory issue is related to the number of qubits, with 40 qubits requiring 16TB of RAM. However, I have tested another circuit with 60 qubits and it runs successfully while using only 1GB of RAM. Below is the code for that:

from projectq import MainEngine
from projectq.ops import H, X, CNOT, Measure,Toffoli
from projectq.backends import CircuitDrawer, ResourceCounter, ClassicalSimulator

# Create a main compiler engine
Simulate = ClassicalSimulator()
eng = MainEngine(Simulate)

# Allocate a qubit register (60 qubits in this case)
qubits = eng.allocate_qureg(60)

# Put the second and third qubits in a simple entangled state
X | qubits[1]  
CNOT | (qubits[1], qubits[2])  
CNOT | (qubits[12], qubits[2]) 
CNOT | (qubits[3], qubits[2]) 
CNOT | (qubits[4], qubits[2]) 
CNOT | (qubits[5], qubits[2]) 
CNOT | (qubits[6], qubits[2]) 
Toffoli | (qubits[3], qubits[2], qubits[11])
Toffoli | (qubits[3], qubits[7], qubits[12])
Toffoli | (qubits[3], qubits[9], qubits[10])
Toffoli | (qubits[3], qubits[0], qubits[13])
CNOT | (qubits[2], qubits[3]) 
CNOT | (qubits[3], qubits[2]) 
CNOT | (qubits[4], qubits[2]) 
CNOT | (qubits[36], qubits[2]) 
Toffoli | (qubits[5], qubits[0], qubits[1])
Toffoli | (qubits[54], qubits[0], qubits[1])
CNOT | (qubits[10], qubits[2]) 
CNOT | (qubits[1], qubits[2]) 

# Measure all qubits
for qubit in qubits:
    Measure | qubit

# Execute the quantum circuit
eng.flush()

# Print the measurement results
print("Measured state:", [int(qubit) for qubit in qubits])

Is there is any issuse of simulator usage or any other?
I would greatly appreciate any insights or suggestions on how I might resolve this issue or better understand the underlying cause.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions