Skip to content

Support specific IonQ targets (qpu.generation) #5141

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

Merged
merged 4 commits into from
Mar 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cirq-ionq/cirq_ionq/job.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ def results(
f'Job was not completed successfully. Instead had status: {self.status()}'
)
# IonQ returns results in little endian, Cirq prefers to use big endian, so we convert.
if self.target() == 'qpu':
if self.target().startswith('qpu'):
repetitions = self.repetitions()
counts = {
_little_endian_to_big(int(k), self.num_qubits()): int(repetitions * float(v))
Expand Down
14 changes: 14 additions & 0 deletions cirq-ionq/cirq_ionq/job_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,20 @@ def test_job_results_qpu_endianness():
assert results == ionq.QPUResult({0: 600, 2: 400}, 2, measurement_dict={})


def test_job_results_qpu_target_endianness():
job_dict = {
'id': 'my_id',
'status': 'completed',
'qubits': '2',
'target': 'qpu.target',
'metadata': {'shots': 1000},
'data': {'histogram': {'0': '0.6', '1': '0.4'}},
}
job = ionq.Job(None, job_dict)
results = job.results()
assert results == ionq.QPUResult({0: 600, 2: 400}, 2, measurement_dict={})


@mock.patch('time.sleep', return_value=None)
def test_job_results_poll(mock_sleep):
ready_job = {
Expand Down