Hamiltonian 演化¶
oracq.algorithms.common.hamiltonian
Hamiltonian decomposition, Pauli evolution, Trotter and truncated Taylor encoding.
- oracq.algorithms.common.hamiltonian.trotter_hamsim(terms, final_time, *, steps=2)[源代码]¶
First-order Trotter product-formula simulation of the evolution under a Pauli-decomposed Hamiltonian.
For H = sum_j c_j P_j it synthesizes exp(-i*H*t) as the steps-th power of prod_j exp(-i*c_j*P_j*t/steps): each Pauli word is folded, through basis changes and a CNOT chain, into a phase rotation on the last active qubit and then restored in reverse order. The circuit body is a single Repeat(steps) block and is not expanded per step at generation or serialization time; an all-I word consumes no qubits and degenerates to a global phase.
- 参数:
terms -- Sequence of
(coefficient, Pauli word)pairs; the coefficients are real numbers, converted throughfloat, and the Pauli words are equal-width strings of I/X/Y/Z.final_time -- Total evolution time t.
steps -- Number of repeated steps, at least 1; more steps give a smaller product-formula error.
- 返回:
A bare unitary operation rather than a block encoding; the registers are target, of word width, and a zero-width signal, and the whole approximates exp(-i*H*t).
- 返回类型:
- 抛出:
ValidationError -- The term sequence is empty, steps is below 1, or the Pauli word widths differ.
- oracq.algorithms.common.hamiltonian.taylor_hamiltonian(hamiltonian, time, *, degree=2)[源代码]¶
A closable plain Hamiltonian-function block encoding; replaceable by a QSP/HamSim protocol.
- 参数:
hamiltonian -- Block encoding of the operator.
time -- Evolution time, a finite real number.
degree -- Taylor truncation order, an integer not less than 0; order 0 keeps only the identity term.
- 返回:
LCU block encoding of the truncated Taylor series, with correctness marked pending.
- 返回类型:
- class oracq.algorithms.common.hamiltonian.HermitianProtocol(*args, **kwargs)[源代码]¶
基类:
ProtocolAccess protocol by which the host declares the Hermiticity of an operator.
- property hermitian¶
Whether the operator is declared Hermitian; hamiltonian_simulation accepts only True.
- class oracq.algorithms.common.hamiltonian.EvolvableProtocol(*args, **kwargs)[源代码]¶
基类:
ProtocolAccess protocol by which the host declares that an operator can produce its own unitary evolution.
- evolution(time)[源代码]¶
Return the unitary Operation of this operator for the given evolution time.
The Trotter path requires the returned evolution to need no postselection: apart from target, all public registers are zero width.
- 参数:
time -- Evolution time, a finite real number.
- 返回:
The unitary evolution operation of this operator for the given duration.
- 返回类型:
- class oracq.algorithms.common.hamiltonian.TrotterizableProtocol(*args, **kwargs)[源代码]¶
基类:
ProtocolAccess protocol by which the host declares that an operator decomposes into a Trotter term list.
- trotter_list()[源代码]¶
Return the TrotterTerm sequence constituting the Hamiltonian; hamiltonian_simulation requires it to be nonempty.
- 返回:
The product-formula term sequence constituting the Hamiltonian, required to be nonempty.
- 返回类型:
Sequence[TrotterTerm]
- class oracq.algorithms.common.hamiltonian.TrotterTerm(coefficient, operator)[源代码]¶
基类:
objectA single Hamiltonian term of a product formula: a real coefficient combined with an evolvable operator.
- 变量:
coefficient (float) -- Real coefficient of the term; the Trotter path calls
operator.evolutionwith durationcoefficient * time / steps.operator (object) -- An operator satisfying EvolvableProtocol.
- 抛出:
ValidationError -- coefficient is not a finite real number, or operator does not satisfy EvolvableProtocol.
- coefficient¶
- operator¶
- class oracq.algorithms.common.hamiltonian.PauliOperator(word)[源代码]¶
基类:
objectA single Pauli word operator; satisfies HermitianProtocol and EvolvableProtocol.
- 变量:
word (str) -- A nonempty string of I/X/Y/Z with width at most 64.
hermitian -- Always True; this is the HermitianProtocol declaration.
- 抛出:
ValidationError -- word is not a nonempty I/X/Y/Z string, or its width exceeds 64.
- word¶
- hermitian = True¶
- class oracq.algorithms.common.hamiltonian.PauliHamiltonian(terms)[源代码]¶
基类:
objectA real-coefficient linear combination of equal-width Pauli words; supports both block-encoding and Trotter decomposition access.
- 变量:
terms (tuple[tuple[float, str], ...]) -- Tuple of
(coefficient, Pauli word)pairs; the coefficients are finite real numbers and all words have equal width.hermitian -- Always True; this is the HermitianProtocol declaration.
- 抛出:
ValidationError -- The term list is empty, a coefficient is not a finite real number, a Pauli word is invalid, or the widths differ.
- terms¶
- hermitian = True¶
- block_encoding()[源代码]¶
Return the LCU block encoding of the nonzero-coefficient terms; with no nonzero term it degenerates to the zero-operator block encoding.
- 返回:
LCU block encoding with scale equal to the sum of absolute coefficient values, or the zero operator with no nonzero term.
- 返回类型:
- trotter_list()[源代码]¶
Wrap each
(coefficient, word)into a TrotterTerm and return the tuple.- 返回:
Tuple of Trotter terms wrapping each coefficient and Pauli word one by one.
- 返回类型:
tuple[TrotterTerm, ...]
- class oracq.algorithms.common.hamiltonian.EncodedOperator(encoding, hermitian)[源代码]¶
基类:
objectHost declaration of matrix properties; may represent non-Hermitian operators and does not claim to itself be a unitary.
- encoding¶
- hermitian¶
- oracq.algorithms.common.hamiltonian.hamiltonian_simulation(operator, time, *, method='auto', steps=2, qsp=None)[源代码]¶
Currently prefers the decomposable Trotter path; QSP requires the caller to supply an actual implementation.
- 参数:
operator -- An operator declaring Hermitian, which must additionally satisfy the Trotter-decomposable or block-encodable protocol.
time -- Evolution time, a finite real number.
method -- Path selection, one of
auto,trotterorqsp;autopicks by the operator protocol.steps -- Number of repeated segments of the Trotter product formula, a positive integer.
qsp -- An actual implementation of the form qsp(BE, time) returning a BlockEncoding; needed only by the
qsppath.
- 返回:
Block encoding of the evolution exp(-iHt); the Trotter path has scale 1.0.
- 返回类型: