Skip to content

Commit

Permalink
Support specific IonQ targets (qpu.generation) (quantumlib#5141)
Browse files Browse the repository at this point in the history
* Support specific IonQ targets

Allows for more specific backend targets.

* fmt
  • Loading branch information
Cynocracy authored and tonybruguier committed Apr 19, 2022
1 parent 137ddb6 commit 551acea
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
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

0 comments on commit 551acea

Please sign in to comment.