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 details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

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

Uploaded Python 3

File details

Details for the file dense_ev-2023.5.22.tar.gz.

File metadata

  • Download URL: dense_ev-2023.5.22.tar.gz
  • Upload date:
  • Size: 26.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.2

File hashes

Hashes for dense_ev-2023.5.22.tar.gz
Algorithm Hash digest
SHA256 e9602f486d841efa9ed5f821a35e92425f557f6dde004171516cdf2096924b08
MD5 605a4ff7ef15e5e9397faf3c3cf9f478
BLAKE2b-256 d191c4d70cca503acee786d07df08252536dba5991ea92fb2789f594d77b5da3

See more details on using hashes here.

File details

Details for the file dense_ev-2023.5.22-py3-none-any.whl.

File metadata

  • Download URL: dense_ev-2023.5.22-py3-none-any.whl
  • Upload date:
  • Size: 28.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.2

File hashes

Hashes for dense_ev-2023.5.22-py3-none-any.whl
Algorithm Hash digest
SHA256 63cf69a1ebf363b2b0e7d4fe2080cfc1d3ffcade65c95900d223f9d026092fe6
MD5 5dd2cee5ee469f18ab9b144ad6a42a7b
BLAKE2b-256 018925a9d8b463666f62ed0c329efab2948329d5a16a8c51added8a6b78408b7

See more details on using hashes here.

Supported by

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