workbench_algorithms.subroutines.batched_hamming_weight_phasing
Functions for batched Hamming weight phasing.
PowerOfTwoBatchedHammingWeightPhasing
PowerOfTwoBatchedHammingWeightPhasing(
hamming_weight_qubrick: Qubrick | None = None,
n_hwp_batches: int = 1,
rot_is_rz: bool = True,
use_black_box: bool = False,
**kwargs,
)
Bases: Qubrick
Implements Hamming weight phasing by splitting the target register into batches.
This Qubrick divides a large rotation tower into smaller batches, where the number of batches is a power of two. Each batch is processed with a smaller Hamming weight phasing circuit. This approach can significantly reduce the number of qubits and catalyst rotation requirements for large registers.
This is particularly useful for applications like Fermi-Hubbard simulation where the number of parallel Rz rotations is either L²/2 or L², where L is the lattice size.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
hamming_weight_qubrick
|
Qubrick | None
|
Qubrick for computing the Hamming weight for the Hamming weight phasing operation. If None, a default method using ComputeHammingWeightGroupOfThrees with GidneyAdd will be used. |
None
|
n_hwp_batches
|
int
|
Number of batches to split the rotations into. Must be a power of 2. Larger values reduce resource costs but may increase circuit depth. |
1
|
rot_is_rz
|
bool
|
Whether to use RZ rotations (True) or phase rotations (False). |
True
|
use_black_box
|
bool
|
Uses black box AV counts if set to True. Default is False. |
False
|
**kwargs
|
dict[str, Any]
|
Additional arguments to pass to the Qubrick constructor. |
{}
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If n_hwp_batches is not a power of 2. |
hamming_weight_qubrick
property
Returns the Hamming weight qubrick used for computation.
Returns:
| Type | Description |
|---|---|
Qubrick
|
The Hamming weight calculation Qubrick. |
compute
Computes the batched Hamming weight phasing operation.
This method splits the target register into batches, then applies a Hamming weight phasing operation to each batch separately. This approach can significantly reduce Toffoli gate counts and catalyst rotation requirements for large registers.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
rz_rotation_angle
|
float
|
Rotation angle (in degrees) for the phase operations. |
required |
target_register
|
Qubits
|
Register on which to apply the rotations. |
required |
ctrl
|
Qubits | int
|
Controls for the operation. Can be an integer bitmask or a Qubits register. Default is 0 (uncontrolled). |
0
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If the number of batches is greater than the number of qubits in the target register. |