4
$\begingroup$

I am trying to run a Qiskit QAOA algorithm on AWS Rigetti Aspen M 1 Backend using qiskit braket provider. However qiskit is not able to properly transpile the circuit

optimizer = COBYLA(maxiter=50)
provider = AWSBraketProvider()
backend = QuantumInstance(
    provider.get_backend("Aspen-M-1"),
    shots=1024,
    seed_transpiler=algorithm_globals.random_seed,
    seed_simulator=algorithm_globals.random_seed,
)
qaoa = QAOA(
    reps=p,
    expectation=cvar_exp,
    optimizer=optimizer,
    quantum_instance=backend,
    callback=store_intermediate_result,
)
ckt=qaoa.construct_circuit([1.0,1.5],qubit_op)
ckt[0].draw()
transpiled_circuit = transpile(
    ckt[0], 
    backend=provider.get_backend("Aspen-M-1"), 
    #seed_transpiler=42
)
transpiled_circuit.draw(idle_wires=False, fold=-1)

leads to the following error:

This backend's operations: h,id,p,rx,ry,rz,s,sdg,t,tdg,x,y,z only apply to a subset of qubits. Using this property to get 'basis_gates' for the transpiler may potentially create invalid output
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-117-94170a3bccca> in <module>
     40 transpiled_circuit = transpile(
     41     ckt[0],
---> 42     backend=provider.get_backend("Aspen-M-1"),
     43     #seed_transpiler=42
     44 )

~/anaconda3/envs/Braket/lib/python3.7/site-packages/qiskit/compiler/transpiler.py in transpile(circuits, backend, basis_gates, inst_map, coupling_map, backend_properties, initial_layout, layout_method, routing_method, translation_method, scheduling_method, instruction_durations, dt, approximation_degree, timing_constraints, seed_transpiler, optimization_level, callback, output_name, unitary_synthesis_method, unitary_synthesis_plugin_config, target)
    302 
    303     # Transpile circuits in parallel
--> 304     circuits = parallel_map(_transpile_circuit, list(zip(circuits, transpile_args)))
    305 
    306     end_time = time()

~/anaconda3/envs/Braket/lib/python3.7/site-packages/qiskit/tools/parallel.py in parallel_map(task, values, task_args, task_kwargs, num_processes)
    127         return []
    128     if len(values) == 1:
--> 129         return [task(values[0], *task_args, **task_kwargs)]
    130 
    131     Publisher().publish("terra.parallel.start", len(values))

~/anaconda3/envs/Braket/lib/python3.7/site-packages/qiskit/compiler/transpiler.py in _transpile_circuit(circuit_config_tuple)
    388 
    389     result = pass_manager.run(
--> 390         circuit, callback=transpile_config["callback"], output_name=transpile_config["output_name"]
    391     )
    392 

~/anaconda3/envs/Braket/lib/python3.7/site-packages/qiskit/transpiler/passmanager.py in run(self, circuits, output_name, callback)
    220             return circuits
    221         if isinstance(circuits, QuantumCircuit):
--> 222             return self._run_single_circuit(circuits, output_name, callback)
    223         if len(circuits) == 1:
    224             return self._run_single_circuit(circuits[0], output_name, callback)

~/anaconda3/envs/Braket/lib/python3.7/site-packages/qiskit/transpiler/passmanager.py in _run_single_circuit(self, circuit, output_name, callback)
    275         """
    276         running_passmanager = self._create_running_passmanager()
--> 277         result = running_passmanager.run(circuit, output_name=output_name, callback=callback)
    278         self.property_set = running_passmanager.property_set
    279         return result

~/anaconda3/envs/Braket/lib/python3.7/site-packages/qiskit/transpiler/runningpassmanager.py in run(***failed resolving arguments***)
    122         for passset in self.working_list:
    123             for pass_ in passset:
--> 124                 dag = self._do_pass(pass_, dag, passset.options)
    125 
    126         circuit = dag_to_circuit(dag)

~/anaconda3/envs/Braket/lib/python3.7/site-packages/qiskit/transpiler/runningpassmanager.py in _do_pass(self, pass_, dag, options)
    155             # Run the pass itself, if not already run
    156             if pass_ not in self.valid_passes:
--> 157                 dag = self._run_this_pass(pass_, dag)
    158 
    159                 # update the valid_passes property

~/anaconda3/envs/Braket/lib/python3.7/site-packages/qiskit/transpiler/runningpassmanager.py in _run_this_pass(self, pass_, dag)
    209             # Measure time if we have a callback or logging set
    210             start_time = time()
--> 211             pass_.run(FencedDAGCircuit(dag))
    212             end_time = time()
    213             run_time = end_time - start_time

~/anaconda3/envs/Braket/lib/python3.7/site-packages/qiskit/transpiler/passes/utils/check_gate_direction.py in run(self, dag)
     44         """
     45         self.property_set["is_direction_mapped"] = True
---> 46         edges = self.coupling_map.get_edges()
     47         trivial_layout = Layout.generate_trivial_layout(*dag.qregs.values())
     48         if self.target is None:

AttributeError: 'NoneType' object has no attribute 'get_edges'

Similar error occurs when I try to directly get results by

result = qaoa.compute_minimum_eigenvalue(qubit_op)

The code works fine with other hardware, it seems only Rigetti has this problem.

$\endgroup$

1 Answer 1

0
$\begingroup$

Investigating a bit, this looks like it's due to the fact that the Rigetti device's operations aren't all global (there are certain qubits/pairs on which a gate may not be supported). As a result, Qiskit adds a gate direction check to the transpiler passes. However, the direction check relies on the coupling map, which isn't populated by the Qiskit-Braket provider. This looks like it's worth raising an issue for in the repo!

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.