- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Variational algorithms are touted as the most promising early application for quantum computers. Can we get an example of how to code a useful variational algorithm with the Intel Quantum SDK?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The Intel Quantum SDK (IQSDK) has many features that are geared for coding variational algorithms. The Hybrid Quantum Classical Library (HQCL) is a collection of tools that will help a user increase productivity when programming variational algorithms. Here, we will explore the way to code a reasonably advanced algorithm for the IQSDK using HQCL and dlib (a popular C++ library for solving optimization problems).
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The Intel Quantum SDK (IQSDK) has many features that are geared for coding variational algorithms. The Hybrid Quantum Classical Library (HQCL) is a collection of tools that will help a user increase productivity when programming variational algorithms. Here, we will explore the way to code a reasonably advanced algorithm for the IQSDK using HQCL and dlib (a popular C++ library for solving optimization problems).
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks for sharing this @Shavi! I'm excited to try it out.
Currently, when I use qsub to submit the compile job, the compiler fails to find dlib/optimization.h. Any tips on compiler arguments or the path to dlib?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you for trying out the example we had posted a few weeks back. We have outlined below the full flow which you can use to reproduce the results. The attached source file will also contain some debug output which will help you identify if the program is running as expected.
First we need to install the Hybrid Quantum Classical Library (standard build process will install dlib alongside by default). From your home directory on the DevCloud, enter in the command line
$ git clone https://github.com/IntelLabs/Hybrid-Quantum-Classical-Library.git
$ cd Hybrid-Quantum-Classical-Library
$ mkdir build
$ cd build
$ cmake ..
$ make
Then copy the two attached files to the DevCloud. Change the suffix on the .txt to .sh (this forum doesn't want executable files for security reasons) and edit the top line so that it reads
#!/bin/bash
Also modify the folder locations as appropriate in the job submission script (now titled tfd_job_script.sh) to point to your directories.
Now compile and execute the source file (tfd_4q_full.cpp) using the job script
qsub tfd_job_script.sh
You can compare the console output to the reference output given by console_output_tfd.txt
If you see warnings during compilation, that's related to the use of dynamic parameter angles while using -O1 optimization.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks so much for the more detailed example!
It worked after I made a couple tweaks to tfd_4q_full.cpp.
- I deleted an extraneous equals sign at the end of line 248.
- On lines 249 and 250 I changed undeclared identifier m_qwc_groups to qwc_groups.
- Then for some reason I don't fully understand and can't dig into at the moment, the compiler can't match the printing of qwc_groups on line 250 to this function in HQCL. So I commented out line 250 and basically pasted the contents of that function below it.
Regarding 3, the error was:
tfd_4q_full.cpp:250:57: error: invalid operands to binary expression ('basic_ostream<char, std::char_traits<char> >' and 'hqcl::QWCMap' (aka 'map<int, set<set<pair<int, char> > > >'))
followed by dozens of variations of "note: candidate function template not viable: no known conversion from 'hqcl::QWCMap' ... " to something.
Cheers!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You are correct! Somewhere along the way an editor or webpage gathered old cache and the mistake is mine. I posted a mid-way version of the code. It is updated now to the correct source.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Perfect!
Ah, of course! The addition of "using hqcl::operator<<;" fixed issue 3. Thank you!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you for trying this out @zachary-crockett !
@KevinR_Intel 's reply should contain all the relevant files for you to try out everything smoothly. dlib was not installed by default with the SDK, so previously a user would have had to manually install it. But now, installation of dlib as well as ensmallen is automatic when you build the Hybrid Quantum Classical Library (https://github.com/IntelLabs/Hybrid-Quantum-Classical-Library).
Please let us know if you run into any other issues. Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Ah, I think I got it. You have to include dlib in the submitted source. It's not on the compile machine.
![](/skins/images/B7BA37F9CE4B52FF7CAE1FB0388839C8/responsive_peak/images/icon_anonymous_message.png)
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page