Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle bits selection in results for circuits with non-default registers #407

Merged
merged 3 commits into from
Oct 25, 2024

Conversation

cqc-alec
Copy link
Collaborator

@cqc-alec cqc-alec commented Oct 25, 2024

Fixes #339 .

Also use PrimitiveResult for debug results instead of SamplerResult, to match real devices.

Tested locally by running:

from pytket.circuit import Circuit, Qubit, Bit
from pytket.extensions.qiskit import IBMQBackend

b = IBMQBackend("ibm_nazca")
c = Circuit(5)
c.add_c_register("a", 2)
c.add_c_register("b", 2)
c.add_c_register("c", 1)
c.H(0).CX(0, 1).Measure(Qubit(3), Bit("b", 1)).Measure(Qubit(0), Bit("c", 0))
c1 = b.get_compiled_circuit(c, optimisation_level=1)
h = b.process_circuit(c1, n_shots=10)
r = b.get_result(h)
print(r.get_counts(cbits=[Bit("b", 1), Bit("c", 0)]))

Output:

Counter({(0, 0): 6, (0, 1): 4})

@cqc-alec cqc-alec marked this pull request as ready for review October 25, 2024 10:08
@cqc-alec cqc-alec requested a review from cqc-melf as a code owner October 25, 2024 10:08
@cqc-alec cqc-alec merged commit 64da26f into main Oct 25, 2024
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

BackendResult from circuit with non-default classical register has incorrect c_bits
2 participants