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

CircuitResult compatible with simulation #125

Merged
merged 1 commit into from
Jul 13, 2022
Merged

Conversation

stavros11
Copy link
Member

Linked to qiboteam/qibo#618. Implements the following backend methods:

  • circuit_result_representation: Defines how a circuit result is printed. Currently just prints the readout dictionary as a string.
  • circuit_result_probabilities: Calculates output probabilities currently based on the naive voltage normalization from the main branch.

The following script now works in slurm:

import qibo
from qibo import gates, models

# Create circuit
c = models.Circuit(1)
c.add(gates.Y(0))
c.add(gates.M(0))

# Execute with numpy
qibo.set_backend("numpy")
for _ in range(5):
    result = c(nshots=1024)
    print(result)
    print(result.probabilities())

# Execute on hardware
from qibolab.paths import qibolab_folder
runcard = qibolab_folder / 'runcards' / 'qw5q.yml'
qibo.set_backend("qibolab", platform="tiiq", runcard=runcard)

for _ in range(5):
    result = c(nshots=1024)
    print(result)
    print(result.probabilities())

so there is symmetry between qibolab and simulation backends.

Similar implementations should be done for result.samples() and result.frequencies().

@scarrazza scarrazza merged commit ca1f33f into backendsequence Jul 13, 2022
@scarrazza scarrazza deleted the circuitresult branch August 17, 2022 07:20
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.

2 participants