Skip to content

Commit fe7fe4e

Browse files
authored
Support specific IonQ targets (qpu.generation) (#5141)
* Support specific IonQ targets Allows for more specific backend targets. * fmt
1 parent 9fd5af1 commit fe7fe4e

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

cirq-ionq/cirq_ionq/job.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ def results(
206206
f'Job was not completed successfully. Instead had status: {self.status()}'
207207
)
208208
# IonQ returns results in little endian, Cirq prefers to use big endian, so we convert.
209-
if self.target() == 'qpu':
209+
if self.target().startswith('qpu'):
210210
repetitions = self.repetitions()
211211
counts = {
212212
_little_endian_to_big(int(k), self.num_qubits()): int(repetitions * float(v))

cirq-ionq/cirq_ionq/job_test.py

+14
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,20 @@ def test_job_results_qpu_endianness():
101101
assert results == ionq.QPUResult({0: 600, 2: 400}, 2, measurement_dict={})
102102

103103

104+
def test_job_results_qpu_target_endianness():
105+
job_dict = {
106+
'id': 'my_id',
107+
'status': 'completed',
108+
'qubits': '2',
109+
'target': 'qpu.target',
110+
'metadata': {'shots': 1000},
111+
'data': {'histogram': {'0': '0.6', '1': '0.4'}},
112+
}
113+
job = ionq.Job(None, job_dict)
114+
results = job.results()
115+
assert results == ionq.QPUResult({0: 600, 2: 400}, 2, measurement_dict={})
116+
117+
104118
@mock.patch('time.sleep', return_value=None)
105119
def test_job_results_poll(mock_sleep):
106120
ready_job = {

0 commit comments

Comments
 (0)