Qiskit expectation values using optimal dense grouping.
Project description
dense_ev
dense_ev implements expectation value measurements in Qiskit using optimal dense grouping arXiv:quant-ph/2305.xxxx. For an $m$-qubit operator that includes all Pauli strings in its decomposition, it provides a speedup of $2^m$ compared to naive evaluation of all strings, and $(3/2)^m$ compared to grouping based on qubit-wise commuting (QWC) families.
Installation
Create a virtual environment to sandbox the installation (optional):
python3 -m venv test-env && source ./test-env/bin/activate
To install,
pip install dense-ev
Install from GitHub:
pip install git+ssh://git@github.com/atlytle/dense-ev.git
To run unit tests,
from dense_ev.test_op import run_unit_tests
run_unit_tests()
Qiskit version compatibility
Note that dense_ev specifies qiskit < 0.43.0
, as the Opflow
and
QuantumInstance
packages have been deprecated as of Qiskit 0.43.0
.
We plan to update the code to function with the new primitives
as this
migration continues and more documentation becomes available.
Usage
Functionality for naive and QWC groupings is provided in Qiskit
by the PauliExpectation
class. DensePauliExpectation
extends the functionality
to dense optimal grouping, and may be used as a replacement for
PauliExpectation
:
from dense_EV import DensePauliExpectation
# Simple expectation values:
...
ev_spec = StateFn(H).compose(psi)
expectation = DensePauliExpectation().convert(ev_spec)
...
# VQE example
...
vqe = VQE(ansatz, optimizer=spsa, quantum_instance=qi,
callback=store_intermediate_result,
expectation=DensePauliExpectation())
result = vqe.compute_minimum_eigenvalue(operator=H)
...
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for dense_ev-2023.5.22-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 63cf69a1ebf363b2b0e7d4fe2080cfc1d3ffcade65c95900d223f9d026092fe6 |
|
MD5 | 5dd2cee5ee469f18ab9b144ad6a42a7b |
|
BLAKE2b-256 | 018925a9d8b463666f62ed0c329efab2948329d5a16a8c51added8a6b78408b7 |