-
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
Support dynamic quantum architecture for IQM QPUs #3298
Conversation
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: NVIDIA#1589, NVIDIA#865 --------- Signed-off-by: Bernd Hoffmann <[email protected]> Signed-off-by: iqm-bhoffmann <[email protected]>
Merge branch 'main' of https://github.com/iqm-bhoffmann/cuda-quantum into support-iqm-dynamic-quantum-architecture Signed-off-by: Bernd Hoffmann <[email protected]>
Command Bot: Processing... |
Signed-off-by: Sachin Pisal <[email protected]>
Command Bot: Processing... |
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]>
Command Bot: Processing... |
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]>
Command Bot: Processing... |
|
CUDA Quantum Docs Bot: A preview of the documentation can be found here. |
Command Bot: Processing... |
|
CUDA Quantum Docs Bot: A preview of the documentation can be found here. |
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]>
Command Bot: Processing... |
|
CUDA Quantum Docs Bot: A preview of the documentation can be found here. |
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]>
Command Bot: Processing... |
|
@sacpis The failure in the tonight's build seems to be workflow mechanics and not related to the code. From my point of view the rework of the PR is now complete and could be reviewed one more time. |
Command Bot: Processing... |
|
Thank you @iqm-bhoffmann. Reviewing now. |
|
|
||
| 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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: let's remove from?
| 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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: let's remove from?
| #("QB2",), | ||
| #("QB3",), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should these be removed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Intention was to simulate a qpu architecture in which some qubits did not pass calibration standards. So from the full list of qubits 2 were intentionally disabled. It was left visible so that anybody can easily change to a fully perfect calibrated architecture or an even more limited. The note explaining it can be found a few lines above just before this list. Unfortunately clang was not happy with just a hash on each line to disable the qubits and insisted on some indentation which now looks funny.
sacpis
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Thanks @iqm-bhoffmann. Left a few comments.
|
CUDA Quantum Docs Bot: A preview of the documentation can be found here. |
* 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]>
|
Hey @iqm-bhoffmann, |
|
|
@bettinaheim I don't see why we need two distinct IQM directories. I think they should be merged to avoid confusion. (Specifically, the introduction of a new |
Are you using docker for the dev environment? If so, we would need to pull newer devdeps image to have the new cuquantum version that the code (after that commit) requires. Usually, cuquantum in the dev environment is installed via pip, so we can also do |
I do have a new devdeps docker image. Still see this failure. |
|
Even after |
|
Last week I created issue #3612 to follow up with the build issue I experienced. |
…test environment (#3619) Signed-off-by: Pradnya Khalate <[email protected]>
* 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: NVIDIA#1589, NVIDIA#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]>
…ython test environment (NVIDIA#3619) Signed-off-by: Pradnya Khalate <[email protected]>
|
@iqm-bhoffmann Hello, Seems like with the addition of the line (IQM test in 6646.39s: CUDAQ-Target :: execution/graph_coloring-1.cpp This is specifically for clang16 (for both AMD64 and ARM64) debug build. If I remove that test, the execution time drops to 120 seconds. |
@sacpis I see that there is a problem if this adds one hour to the testing. I did not notice as in my environment it runs in just below 5 minutes on CPU. I am still consulting with our quantum engineers but the initial notion is to remove again the testing for IQM crystal architecture. Question: how would we do this? Should I update this branch and PR or create a new issue/PR for this, or would you like to do this to be fast and this is a rather trivial change? |
|
Sure, you can create a new PR and I will get it merged. Thank you. |
Description
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
Test related changes
Documentation
Addressed issues
#1589, #865