> ## Documentation Index
> Fetch the complete documentation index at: https://docs.haiqu.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Transpile

#### Haiqu.transpile(circuits, device, \*\*transpilation\_options)

Transpile a quantum circuit for a specific device.

* **Parameters:**
  * **circuits** (*QuantumCircuit* *|* *list* \*\[\**QuantumCircuit* *]*  *|* *CircuitModel* *|* *list* \*\[\**CircuitModel* *]*) -- The circuit(s) to transpile.
  * **device** (*DeviceModel*) -- The target device for execution.
  * **\*\*transpilation\_options** -- Additional arguments passed to the Qiskit transpiler. All parameters
    follow the Qiskit `transpile()` interface. A notable extension is `seed_transpiler`:
    it accepts either a single integer (standard Qiskit behaviour) or a list of integers.
    When a list is provided, transpilation is run once per seed in parallel and the result
    with the lowest multi-qubit gate count is selected for each circuit.
* **Returns:**
  The transpiled quantum circuit, logged to the current experiment.
  : When transpiling a circuit generated by Haiqu or containing Haiqu-generated components, the transpiled circuit
  will be returned in form of a single gate. The metrics will contain details of the transpilation.
  The returned `CircuitModel` will be linked to the original circuit.
* **Return type:**
  CircuitModel | list\[CircuitModel]

#### Examples

Haiqu SDK uses the Qiskit Transpiler for transpilation of your circuits.
Transpiling a circuit is as easy as follows:

```python theme={null}
>>> device = haiqu.get_device("fake_torino")
>>> transpiled_circuit = haiqu.transpile(circuit, device)
```

Every circuit stores the information about its transpiled versions, that can be viewed using:

```python theme={null}
>>> haiqu.list_transpiled_circuits(circuit)
```

It may sometimes be useful to compare the circuits resulting from transpilation with different parameters.

```python theme={null}
>>> transpiled_circuit_opt0 = haiqu.transpile(circuit, device, optimization_level=0)
>>> transpiled_circuit_opt3 = haiqu.transpile(circuit, device, optimization_level=3)
>>> haiqu.compare_metrics(transpiled_circuit_opt0, transpiled_circuit_opt3)
```

Pass a list of seeds to run multiple transpilations and automatically keep the best result
(fewest two-qubit gates) for each circuit:

```python theme={null}
>>> transpiled_circuit = haiqu.transpile(circuit, device, seed_transpiler=[0, 1, 2, 3, 4])
```
