This repository was archived by the owner on Jan 12, 2024. It is now read-only.
This repository was archived by the owner on Jan 12, 2024. It is now read-only.
Table lookup #601
Open
Description
Proposal title
Conceptual overview
We propose to add a function for a table lookup routine, as the current idiomatic implementation requires deep knowledge of the API or will be challenging to implement.
Current status
Right now, table lookups require finding MultiplexOperations
and ApplyPauliFromBitString
within the API.
User feedback
N/A
Child issues
N/A
Proposal
New and modified functions, operations, and UDTs
namespace Microsoft.Quantum.Canon
/// # Summary
/// Performs a table lookup operation
///
/// # Description
/// A table lookup uses an address to return classical data from quantum registers
/// See more details on table lookup in Craig Gidney's paper https://arxiv.org/abs/1905.07682
///
/// # Input
/// ## data
/// The classical bit data that represents the table
/// ## address
/// The address used to lookup from the table
/// ## target
/// Qubits in which the result of the lookup will be stored
operation TableLookup(data : Bool[][], address : LittleEndian, target : Qubit[]) : Unit is Adj + Ctl
Modifications to style guide
N/A
Impact of breaking changes
N/A
Examples
Current status
Currently the best implementation we came up with is to implement a table lookup is as follows:
let ApplyXFromBitString = ApplyPauliFromBitString(PauliX, true, _, _); // Applies X conditionally based on bitstring
let unitaries = Mapped(bitstring -> ApplyXFromBitString(bitstring, _), data); // Create unitaries based on data
MultiplexOperations(unitaries, address, target); // Multiplex over address onto target
Using proposed changes
As this is a wrapper function it would involve a call to the wrapper
Relationship to Q# language feature proposals
N/A
Alternatives considered
We considered not including it since table lookups are a niche usecase, however we suggest they are used enough to provide the convenience function.
Open design questions and considerations
N/A