0

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 
1
  • I have qiskit 1.4.2 and the solution posted here worked for me. Commented May 23 at 21:55

1 Answer 1

0

The following worked for me:

job.result()[0].data.meas.get_counts() 

Source: https://docs.quantum.ibm.com/guides/get-started-with-primitives

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.