Qiskit / qiskit-aer

Aer is a high performance simulator for quantum circuits that includes noise models
https://qiskit.github.io/qiskit-aer/
Apache License 2.0
497 stars 361 forks source link

Unavailability of Probabilities in result after successfull simulation #2183

Open Suraj1409 opened 4 months ago

Suraj1409 commented 4 months ago

Informations

Qiskit = 1.0.2 Qiskit-aer = 0.14.1 Qiskit-aer-gpu = 0.14.1

What is the current behavior?

I have Nvidia A100 GPU with 80GB memory, and I am trying to simulate 33 qubit circuit (statevector simulation) with single precision which will take around 64 GB memory, but when I run the circuit it didnt produce probabilities in the result, but the status of simulation is completed and time taken is 0.0025 sec

Need a guide for it

chrisamirani commented 4 months ago

Hey @Suraj1409 Are you able to share your code here? If not everything, at least the part where you define your circuit and where you run the backend

Suraj1409 commented 4 months ago

from qiskit import * from qiskit_aer import Aer, AerSimulator import numpy as np from qiskit.circuit.library import MCXGate

number_of_qubit = 33 target = [2]

def single_oracle(qc, q): qc.barrier(q) n = len(q) qc.h(q[n - 1]) qc.append(MCXGate(n - 1), q) qc.h(q[n - 1]) qc.barrier(q)

def diffusion_operator(qc, q): qc.barrier(q) n = len(q) qc.h(q) qc.x(q) qc.h(q[n - 1]) qc.append(MCXGate(n - 1), q) qc.h(q[n - 1]) qc.barrier(q) qc.x(q) qc.h(q) qc.barrier(q)

def grover(qc, q, target): n = len(q) n_iterator = int(round((np.pi / 4)*np.sqrt(2**n / len(target)) - 0.5))

print(n_iterator)

for i in range(0, n_iterator):
    for t in target:
        temp = t
        for i in range(0, n):
            if (temp % 2) == 0:
                qc.x(q[i])
            temp = int(temp / 2)
        single_oracle(qc, q)
        temp = t
        for i in range(0, n):
            if (temp % 2) == 0:
                qc.x(q[i])
            temp = int(temp / 2)
        qc.barrier(q)
    diffusion_operator(qc, q)

q = QuantumRegister(number_of_qubit) c = ClassicalRegister(number_of_qubit) qc = QuantumCircuit(q, c) qc.h(q) grover(qc, q, target) qc.measure(q, c)

backend = Aer.get_backend('aer_simulator_statevector_gpu') backend.set_options(precision='single')

job_cu = backend.run(qc, shots=3000,cuStateVec_enable=True)

result_cu = job_cu.result()

print("CuStateVec Output : ") print(result_cu.status) print(result_cu.time_taken)

chrisamirani commented 4 months ago

Thx @Suraj1409 so when you run job_cu.result().get_counts() you get nothing? You should be able to get the probabilities with that.

Suraj1409 commented 4 months ago

Nothing gets print, even i tried to print job_cu.result() all parameters get printed but not probabilities