Skip to content

workbench_algorithms.subroutines.hamming_weight_phasing

Functions for hamming weight phasing.

HammingWeightPhasing

HammingWeightPhasing(
    angle,
    rot_is_rz: bool = False,
    hamming_weight_qubrick=None,
    use_catalyst_state: bool = False,
    catalyst_state_reg=None,
    use_padding: bool = False,
    use_black_box: bool = False,
    **kwargs,
)

Bases: Qubrick

Implement a stack of rotations of the same angle using hamming weight phasing.

Parameters:

Name Type Description Default
angle float | RotationAngle

An angle specifying the angle of the rotations

required
rot_is_rz bool

Flag to determine if attempting to perform Rz rotations or phase gates

False
hamming_weight_qubrick Qubrick

A Qubrick that computes the hamming weight of a register

None
use_catalyst_state bool

A flag to determine if the Phasing circuit should be used to implement the growingtower of rotations.

False
catalyst_state_reg Qubits

The catalyst state for the PhaseC circuit

None
use_padding bool

A flag to determine if the Hamming Weight register should be padded with clean ancilla so that the size is consistent with the size of the catalyst state. If it is not padded, then a single phase gate needs to be applied during the PhaseC circuit. If it is padded, then the rotations should be completely decomposed via Toffolis when adding onto the catalyst state assuming the catalyst state is large enough to implement the angle passed in exactly. If the catalyst state is not large enough based on the precision of the angle, I believe a rotation is still required.

False
use_black_box bool

Uses black box AV counts if set to True. Default is False.

False
**kwargs dict[str, Any]

Additonal Qubrick kwargs

{}

angle property writable

angle

Angle specifying the angle of the rotations.

compute

compute(target_register: Qubits, ctrl: Qubits | int = 0)

Implement a stack of rotations using Hamming weight phasing.

Parameters:

Name Type Description Default
target_register Qubits

The register on which to apply the rotations

required
ctrl int or Qubits

The quantum control conditions.

0

PhasingCircuit

PhasingCircuit(
    base_angle,
    rot_is_rz: bool = False,
    use_black_box: bool = False,
    **kwargs,
)

Bases: Qubrick

Implement the phasing circuit.

Notes
  • See under section "Additional basis rotations."

Parameters:

Name Type Description Default
base_angle float | RotationAngle

An angle specifying the base angle of the growing tower of rotations

required
rot_is_rz bool

Flag to determine if attempting to perform Rz rotations or phase gates

False
use_black_box bool

Uses black box AV counts if set to True. Default is False.

False
**kwargs dict[str, Any]

Additonal Qubrick kwargs

{}

base_angle property writable

base_angle

Angle specifying the base angle of the growing tower of rotations.

compute

compute(
    target_reg: Qubits,
    catalyst_reg: Qubits,
    ctrl: Qubits | int = 0,
    final_qubits: Qubits | int = 0,
)

Use the phasing circuit to implement a tower of growing rotations.

Parameters:

Name Type Description Default
target_reg Qubits

The state to implement the rotations upon

required
catalyst_reg Qubits

The catalyst state to use which is specific to the base angle being implemented

required
ctrl int or Qubits

Classical or Quantum control conditions

0
final_qubits Qubits

If passed in, these are the three qubits on which we just perform Z, S, and T directly instead of adding on to the catalyst state.

0
Notes
  • The implemented circuit applies rotations of base_angle(2*i) for the i'th qubit of the target_reg where i runs from 0 to len(target_reg) - 1.

compute_subblock

compute_subblock(top, mid, bottom)

Compute half-adder-like block.