paddle_quantum.gate.custom

The source file of the oracle class and the control oracle class.

class paddle_quantum.gate.custom.Oracle(oracle, qubits_idx=None, num_qubits=None, depth=1, gate_info=None)

Bases: Gate

An oracle as a gate.

Parameters:
  • oracle (Tensor) – Unitary oracle to be implemented.

  • qubits_idx (Iterable[Iterable[int]] | Iterable[int] | int) – Indices of the qubits on which the gates are applied.

  • num_qubits (int) – Total number of qubits. Defaults to None.

  • depth (int) – Number of layers. Defaults to 1.

class paddle_quantum.gate.custom.ControlOracle(oracle, qubits_idx, num_qubits=None, depth=1, gate_info=None)

Bases: Gate

A controlled oracle as a gate.

Parameters:
  • oracle (Tensor) – Unitary oracle to be implemented.

  • qubits_idx (Iterable[Iterable[int]] | Iterable[int]) – Indices of the qubits on which the gates are applied.

  • num_qubits (int) – Total number of qubits. Defaults to None.

  • depth (int) – Number of layers. Defaults to 1.

class paddle_quantum.gate.custom.ParamOracle(generator, param=None, depth=1, num_acted_param=1, param_sharing=False, qubits_idx=None, gate_info=None, num_qubits=None)

Bases: ParamGate

An parameterized oracle as a gate

Parameters:
  • generator (Callable[[Tensor], Tensor]) – function that generates the oracle.

  • param (Tensor | float | List[float]) – input parameters of quantum parameterized gates. Defaults to None i.e. randomized.

  • qubits_idx (Iterable[Iterable[int]] | Iterable[int] | int) – indices of the qubits on which this gate acts on. Defaults to None i.e. list(range(num_qubits)).

  • depth (int) – number of layers. Defaults to 1.

  • num_acted_param (int) – the number of parameters required for a single operation.

  • param_sharing (bool) – whether all operations are shared by the same parameter set.

  • gate_info (dict) – information of this gate that will be placed into the gate history or plotted by a Circuit.

  • None. (Defaults to) –

  • num_qubits (int) – total number of qubits. Defaults to None.