Package: pytket-iqm
pytket-iqmPytketis a python module
providing an extensive set of tools for compiling and executing quantum circuits.pytket-iqmis an extension topytketthat allowspytketcircuits to be
executed onIQM's quantum devices and simulators.Getting startedpytket-iqmis available for Python 3.10, 3.11 and 3.12, on Linux, macOS
and Windows. To install, run:pipinstallpytket-iqmThis will installpytketif it isn't already installed, and add new classes
and methods into thepytket.extensionsnamespace.API documentation is availablehere.Under the hood,pytket-iqmusesiqm-clientto interact with the devices. See
the IQM Clientdocumentationand
Pytketdocumentationfor more info.To use the integration, initialise anIQMBackend, construct a Pytket circuit,
compile it and run. Here is a small example of running a GHZ state circuit:frompytket.extensions.iqmimportIQMBackendfrompytket.circuitimportCircuitbackend=IQMBackend(url="https://demo.qc.iqm.fi/cocos",auth_server_url="https://demo.qc.iqm.fi/auth",username="USERNAME",password="PASSWORD",)circuit=Circuit(3,3)circuit.H(0)circuit.CX(0,1)circuit.CX(0,2)circuit.measure_all()compiled_circuit=backend.get_compiled_circuit(circuit)result=backend.run_circuit(compiled_circuit,n_shots=100)print(result.get_shots())The IQM Client documentation includes the [set of currently supported
instructions]
(https://iqm-finland.github.io/iqm-client/api/iqm_client.iqm_client.html).pytket-iqmretrieves the set from the IQM backend during the initialisation;
thenget_compiled_circuit()takes care of compiling the circuit into the
form suitable to run on the backend.During the backend initialisation,pytket-iqmalso retrieves the names of
physical qubits and qubit connectivity. You can override the qubit connectivity
by providing thearchparameter to theIQMBackendconstructor, but it generally
does not make sense, since the IQM server reports the valid quantum architecture
relevant to the given backend URL.(Note: At the moment IQM does not provide a quantum computing service open to the
general public. Please contact oursales teamto set up your access to an IQM quantum computer.)Bugs and feature requestsPlease file bugs and feature requests on the GitHubissue tracker.DevelopmentTo install an extension in editable mode, simply change to its subdirectory
within themodulesdirectory, and run:pipinstall-e.ContributingPull requests are welcome. To make a PR, first fork the repo, make your proposed
changes on thedevelopbranch, and open a PR from your fork. If it passes
tests and is accepted after review, it will be merged in.Code styleFormattingAll code should be formatted usingblack, with default options. This is
checked on the CI.Type annotationOn the CI,mypyis used as a static
type checker and all submissions must pass its checks. You should therefore runmypylocally on any changed files before submitting a PR. Because of the way
extension modules embed themselves into thepytketnamespace this is a little
complicated, but it should be sufficient to run the scriptmodules/mypy-check(passing as a single argument the root directory of the module to test). The
script requiresmypy0.800 or above.LintingWe usepylinton the CI to check compliance
with a set of style requirements (listed in.pylintrc). You should runpylintover any changed files before submitting a PR, to catch any issues.TestsTo run the tests:cdtests
pipinstall-rtest-requirements.txt
pytestBy default, the remote tests, which run against the real backend server, are
skipped. To enable them, set the following environment variables:exportPYTKET_RUN_REMOTE_TESTS=1exportPYTKET_REMOTE_IQM_AUTH_SERVER_URL=https://demo.qc.iqm.fi/authexportPYTKET_REMOTE_IQM_USERNAME=YOUR_USERNAMEexportPYTKET_REMOTE_IQM_PASSWORD=YOUR_PASSWORDWhen adding a new feature, please add a test for it. When fixing a bug, please
add a test that demonstrates the fix.