LCU and qubitization¶
Download Notebook - lcu_qubitization.ipynb
Build a block encoding from a Pauli Hamiltonian, then check that two quantum-walk steps encode its second Chebyshev polynomial. This example uses unary-iteration SELECT with temporary-AND uncomputation.
Run this notebook from a source checkout with the development dependencies installed. The repository default is little endian.
1. Build PREPARE and SELECT¶
For the Hamiltonian
LCUData extracts the weights and Pauli terms. multiplexor_prep prepares amplitudes \(\sqrt{|a_j|/\lambda}\), while SELECT includes the coefficient signs. Together with inverse preparation, they give
Two preparation qubits address the four terms. Unary iteration uses one additional work qubit internally.
hamiltonian = zqp.RealTermSum.from_str(
"(0.4, Z0), (-0.2, X1), (0.3, Y0 Y1), (0.1, Z0 X1)",
2,
)
lcu_data = LCUData.from_hamiltonian(hamiltonian)
prepare = multiplexor_prep(lcu_data.amplitudes)
select = build_unary_iteration_select(
lcu_data,
comp_and_op=temp_and_compute,
uncomp_and_op=temp_and_uncompute,
)
dagger = object()
@guppy
@no_type_check
def unprepare(prep: array[qubit, 2]) -> None:
with dagger:
prepare(prep)
2. Apply two walk steps¶
Qubitization combines the LCU with the all-zero reflection:
For this Hermitian Pauli encoding, the projected second power is
The check reserves the internal work qubit and compares the unnormalized block with the classical polynomial, allowing an overall global phase.
power = 2
@guppy
@no_type_check
def qubitize(
prep: array[qubit, 2],
state: array[qubit, 2],
) -> None:
lcu = LCU(prepare, select, unprepare)
reflection = Reflection[2, 1](cnx)
Qubitization(lcu, reflection).power(prep, state, power)
projected_qubitization = get_unitary_projected(
qubitize,
lcu_data.n_state_qubits,
{"prep": [False] * lcu_data.n_prep_qubits},
n_extra_qubits=lcu_data.n_prep_qubits - 1,
endianness=Endianness.LITTLE,
)
normalized_hamiltonian = (
hamiltonian.to_sparse_matrix().toarray() / lcu_data.l1_norm
)
expected_chebyshev = chebyshev_power_matrix(normalized_hamiltonian, power)
assert_allclose_ignorephase(projected_qubitization, expected_chebyshev)