-
Notifications
You must be signed in to change notification settings - Fork 304
Support dynamic quantum architecture for IQM QPUs #3298
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
Changes from all commits
647afa0
b473371
09162a9
63828da
9914c16
30e7ddd
56c5e17
3f0d099
1067441
403d4ed
a472db4
41a4ce7
2bbc8f0
cc3e9e0
c922993
5b6c2e8
e0559db
a59cfb3
cd84da0
fb5bf88
48495aa
6e7131f
2a97e5c
c5a6e45
7d19320
604f3d2
2fb66ab
6cc51c2
47e9c5c
33d562b
58de041
5fb249a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -354,6 +354,7 @@ toolchain | |
| toolchains | ||
| toolset | ||
| transmon | ||
| transpile | ||
| trotterization | ||
| uccsd | ||
| unary | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,6 @@ | ||
| // Compile and run with: | ||
| // ``` | ||
| // nvq++ --target iqm iqm.cpp --iqm-machine Crystal_5 -o out.x && ./out.x | ||
| // nvq++ --target iqm iqm.cpp -o out.x && ./out.x | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Generally, we try to make sure that changes are non-breaking (current API still works but gives a deprecated warning for some time before we remove it in favor of a different API). It would be good if we could have one test for python and one for C++ that checks the old API still works (possibly giving a warning or error if necessary with instructions for what should be used instead).
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since the architecture information is now fetched from the target machine (URL) giving it as parameter is no longer necessary and the parsing of the parameter was removed. From backward compatibility point nothing bad will happen if it is still given. It can however be confusing that this parameter is ignored and we can give a warning/information about this if desired. |
||
| // ``` | ||
| // Assumes a valid set of credentials have been stored. | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,113 @@ | ||
| IQM Backend Advanced Use Cases | ||
| ============================== | ||
|
|
||
| On this page advanced uses cases which are supported by the IQM backend integration are described. | ||
|
|
||
|
|
||
| Emulation Mode | ||
| ++++++++++++++ | ||
|
|
||
| .. tab:: Python | ||
|
|
||
| To emulate the IQM Server locally, without submitting to the IQM Server, you can set the ``emulate`` flag to ``True``. | ||
| This will emit any target specific compiler diagnostics, before running a noise free emulation. | ||
|
|
||
| .. code:: python | ||
| cudaq.set_target('iqm', emulate=True, url="https://<IQM Server>/") | ||
| 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. | ||
| This can be done by setting `mapping_file` to point to a file describing the QPU architecture which should be emulated. | ||
| If an architecture is specified no server URL is needed anymore. | ||
|
|
||
| .. code:: python | ||
| cudaq.set_target('iqm', emulate=True, mapping_file="<path+filename>") | ||
| The folder ``targettests/Target/IQM/`` contains sample QPU architecture files. | ||
| 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. | ||
|
|
||
| The QPU quantum architecture of a test with a real life IQM QPU can be saved for later use in emulation runs. | ||
| 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. | ||
| The test can even run as emulation as long as a server URL is given to retrieve the current dynamic quantum architecture from. | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: let's remove |
||
|
|
||
| .. code:: bash | ||
| IQM_SERVER_URL="https://demo.qc.iqm.fi/" IQM_SAVE_QPU_QA="<path+filename for QPU architecture file>" python3 program.py | ||
| The file will be created with the given name. If the file already exists the test is aborted with an error. | ||
|
|
||
|
|
||
| .. tab:: C++ | ||
|
|
||
| To emulate the IQM machine locally, without submitting to the IQM Server, you can pass the ``--emulate`` option to ``nvq++``. | ||
| This will emit any target specific compiler diagnostics, before running a noise free emulation. | ||
|
|
||
| .. code:: bash | ||
| nvq++ --target iqm --emulate src.cpp -o program | ||
| IQM_SERVER_URL="https://demo.qc.iqm.fi/" ./program | ||
| 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. | ||
| 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. | ||
| If an architecture is specified no server URL is needed anymore. | ||
|
|
||
| .. code:: bash | ||
| // With this binary multiple QPU architectures can be tested without recompilation. | ||
| nvq++ --target iqm --emulate src.cpp -o program | ||
| IQM_QPU_QA="<path+filename of QPU architecture file>" ./program | ||
| .. code:: bash | ||
| // This binary will use the given QPU architecture file until overwritten by environment variable "IQM_QPU_QA". | ||
| nvq++ --target iqm --emulate --mapping-file <path+filename of QPU architecture file> src.cpp -o program | ||
| ./program | ||
| The folder ``targettests/Target/IQM/`` contains sample QPU architecture files. | ||
| 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. | ||
| The QPU architecture of a test with an IQM server can be saved for later use in emulation runs. | ||
| 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. | ||
| The test can even run as emulation as long as a server URL is given to retrieve the current dynamic quantum architecture from. | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: let's remove |
||
| .. code:: bash | ||
| nvq++ --target iqm --emulate src.cpp -o program | ||
| IQM_SERVER_URL="https://demo.qc.iqm.fi/" IQM_SAVE_QPU_QA="<path+filename for QPU architecture file>" ./program | ||
| To see a complete example, take a look at :ref:`IQM examples <iqm-examples>`. | ||
| Setting the Number of Shots | ||
| +++++++++++++++++++++++++++ | ||
| .. tab:: Python | ||
| The number of shots for a kernel execution can be set through | ||
| the ``shots_count`` argument to ``cudaq.sample`` or ``cudaq.observe``. By default, | ||
| the ``shots_count`` is set to 1000. | ||
| .. code:: python | ||
| cudaq.sample(kernel, shots_count=10000) | ||
| Using Credentials Saved in a File | ||
| +++++++++++++++++++++++++++++++++ | ||
| 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: | ||
| 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. | ||
| 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. | ||
| A tokens file can be created and the environment variable set like this: | ||
| .. code:: bash | ||
| echo '{ "access_token": "<put-your-token-here>" }' > resonance-token.json | ||
| export IQM_TOKENS_FILE="path/to/resonance-token.json" | ||
| When storing the "API Token" in a file please make sure to restrict access to this file to only the account running tests. | ||
| No other user or group on the computer must have any access to this file. | ||
Uh oh!
There was an error while loading. Please reload this page.