qml.io.bloq_registers

bloq_registers(bloq)[source]

Reads a Qualtran Bloq signature and returns a dictionary mapping the Bloq’s register names to Wires.

Note

This function requires the latest version of Qualtran. We recommend installing the main branch via pip:

pip install qualtran

The keys of the returned dictionary are the register names in the Qualtran Bloq. The values are Wires objects with a length equal to the bitsize of its respective register. The wires are indexed in ascending order, starting from 0.

This function makes it easy to access the wires that a Bloq acts on and use them to precisely control how gates connect.

Parameters

bloq (Bloq) – an initialized Qualtran Bloq to be wrapped as a PennyLane operator

Returns

A dictionary mapping the names of the Bloq’s registers to Wires

objects with the same lengths as the bitsizes of their respective registers.

Return type

dict

Raises

TypeError – bloq must be an instance of Bloq.

Example

This example shows how to find the estimation wires of a textbook Quantum Phase Estimation Bloq.

>>> from qualtran.bloqs.phase_estimation import RectangularWindowState, TextbookQPE
>>> from qualtran.bloqs.basic_gates import ZPowGate
>>> textbook_qpe_small = TextbookQPE(ZPowGate(exponent=2 * 0.234), RectangularWindowState(3))
>>> qml.bloq_registers(textbook_qpe_small)
{'q': Wires([0]), 'qpe_reg': Wires([1, 2, 3])}