Intel® Quantum SDK
Forum related to Intel Quantum SDK, a full-stack software kit for programming and executing algorithms on simulated quantum hardware.
37 Discussions

How would I use the Intel Quantum SDK to write a complete variational algorithm?

Shavi
Employee
4,126 Views

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?

1 Solution
Shavi
Employee
4,125 Views

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).

View solution in original post

8 Replies
Shavi
Employee
4,126 Views

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).

zachary-crockett
4,025 Views

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?

KevinR_Intel
Moderator
3,786 Views

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.

zachary-crockett
3,762 Views

Thanks so much for the more detailed example!

It worked after I made a couple tweaks to tfd_4q_full.cpp.

  1. I deleted an extraneous equals sign at the end of line 248.
  2. On lines 249 and 250 I changed undeclared identifier m_qwc_groups to qwc_groups.
  3. 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!

 

 

0 Kudos
KevinR_Intel
Moderator
3,758 Views

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.

 

zachary-crockett
3,748 Views

Perfect!

Ah, of course! The addition of "using hqcl::operator<<;" fixed issue 3. Thank you!

Shavi
Employee
3,778 Views

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!

zachary-crockett
4,020 Views

Ah, I think I got it. You have to include dlib in the submitted source. It's not on the compile machine.

Reply