diff --git a/docs/source/advanced_usage.rst b/docs/source/advanced_usage.rst index 59a0436fc..937671607 100644 --- a/docs/source/advanced_usage.rst +++ b/docs/source/advanced_usage.rst @@ -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 `_ 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 `_. +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 `_. + +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 `_. ************************ Using qubit placeholders diff --git a/pyquil/api/_compiler.py b/pyquil/api/_compiler.py index 9dc3cf109..759806e1f 100644 --- a/pyquil/api/_compiler.py +++ b/pyquil/api/_compiler.py @@ -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 diff --git a/test/unit/test_operator_estimation.py b/test/unit/test_operator_estimation.py index b1fadf336..f4b9e8c53 100644 --- a/test/unit/test_operator_estimation.py +++ b/test/unit/test_operator_estimation.py @@ -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):