workbench_algorithms.subroutines.compression_gadget
Implementation of the Compression Gadget (arxiv:2208.06941).
CompressionGadgetStrategy
Bases: Protocol
Interface for applying block-encodings in compression gadget.
apply_compression_gadget_block_encoding
apply_compression_gadget_block_encoding(
system_reg: Qubits,
be_anc: Qubits,
idx: int,
ctrl: Qubits | int = 0,
)
Method describing how to apply the block encodings.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
system_reg
|
Qubits
|
System qubits. |
required |
be_anc
|
Qubits
|
Block-encoding's ancillary qubits. |
required |
idx
|
int
|
Iteration of the compression gadget. |
required |
ctrl
|
Qubits | int
|
Control register. |
0
|
CompressionGadget
Bases: Qubrick
Compression gadget for block-encoding powers.
Given BE[H_i], applies a BE[Prod H_i] according to https://arxiv.org/pdf/2208.06941 Fig. 3.
Note
The block-encoding is successful in the subspace where counter == 0. The controlled version is such that the controlled unitary is applied accordingly when the block-encoding's ancillae qubits are in the zero state. However, the controlled-qubrick might still have an action in other subspace. This allows to reduce the cost of the implementation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
strategy
|
CompressionGadgetStrategy
|
block-encoding of the hamiltonian H |
required |
adder
|
Qubrick
|
Adder qubrick |
None
|
**kwargs
|
dict[str, Any]
|
Other arguments to pass to the init. |
{}
|
strategy
property
Set the strategy property so it can't be modified.
Returns:
| Type | Description |
|---|---|
CompressionGadgetStrategy
|
The Compression gadget strategy |
compute
Compute CompressionGadget.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
system_reg
|
Qubits
|
System qubits to apply to block-encodings. |
required |
be_anc
|
int
|
Block-encoding ancilla register. |
required |
idx_stop
|
int
|
Final index of the multiplication. |
required |
idx_start
|
int
|
Starting index of the multiplication. |
0
|
counter
|
Qubits
|
Counter register to perform the compression, if None will be allocated at compute. |
None
|
ctrl
|
(Qubits, int)
|
Control register. |
0
|