braket.experimental.algorithms.qc_qmc.qc_qmc module

braket.experimental.algorithms.qc_qmc.qc_qmc.qc_qmc(num_walkers: int, num_steps: int, dtau: float, quantum_evaluations_every_n_steps: int, trial: ndarray, prop: ChemicalProperties, trial_state_circuit: Callable, dev: Device, max_pool: int = 8) Tuple[List[float], List[float]][source]

Quantum assisted Auxiliary-Field Quantum Monte Carlo.

Parameters:
  • num_walkers (int) – Number of walkers.

  • num_steps (int) – Number of (imaginary) time steps

  • dtau (float) – Increment of each time step

  • quantum_evaluations_every_n_steps (int) – How often to evaluate the energy using quantum

  • trial (ndarray) – Trial wavefunction.

  • prop (ChemicalProperties) – Chemical properties.

  • trial_state_circuit (Callable) – quantum trial state as a pennylane quantum function

  • dev (qml.devices.Device) – Pennylane device to run circuits on.

  • max_pool (int) – Max workers. Defaults to 8.

Returns:

Tuple[List[float], List[float]] – quantum and classical energies

braket.experimental.algorithms.qc_qmc.qc_qmc.q_full_imag_time_evolution_wrapper(args: Tuple) Callable[source]
braket.experimental.algorithms.qc_qmc.qc_qmc.q_full_imag_time_evolution(num_steps: int, quantum_evaluations_every_n_steps: int, dtau: float, trial: ndarray, prop: ChemicalProperties, e_shift: float, walker: ndarray, weight: float, trial_state_circuit: Callable, dev: Device) Tuple[List[float], List[float], List[float], List[float]][source]

Imaginary time evolution of a single walker.

Parameters:
  • num_steps (int) – number of time steps

  • quantum_evaluations_every_n_steps (int) – between how many steps to do a quantum evaluation

  • dtau (float) – imaginary time step size

  • trial (ndarray) – trial state as np.ndarray, e.g., for h2 HartreeFock state, it is np.array([[1,0], [0,1], [0,0], [0,0]])

  • prop (ChemicalProperties) – Chemical properties.

  • e_shift (float) – Reference energy, i.e. Hartree-Fock energy

  • walker (ndarray) – normalized walker state as np.ndarray, others are the same as trial

  • weight (float) – weight for sampling.

  • trial_state_circuit (Callable) – quantum trial state

  • dev (qml.devices.Device) – qml.device('lightning.qubit', wires=wires) for simulator; or qml.device('braket.aws.qubit', device_arn=device_arn, wires=wires, shots=shots) for quantum device;

Returns:

Tuple[List[float],List[float],List[float],List[float]] – energy_list, weights, qs, cs

braket.experimental.algorithms.qc_qmc.qc_qmc.imag_time_propogator_qaee(dtau: float, trial: ndarray, walker: ndarray, weight: float, prop: ChemicalProperties, e_shift: float, trial_state_circuit: Callable, dev: Device) Tuple[float, float, float, ndarray, float][source]

Imaginary time propogator with quantum energy evaluations.

Parameters:
  • dtau (float) – imaginary time step size

  • trial (ndarray) – trial state as np.ndarray, e.g., for h2 HartreeFock state, it is np.array([[1,0], [0,1], [0,0], [0,0]])

  • walker (ndarray) – normalized walker state as np.ndarray, others are the same as trial

  • weight (float) – weight for sampling.

  • prop (ChemicalProperties) – Chemical properties.

  • e_shift (float) – Reference energy, i.e. Hartree-Fock energy

  • trial_state_circuit (Callable) – quantum trial state

  • dev (qml.devices.Device) – Pennylane device

Returns:

Tuple[float, float, float, ndarray, float] – propogatpr results e_loc: local energy e_loc_q / c_ovlp: numerator q_ovlp / c_ovlp: denominator for evaluation of total energy new_walker: new walker for the next time step new_weight: new weight for the next time step

braket.experimental.algorithms.qc_qmc.qc_qmc.local_energy_quantum(walker: ndarray, ovlp: float, one_body: ndarray, lambda_l: ndarray, u_l: ndarray, trial_state_circuit: Callable, dev: device) complex[source]

This function estimates the integral \($\\langle \\Psi_Q|H|\\phi_l\rangle$\) with rotated basis.

Parameters:
  • walker (ndarray) – np.ndarray; matrix representation of the walker state, not necessarily orthonormalized.

  • ovlp (float) – amplitude between walker and the quantum trial state

  • one_body (ndarray) – (corrected) one-body term in the second quantized hamiltonian written in chemist’s notation. This term is assumed to be diagonal in the current implementation, but should be rather straight forward to generalize if it’s not.

  • lambda_l (ndarray) – eigenvalues of Cholesky vectors

  • u_l (ndarray) – eigenvectors of Cholesky vectors

  • trial_state_circuit (Callable) – quantum trial state

  • dev (qml.device) – qml.device('lightning.qubit', wires=wires) for simulator; or qml.device('braket.aws.qubit', device_arn=device_arn, wires=wires, shots=shots) for quantum device;

Returns:

complex – energy

braket.experimental.algorithms.qc_qmc.qc_qmc.givens_block_circuit(givens: Tuple) None[source]

This function defines the Givens rotation circuit from a single givens tuple.

Parameters:

givens (Tuple) – (i, j, theta, varphi)

braket.experimental.algorithms.qc_qmc.qc_qmc.prepare_slater_circuit(circuit_description: List[Tuple]) None[source]

Creating Givens rotation circuit to prepare arbitrary Slater determinant.

Parameters:

circuit_description (List[Tuple]) – list of tuples containing Givens rotation (i, j, theta, phi) in reversed order.

braket.experimental.algorithms.qc_qmc.qc_qmc.circuit_first_half(q_state: ndarray) None[source]

Construct the first half of the vacuum reference circuit.

Parameters:

q_state (ndarray) – orthonormalized walker state

braket.experimental.algorithms.qc_qmc.qc_qmc.circuit_second_half_real(q_state: ndarray, trial_state_circuit: Callable) None[source]

Construct the second half of the vacuum reference circuit (for real expectation values)

Parameters:
  • q_state (ndarray) – orthonormalized walker state

  • trial_state_circuit (Callable) – quantum trial state

braket.experimental.algorithms.qc_qmc.qc_qmc.circuit_second_half_imag(q_state: ndarray, trial_state_circuit: Callable) None[source]

Construct the second half of the vacuum reference circuit (for imaginary expectation values) :param q_state: orthonormalized walker state :type q_state: ndarray :param trial_state_circuit: quantum trial state :type trial_state_circuit: Callable

braket.experimental.algorithms.qc_qmc.qc_qmc.amplitude_real(q_state: ndarray, trial_state_circuit: Callable) None[source]

Construct the the vacuum reference circuit for measuring amplitude real part :param q_state: orthonormalized walker state :type q_state: ndarray :param trial_state_circuit: quantum trial state :type trial_state_circuit: Callable

braket.experimental.algorithms.qc_qmc.qc_qmc.amplitude_imag(q_state: ndarray, trial_state_circuit: Callable) None[source]

Construct the the vacuum reference circuit for measuring amplitude imaginary part :param q_state: orthonormalized walker state :type q_state: ndarray :param trial_state_circuit: quantum trial state :type trial_state_circuit: Callable

braket.experimental.algorithms.qc_qmc.qc_qmc.amplitude_estimate(q_state: ndarray, trial_state_circuit: Callable, dev: device) complex128[source]

This function computes the amplitude between walker state and quantum trial state.

Parameters:
  • q_state (ndarray) – orthonormalized walker state

  • trial_state_circuit (Callable) – quantum trial state

  • dev (qml.device) – qml.device('lightning.qubit', wires=wires) for simulator; or qml.device('braket.aws.qubit', device_arn=device_arn, wires=wires, shots=shots) for quantum device;

Returns:

complex128 – amplitude

braket.experimental.algorithms.qc_qmc.qc_qmc.u_circuit(u_matrix: ndarray) None[source]

Construct circuit to perform unitary transformation U.

Parameters:

u_matrix (ndarray) – unitary

braket.experimental.algorithms.qc_qmc.qc_qmc.pauli_real(q_state: ndarray, trial_state_circuit: Callable, u_matrix: ndarray, pauli: List[int]) Callable[source]
Construct the the vacuum reference circuit for measuring expectation value

of a pauli real part

Parameters:
  • q_state (ndarray) – orthonormalized walker state

  • trial_state_circuit (Callable) – quantum trial state

  • u_matrix (ndarray) – unitary transformation to change the Pauli into Z basis

  • pauli (List[int]) – list that stores the position of the Z gate, e.g., [0,1] represents ‘ZZII’.

Returns:

Callable – pennylane circuit

braket.experimental.algorithms.qc_qmc.qc_qmc.pauli_imag(q_state: ndarray, trial_state_circuit: Callable, u_matrix: ndarray, pauli: List[int]) Callable[source]
Construct the the vacuum reference circuit for measuring expectation value

of a pauli imaginary part

Parameters:
  • q_state (ndarray) – orthonormalized walker state

  • trial_state_circuit (Callable) – quantum trial state

  • u_matrix (ndarray) – unitary transformation to change the Pauli into Z basis

  • pauli (List[int]) – list that stores the position of the Z gate, e.g., [0,1] represents ‘ZZII’.

Returns:

Callable – pennylane circuit

braket.experimental.algorithms.qc_qmc.qc_qmc.pauli_estimate(q_state: ndarray, trial_state_circuit: Callable, u_matrix: ndarray, pauli: List[int], dev: device) float[source]

This function returns the expectation value of $langle Psi_q_state|pauli|phi_l angle$. :param q_state: np.ndarray; matrix representation of the walker state, not necessarily

orthonormalized.

Parameters:
  • trial_state_circuit (Callable) – circuit unitary to prepare the quantum trial state

  • u_matrix (ndarray) – eigenvector of Cholesky vectors, $L = U lambda U^{dagger}$

  • pauli (List[int]) – list of 0 and 1 as the representation of a Pauli string, e.g., [0,1] represents ‘ZZII’.

  • dev (qml.device) – qml.device('lightning.qubit', wires=wires) for simulator; or qml.device('braket.aws.qubit', device_arn=device_arn, wires=wires, shots=shots) for quantum device;

Returns:

float – expectation value