qbraid.transpiler.cirq_braket package

Submodules

qbraid.transpiler.cirq_braket.convert_from_braket_qasm module

Module for converting Braket circuits to Cirq circuit via OpenQASM

from_braket(circuit)[source]

Returns a Cirq circuit equivalent to the input Braket circuit.

Note: The returned Cirq circuit acts on cirq.LineQubit’s with indices equal to the qubit indices of the Braket circuit.

Parameters

circuit (Circuit) – Braket circuit to convert to a Cirq circuit.

Raises

CircuitConversionError – if circuit could not be converted

Return type

Circuit

qbraid.transpiler.cirq_braket.convert_from_braket module

Module for converting Cirq circuits to Braket circuits

unitary_braket_instruction(instr)[source]

Converts a Braket instruction to a unitary gate instruction.

Parameters

instr (Instruction) – Braket instruction to convert.

Raises

CircuitConversionError – If the instruction cannot be converted

Return type

Instruction

from_braket(circuit)[source]

Returns a Cirq circuit equivalent to the input Braket circuit.

Note: The returned Cirq circuit acts on cirq.LineQubit’s with indices equal to the qubit indices of the Braket circuit.

Parameters

circuit (Circuit) – Braket circuit to convert to a Cirq circuit.

Return type

Circuit

qbraid.transpiler.cirq_braket.convert_to_braket module

Module for converting Braket circuits to Cirq circuits

to_braket(circuit)[source]

Returns a Braket circuit equivalent to the input Cirq circuit.

Parameters

circuit (Circuit) – Cirq circuit to convert to a Braket circuit.

Return type

Circuit

Returns

Braket circuit equivalent to the input Cirq circuit.

qbraid.transpiler.cirq_braket.custom_gates module

Module for Braket custom gates

class C(sub_gate, targets)[source]

Bases: Gate

Controlled gate :type sub_gate: Gate :param sub_gate: Quantum Gate. :type sub_gate: Gate :type targets: QubitSet :param targets: Target qubits. :type targets: QubitSet

Parameters
  • qubit_count (Optional[int]) – Number of qubits this gate interacts with.

  • ascii_symbols (Sequence[str]) – ASCII string symbols for the gate. These are used when printing a diagram of circuits. Length must be the same as qubit_count, and index ordering is expected to correlate with target ordering on the instruction. For instance, if CNOT instruction has the control qubit on the first index and target qubit on the second index. Then ASCII symbols would have [“C”, “X”] to correlate a symbol with that index.

Raises

ValueErrorqubit_count is less than 1, ascii_symbols are None, or ascii_symbols length != qubit_count

to_matrix(*args, **kwargs)[source]

Returns a matrix representation of the quantum operator

Returns

A matrix representation of the quantum operator

Return type

np.ndarray

adjoint()[source]

Returns a list of gates that implement the adjoint of this gate.

This is a list because some gates do not have an inverse defined by a single existing gate.

Returns

The gates comprising the adjoint of this gate.

Return type

List[Gate]

static c(targets, sub_gate)[source]

Registers this function into the circuit class. :type targets: QubitSet :param targets: Target qubits. :type targets: QubitSet :type sub_gate: Gate :param sub_gate: Quantum Gate. :type sub_gate: Gate

Returns

Controlled Gate Instruction.

Return type

Instruction