Skip to main content

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dense_ev-2023.5.22.tar.gz (26.1 kB view hashes)

Uploaded Source

Built Distribution

dense_ev-2023.5.22-py3-none-any.whl (28.1 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page