amazon-braket-algorithm-library
  • braket.experimental.algorithms.grovers_search.grovers_search module
    • grovers_search()
    • build_oracle()
    • amplify()
    • ccnot_decomposed()
    • multi_control_not_constructor()
    • multi_control_not()
    • multi_control_z()
amazon-braket-algorithm-library
  • braket.experimental.algorithms.grovers_search.grovers_search module
  • View page source

braket.experimental.algorithms.grovers_search.grovers_search module

braket.experimental.algorithms.grovers_search.grovers_search.grovers_search(oracle: Circuit, n_qubits: int, n_reps: int = 1, decompose_ccnot: bool = False) → Circuit[source]

Generate Grover’s circuit for a target solution and oracle.

Parameters:
  • oracle (Circuit) – Oracle circuit for a solution.

  • n_qubits (int) – Number of data qubits.

  • n_reps (int) – Number of repititions for amplification. Defaults to 1.

  • decompose_ccnot (bool) – To decompose CCNOT (Toffoli) gate in the circuit.

Returns:

Circuit – Grover’s circuit

braket.experimental.algorithms.grovers_search.grovers_search.build_oracle(solution: str, decompose_ccnot: bool = False) → Circuit[source]

Oracle circuit of a given solution.

Parameters:
  • solution (str) – Target solution (e.g., ‘010’)

  • decompose_ccnot (bool) – Whether to decompose CCNOT (Toffoli) gate in the circuit.

Returns:

Circuit – Oracle circuit

braket.experimental.algorithms.grovers_search.grovers_search.amplify(n_qubits: int, decompose_ccnot: bool) → Circuit[source]

Perform a single iteration of amplitude amplification.

Parameters:
  • n_qubits (int) – Number of data qubits.

  • decompose_ccnot (bool) – Whether to decompose CCNOT (Toffoli) gate in the circuit.

Returns:

Circuit – Amplification circuit.

braket.experimental.algorithms.grovers_search.grovers_search.ccnot_decomposed(control_1: int, control_2: int, target: int) → Circuit[source]

Build CCNOT (Toffoli gate) from H, CNOT, T, Ti.

Parameters:
  • control_1 (int) – control qubit 1 of CCNot gate

  • control_2 (int) – control qubit 2 of CCNot gate

  • target (int) – target qubit of CCNot gate

Returns:

Circuit – CCNot circuit.

braket.experimental.algorithms.grovers_search.grovers_search.multi_control_not_constructor(n_qubit: int, decompose_ccnot: bool, is_outermost_call: bool = True) → Tuple[Circuit, int][source]

Recursive constructor of a multi-contol Not circuit (generalized Toffoli gate). Ref: https://arxiv.org/abs/1904.01671

Parameters:
  • n_qubit (int) – Number of qubits.

  • decompose_ccnot (bool) – To decompose CCNOT (Toffoli) gate in the circuit.

  • is_outermost_call (bool) – Whether the call is the outermost call from external functions.

Returns:

Tuple[Circuit, int] – the multi-contol Not circuit and the number of ancilla in the circuit

braket.experimental.algorithms.grovers_search.grovers_search.multi_control_not(n_qubit: int, decompose_ccnot: bool) → Circuit[source]

Multi-control Not circuit.

Parameters:
  • n_qubit (int) – Number of qubits.

  • decompose_ccnot (bool) – To decompose CCNOT (Toffoli) gate in the circuit.

Returns:

Circuit – multi-contol Not circuit

braket.experimental.algorithms.grovers_search.grovers_search.multi_control_z(n_qubit: int, decompose_ccnot: bool) → Circuit[source]

Multi-control Z circuit.

Parameters:
  • n_qubit (int) – Number of qubits.

  • decompose_ccnot (bool) – To decompose CCNOT (Toffoli) gate in the circuit.

Returns:

Circuit – multi-contol Z circuit


© Copyright 2026, Amazon.com.

Built with Sphinx using a theme provided by Read the Docs.