You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Support dynamic quantum architecture for IQM QPUs (#3298)
* Support dynamic quantum architecture for IQM QPUs
For IQM machines fetch the quantum architecture from server, derive the dynamic architecture from this and write it to an architecture file. This file is then passed in the lowering pipeline in place of the previously used static architecture files.
The output from the algorithm for finding usable qubits generates a list of qubits which are calibrated for mz, cz and prx. A mapping ensures that qubit names are enumerated in a linear manner and not fully calibrated qubits do not show in the architecture file. The architecture file is created in the system temp directory with a unique filename and deleted after the job has been sent to the IQM server.
Changes in function
* Removed parameter "--iqm-machine" which was used to specify the IQM quantum architecture at compile time.
* Removed static architecture files provided for Adonis, Apollo, and Aphrodite architectures.
* Removed machine architecture bindings from IQM tests.
* Implemented getting the authorization token from IQM_TOKEN environment variable. If this is not set the previous mechanism reading the token from a JSON file is used.
* Updated IQM JSON output of LLVM to latest syntax. "phased_rx" -> "prx", "measurement" -> "measure" in both emitter code and tests.
Test related changes
* Adapted IQM mock server to latest iqmclient API version (v28.0.0) and IQM server API changes.
* Implemented in IQM mock server the 20 qubit Apollo quantum architecture.
* Added support for mapping of qubits syntax in the job request to the mock server.
* In the mock server deliberately removed QB2 and QB3 from the list of PRX calibrated gates. This results in changes in the topology and forces the CUDA-Q code to work with an imperfect calibrated system. This tests the implemented algorithm with every testcase which uses more than 1 qubit.
* In mock server implemented a full checking of gates used in circuits versus the topology to verify that all 2 qubit gates are supported by the mock qpu.
* Pass the authorization token to IQM mock server with env-variable. This includes also a new testcase addressing the IQM_TOKEN environment variable.
* Save and restore environment variables for testcases modifying them. So the order of testcases does not matter anymore.
* Fixed evaluation of 2 qubit testcases which failed on some simulations.
Documentation
* Updated the IQM parts of the documentation and examples. Explained changes from previous version and removed references to the no longer needed machine names.
* Cleanup: improved doxygen headers and few other comments.
* Cleanup: Added copyright to touched files
Addresses issues: #1589, #865
---------
Signed-off-by: Bernd Hoffmann <[email protected]>
Signed-off-by: iqm-bhoffmann <[email protected]>
* removing yapf as spell checker is complaining about it
Signed-off-by: Sachin Pisal <[email protected]>
* Removed debug prints which are failing
Commented out debug output dumping JSON data. The code worked earlier but now fails compilation reporting a type issue.
Signed-off-by: Bernd Hoffmann <[email protected]>
* Removed commented-out debug prints entirely
Instead of fixing a formatting error removed some debug prints entirely as they are just details of a more general previous printout.
Signed-off-by: Bernd Hoffmann <[email protected]>
* Fixed emulation mode for IQM server
Fixed implementation of --emulate parameter. Previously it tried load the dynamic quantum architecture from server despite "emulate" means without server. This caused several ctests to fail.
Removed the --iqm-machine parameter from all ctest lines in the various C++ test programs.
Adapted the ctests mapping testcase to use a Crystal_5.txt file and restored this to the project.
Signed-off-by: Bernd Hoffmann <[email protected]>
* Fixed mapping file issue for emulation mode
In emulation mode provide a mapping file for the 20 qubit crystal architecture.
Restored the Crystal_20.txt (former Apollo.txt) mapping file. This is used only in emulation mode.
Added header file <unistd.h> which was missing in IQMServerHelper.
Signed-off-by: Bernd Hoffmann <[email protected]>
* Corrected comments and code readability
After feedback in internal review corrected:
- Wording of some comments.
- Improved writing of the bit encoded flag variable. Only for readability - non functional change.
- Removed an unused include.
Signed-off-by: Bernd Hoffmann <[email protected]>
* Correction from clang-format
Signed-off-by: Bernd Hoffmann <[email protected]>
* Remove again `prx` from spellchecker whitelist
Signed-off-by: Bernd Hoffmann <[email protected]>
* Clarified documentation
Review feedback: Removed outdated paragraph.
Fixed typo in example.
Signed-off-by: Bernd Hoffmann <[email protected]>
* Alternate ways to define the IQM QPU architecture
Allow defining the IQM QPU architecture at runtime via environment variable IQM_QPU_QA. The value of this variable is interpreted as a path+filename of an QPU architecture (mapping) file.
Aternatively the IQM QPU archtecture can be given at compile time with parameter "--mapping-file" to the nvq++ or in the backend-string as "mapping_file".
Moved the IQM QPU architecture files from "runtime" into the "targettest" folder. Added file for the IQM Crystal-54 architecture. Changed the lit variable pointing to these folders.
Updated all testcases testing IQM target which use "--emulate" to use QPU architecture via environment variable.
Signed-off-by: Bernd Hoffmann <[email protected]>
* Updated IQM doc, save DQA to file, tests
Updated the IQM backend documentation. Created a new subpage there to explain some advanced use-cases.
Added a way to save the dynamic quantum architecture of a server to file for later use.
Added example files of a quantum architecture to targettests/Target/IQM/ folder.
Added testcase to unittests testing the options to load and save a dynamic quantum architecture to file.
Signed-off-by: Bernd Hoffmann <[email protected]>
* Fixup lint and linkcheck issues
The link to Resonance is valid but only when requested with an accept string of "text/html" a response with 200 will be returned. Reverted to previously page instead.
Signed-off-by: Bernd Hoffmann <[email protected]>
---------
Signed-off-by: Bernd Hoffmann <[email protected]>
Signed-off-by: iqm-bhoffmann <[email protected]>
Signed-off-by: Sachin Pisal <[email protected]>
Co-authored-by: Sachin Pisal <[email protected]>
Co-authored-by: Bettina Heim <[email protected]>
Emulation mode will still contact the configured IQM Server to retrieve the dynamic quantum architecture resulting from the active calibration unless a QPU architecture file is explicitly specified.
20
+
This can be done by setting `mapping_file` to point to a file describing the QPU architecture which should be emulated.
21
+
If an architecture is specified no server URL is needed anymore.
Emulation mode will still contact the configured IQM Server to retrieve the dynamic quantum architecture resulting from the active calibration unless a QPU architecture file is explicitly specified.
53
+
This can be done by specifying a file with the architecture either at compile time or in an variable in the environment executing the binary.
54
+
If an architecture is specified no server URL is needed anymore.
55
+
56
+
.. code:: bash
57
+
58
+
// With this binary multiple QPU architectures can be tested without recompilation.
59
+
nvq++ --target iqm --emulate src.cpp -o program
60
+
IQM_QPU_QA="<path+filename of QPU architecture file>" ./program
61
+
62
+
.. code:: bash
63
+
64
+
// This binary will use the given QPU architecture file until overwritten by environment variable "IQM_QPU_QA".
65
+
nvq++ --target iqm --emulate --mapping-file <path+filename of QPU architecture file> src.cpp -o program
66
+
./program
67
+
68
+
The folder ``targettests/Target/IQM/`` contains sample QPU architecture files.
69
+
Find there files for the IQM Crystal architecture as well as files from real life QPUs which can be found on the IQM Resonance portal.
70
+
71
+
The QPU architecture of a test with an IQM server can be saved forlater usein emulation runs.
72
+
To do so the environment variable ``IQM_SAVE_QPU_QA`` must be set to point to a filename in addition to setting the URL of a Resonance server.
73
+
The test can even run as emulation as long as a server URL is given to retrieve the current dynamic quantum architecture from.
74
+
75
+
.. code:: bash
76
+
77
+
nvq++ --target iqm --emulate src.cpp -o program
78
+
IQM_SERVER_URL="https://demo.qc.iqm.fi/" IQM_SAVE_QPU_QA="<path+filename for QPU architecture file>" ./program
79
+
80
+
81
+
To see a complete example, take a look at :ref:`IQM examples <iqm-examples>`.
82
+
83
+
84
+
Setting the Number of Shots
85
+
+++++++++++++++++++++++++++
86
+
87
+
.. tab:: Python
88
+
89
+
The number of shots for a kernel execution can be set through
90
+
the ``shots_count`` argument to ``cudaq.sample`` or ``cudaq.observe``. By default,
91
+
the ``shots_count`` is set to 1000.
92
+
93
+
.. code:: python
94
+
95
+
cudaq.sample(kernel, shots_count=10000)
96
+
97
+
98
+
Using Credentials Saved in a File
99
+
+++++++++++++++++++++++++++++++++
100
+
101
+
The preferred way to pass the "API Token" to the IQM backend is through the environment variable ``IQM_TOKEN``. For compatibility the earlier used storage of the "API Token"in a file can still be used as follows:
102
+
103
+
The previously used ``IQM_TOKENS_FILE`` environment variable can still be used to point to a tokens file but will be ignored if the ``IQM_TOKEN`` variable is set.
104
+
The tokens file cannot be generated by the ``iqmclient`` tool anymore but can be created manually using the "API Token" obtained from the Resonance profile page.
105
+
A tokens file can be created and the environment variable set like this:
Copy file name to clipboardExpand all lines: docs/sphinx/using/backends/hardware/superconducting.rst
+39-54Lines changed: 39 additions & 54 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -109,89 +109,74 @@ To see a complete example, take a look at :ref:`Anyon examples <anyon-examples>`
109
109
110
110
111
111
IQM
112
-
+++++++++
112
+
+++
113
113
114
114
.. _iqm-backend:
115
115
116
-
Support for submissions to IQM is currently under development.
117
-
In particular, two-qubit gates can only be performed on adjacent qubits. For more information, we refer to the respective hardware documentation.
118
-
Support for automatically injecting the necessary operations during compilation to execute arbitrary multi-qubit gates will be added in future versions.
116
+
`IQM Resonance <https://meetiqm.com/products/iqm-resonance/>`__ offers access to various different IQM quantum computers.
117
+
The machines available there will be constantly extended as development progresses.
118
+
Programmers of CUDA-Q may use IQM Resonance with either C++ or Python.
119
119
120
-
Setting Credentials
121
-
`````````````````````````
120
+
With this version it is no longer necessary to define the target QPU architecture in the code or at compile time.
121
+
The IQM backend integration now contacts at runtime the configured IQM server and fetches the active dynamic quantum architecture of the QPU.
122
+
This is then used as input to transpile the quantum kernel code just-in-time for the target QPU topology.
123
+
By setting the environment variable ``IQM_SERVER_URL`` the target server can be selected just before executing the program.
124
+
As result the python script or the compiled C++ program can be executed on different QPUs without recompilation or code changes.
122
125
123
-
Programmers of CUDA-Q may access the IQM Server from either C++ or Python. Following the `quick start guide <https://iqm-finland.github.io/cortex-cli/readme.html#using-cortex-cli>`__, install `iqm-cortex-cli` and login to initialize the tokens file.
124
-
The path to the tokens file can either be passed explicitly via an environment variable or it will be loaded automatically if located in
125
-
the default location :code:`~/.cache/iqm-cortex-cli/tokens.json`.
126
+
Please find also more documentation after logging in to the IQM Resonance portal.
126
127
127
-
.. code:: bash
128
128
129
-
export IQM_TOKENS_FILE="path/to/tokens.json"
129
+
Setting Credentials
130
+
```````````````````
131
+
132
+
Create a free account on the `IQM Resonance portal <https://meetiqm.com/products/iqm-resonance/>`__ and log-in.
133
+
Navigate to the account profile (top right). There generate an "API Token" and copy the generated token-string.
134
+
Set the environment variable ``IQM_TOKEN`` to contain the value of the token-string.
135
+
The IQM backend integration will use this as authorization token at the IQM server.
130
136
131
137
132
-
133
138
Submitting
134
-
`````````````````````````
135
-
136
-
.. tab:: Python
137
-
138
-
The target to which quantum kernels are submitted
139
-
can be controlled with the ``cudaq.set_target()`` function.
Once the binary for a specific IQM QPU architecture is compiled, it can be executed against any IQM Server with the same QPU architecture:
160
+
Once the binary for an IQM QPU is compiled, it can be executed against any IQM Server by setting the environment variable ``IQM_SERVER_URL`` as shown here:
176
161
177
-
.. code:: bash
162
+
.. code:: bash
178
163
179
-
nvq++ --target iqm --iqm-machine Crystal_5 src.cpp -o program
0 commit comments