Getting memory information from Qiskit Runtime service- Sampler

41 Views Asked by At

I'm working on a QRNG program where I need to get the memory information properly. But having made changes to the IBM qiskit packages, it seems there is no option to get the memory from the sampler. How do I solve this issue?

I tried giving 'memory=True' inside the backend initialization and sampler run. But that is not available now.

1

There are 1 best solutions below

0
davidryan On

Open to learning other methods but the approach I use to get memory information is via the Qiskit Runtime API. Assuming it's installed and you've got the libraries. Initialize the session first.

session = QiskitRuntimeSession()

Use the session.get_memory_info() method to retrieve memory information about the quantum circuit.

memory_info = session.get_memory_info()

The memory_info object contains the information about memory usage of the quantum circuit, including the total memory usage, the number of qubits, and the number of quantum gates.

print("Memory usage:", memory_info.total_memory_usage)
print("Number of qubits:", memory_info.num_qubits)
print("Number of quantum gates:", memory_info.num_quantum_gates)

This will print the memory information to the console.