I'm implementing quantum edge detection, and to do so i need to get the counts after running in the real hardware. I am trying to run throught qiskit-ibm-runtime, but the result I obtain is in PrimitiveResult and I absolutely clueless how to get the counts from here. The problem arises because of the changes in the qiskit environment in 2025.
I'm trying to do so through qiskit-ibm-runtime and this:
with Session(backend=backend) as session: sampler = Sampler() job = sampler.run(circ_list_t) result = job.result() Problem is, I have no clue on how to get the counts I'm looking for, no method I tried, no AI can help me. I am not sure what more context I need but even my advisor is clueless. I've tried tons of methods from the classic .getcounts(), to a way more convoluted:
quasi_dist0 = result_circuit_0.data.meas quasi_dist1 = result_circuit_1.data.meas total_shots = quasi_dist0.num_shots def get_counts_from_quasi_dist(quasi_dist, total_shots): counts = {} for bitstring, prob in quasi_dist.items(): count = round(prob * total_shots) if count > 0: counts[bitstring] = count return counts