Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update qcs-sdk-python version for libquil support, and document libquil usage #1698

Merged
merged 6 commits into from
Jan 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 49 additions & 0 deletions docs/source/advanced_usage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,55 @@ After doing so, for all intents and purposes - compilation, optimization, etc -
as when using "default" endpoint for a given quantum processor, except that it will be executed by an
alternate QCS service, and the results of execution should not be treated as correct or meaningful.

*******************************
Using libquil for Quilc and QVM
*******************************

.. note::
This feature is experimental and may not work for all platforms.

`libquil <https://github.com/rigetti/libquil>`_ provides the functionality of Quilc and QVM in a library
that can be used without having to run Quilc and QVM as servers, which can make developing with pyQuil
easier.

To use ``libquil``, first follow its `installation instructions <https://github.com/rigetti/libquil#libquil>`_.
Once ``libquil`` and its dependencies are installed, you will need to run the following command to install a compatible
version of ``qcs-sdk-python``:

.. code::

poetry run pip install --config-settings=build-args='--features libquil' qcs-sdk-python --force-reinstall --no-binary qcs-sdk-python

You can then check that ``libquil`` is available to pyQuil by executing the following Python code

.. code:: python

from pyquil.diagnostics import get_report
print(get_report())

Towards the end of the output, you will see a ``libquil`` section like below

.. code::

libquil:
available: true
quilc version: 1.27.0
qvm version: 1.17.2 (077ba23)

If you do not see ``available: true`` then re-try installation. If you continue to have issues, please report them
on `github <https://github.com/rigetti/pyquil/issues/new/choose>`_.

If installation was successful, you can now use libquil in pyQuil: the ``get_qc`` function provides two keyword parameters ``quilc_client`` and ``qvm_client`` which can be set to use ``libquil``:

.. code:: python

from pyquil import get_qc
from qcs_sdk.compiler.quilc import QuilcClient
from qcs_sdk.qvm import QVMClient

qc = get_qc("8q-qvm", quilc_client=QuilcClient.new_libquil(), qvm_client=QVMClient.new_libquil())

Please report issues on `github <https://github.com/rigetti/pyquil/issues/new/choose>`_.

************************
Using qubit placeholders
Expand Down
1 change: 1 addition & 0 deletions pyquil/api/_compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ def __init__(
quantum_processor=quantum_processor,
timeout=timeout,
client_configuration=client_configuration,
quilc_client=quilc_client,
)

self.api_options = api_options
Expand Down
2 changes: 1 addition & 1 deletion test/unit/test_operator_estimation.py
Original file line number Diff line number Diff line change
Expand Up @@ -1781,7 +1781,7 @@ def test_bit_flip_state_fidelity_readout_error(client_configuration: QCSClient,
estimated_fidelity = _point_state_fidelity_estimate(results)
# how close is the mixed state to |0>
expected_fidelity = 1 - prob
np.testing.assert_allclose(expected_fidelity, estimated_fidelity, atol=2e-2)
np.testing.assert_allclose(expected_fidelity, estimated_fidelity, atol=2.2e-2)


def test_dephasing_state_fidelity_readout_error(client_configuration: QCSClient, use_seed: bool):
Expand Down
Loading