iic-jku / ibm_qx_mapping Goto Github PK
View Code? Open in Web Editor NEWMapping of OPENQASM programs to IBM QX satisfying the architectural constraints
Home Page: http://iic.jku.at/eda/research/ibm_qx_mapping/
License: MIT License
Mapping of OPENQASM programs to IBM QX satisfying the architectural constraints
Home Page: http://iic.jku.at/eda/research/ibm_qx_mapping/
License: MIT License
Hi,
I'm interested in the mapping algorithm you proposed, and I'm trying to get it running on my laptop. However, I got this while compiling:
[libreliu@thinkpad-ssd build]$ make
[ 20%] Building CXX object CMakeFiles/dd_example.dir/src/main.cpp.o
In file included from /usr/include/c++/9.2.0/x86_64-pc-linux-gnu/bits/c++allocator.h:33,
from /usr/include/c++/9.2.0/bits/allocator.h:46,
from /usr/include/c++/9.2.0/string:41,
from /usr/include/c++/9.2.0/bits/locale_classes.h:40,
from /usr/include/c++/9.2.0/bits/ios_base.h:41,
from /usr/include/c++/9.2.0/ios:42,
from /usr/include/c++/9.2.0/ostream:38,
from /usr/include/c++/9.2.0/iostream:39,
from /home/libreliu/quantum-computing/ibm_qx_mapping/src/main.cpp:1:
/usr/include/c++/9.2.0/ext/new_allocator.h: In instantiation of 'void __gnu_cxx::new_allocator<_Tp>::construct(_Up*, _Args&& ...) [with _Up = edge; _Args = {int&, int}; _Tp = std::_Rb_tree_node<edge>]':
/usr/include/c++/9.2.0/bits/alloc_traits.h:482:2: required from 'static void std::allocator_traits<std::allocator<_CharT> >::construct(std::allocator_traits<std::allocator<_CharT> >::allocator_type&, _Up*, _Args&& ...) [with _Up = edge; _Args = {int&, int}; _Tp = std::_Rb_tree_node<edge>; std::allocator_traits<std::allocator<_CharT> >::allocator_type = std::allocator<std::_Rb_tree_node<edge> >]'
/usr/include/c++/9.2.0/bits/stl_tree.h:614:32: required from 'void std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_M_construct_node(std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_Link_type, _Args&& ...) [with _Args = {int&, int}; _Key = edge; _Val = edge; _KeyOfValue = std::_Identity<edge>; _Compare = std::less<edge>; _Alloc = std::allocator<edge>; std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_Link_type = std::_Rb_tree_node<edge>*]'
/usr/include/c++/9.2.0/bits/stl_tree.h:631:4: required from 'std::_Rb_tree_node<_Val>* std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_M_create_node(_Args&& ...) [with _Args = {int&, int}; _Key = edge; _Val = edge; _KeyOfValue = std::_Identity<edge>; _Compare = std::less<edge>; _Alloc = std::allocator<edge>; std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_Link_type = std::_Rb_tree_node<edge>*]'
/usr/include/c++/9.2.0/bits/stl_tree.h:2408:13: required from 'std::pair<std::_Rb_tree_iterator<_Val>, bool> std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_M_emplace_unique(_Args&& ...) [with _Args = {int&, int}; _Key = edge; _Val = edge; _KeyOfValue = std::_Identity<edge>; _Compare = std::less<edge>; _Alloc = std::allocator<edge>]'
/usr/include/c++/9.2.0/bits/stl_set.h:463:64: required from 'std::pair<typename std::_Rb_tree<_Key, _Key, std::_Identity<_Tp>, _Compare, typename __gnu_cxx::__alloc_traits<_Alloc>::rebind<_Key>::other>::const_iterator, bool> std::set<_Key, _Compare, _Alloc>::emplace(_Args&& ...) [with _Args = {int&, int}; _Key = edge; _Compare = std::less<edge>; _Alloc = std::allocator<edge>; typename std::_Rb_tree<_Key, _Key, std::_Identity<_Tp>, _Compare, typename __gnu_cxx::__alloc_traits<_Alloc>::rebind<_Key>::other>::const_iterator = std::_Rb_tree_const_iterator<edge>]'
/home/libreliu/quantum-computing/ibm_qx_mapping/src/main.cpp:107:29: required from here
/usr/include/c++/9.2.0/ext/new_allocator.h:145:20: error: new initializer expression list treated as compound expression [-fpermissive]
145 | noexcept(noexcept(::new((void *)__p)
| ^~~~~~~~~~~~~~~~~~
146 | _Up(std::forward<_Args>(__args)...)))
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/9.2.0/ext/new_allocator.h:145:20: error: no matching function for call to 'edge::edge(int)'
/home/libreliu/quantum-computing/ibm_qx_mapping/src/main.cpp:31:8: note: candidate: 'edge::edge()'
31 | struct edge {
| ^~~~
/home/libreliu/quantum-computing/ibm_qx_mapping/src/main.cpp:31:8: note: candidate expects 0 arguments, 1 provided
/home/libreliu/quantum-computing/ibm_qx_mapping/src/main.cpp:31:8: note: candidate: 'constexpr edge::edge(const edge&)'
/home/libreliu/quantum-computing/ibm_qx_mapping/src/main.cpp:31:8: note: no known conversion for argument 1 from 'int' to 'const edge&'
/home/libreliu/quantum-computing/ibm_qx_mapping/src/main.cpp:31:8: note: candidate: 'constexpr edge::edge(edge&&)'
/home/libreliu/quantum-computing/ibm_qx_mapping/src/main.cpp:31:8: note: no known conversion for argument 1 from 'int' to 'edge&&'
In file included from /usr/include/c++/9.2.0/x86_64-pc-linux-gnu/bits/c++allocator.h:33,
from /usr/include/c++/9.2.0/bits/allocator.h:46,
from /usr/include/c++/9.2.0/string:41,
from /usr/include/c++/9.2.0/bits/locale_classes.h:40,
from /usr/include/c++/9.2.0/bits/ios_base.h:41,
from /usr/include/c++/9.2.0/ios:42,
from /usr/include/c++/9.2.0/ostream:38,
from /usr/include/c++/9.2.0/iostream:39,
from /home/libreliu/quantum-computing/ibm_qx_mapping/src/main.cpp:1:
/usr/include/c++/9.2.0/ext/new_allocator.h: In instantiation of 'void __gnu_cxx::new_allocator<_Tp>::construct(_Up*, _Args&& ...) [with _Up = edge; _Args = {int, int&}; _Tp = std::_Rb_tree_node<edge>]':
/usr/include/c++/9.2.0/bits/alloc_traits.h:482:2: required from 'static void std::allocator_traits<std::allocator<_CharT> >::construct(std::allocator_traits<std::allocator<_CharT> >::allocator_type&, _Up*, _Args&& ...) [with _Up = edge; _Args = {int, int&}; _Tp = std::_Rb_tree_node<edge>; std::allocator_traits<std::allocator<_CharT> >::allocator_type = std::allocator<std::_Rb_tree_node<edge> >]'
/usr/include/c++/9.2.0/bits/stl_tree.h:614:32: required from 'void std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_M_construct_node(std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_Link_type, _Args&& ...) [with _Args = {int, int&}; _Key = edge; _Val = edge; _KeyOfValue = std::_Identity<edge>; _Compare = std::less<edge>; _Alloc = std::allocator<edge>; std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_Link_type = std::_Rb_tree_node<edge>*]'
/usr/include/c++/9.2.0/bits/stl_tree.h:631:4: required from 'std::_Rb_tree_node<_Val>* std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_M_create_node(_Args&& ...) [with _Args = {int, int&}; _Key = edge; _Val = edge; _KeyOfValue = std::_Identity<edge>; _Compare = std::less<edge>; _Alloc = std::allocator<edge>; std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_Link_type = std::_Rb_tree_node<edge>*]'
/usr/include/c++/9.2.0/bits/stl_tree.h:2408:13: required from 'std::pair<std::_Rb_tree_iterator<_Val>, bool> std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_M_emplace_unique(_Args&& ...) [with _Args = {int, int&}; _Key = edge; _Val = edge; _KeyOfValue = std::_Identity<edge>; _Compare = std::less<edge>; _Alloc = std::allocator<edge>]'
/usr/include/c++/9.2.0/bits/stl_set.h:463:64: required from 'std::pair<typename std::_Rb_tree<_Key, _Key, std::_Identity<_Tp>, _Compare, typename __gnu_cxx::__alloc_traits<_Alloc>::rebind<_Key>::other>::const_iterator, bool> std::set<_Key, _Compare, _Alloc>::emplace(_Args&& ...) [with _Args = {int, int&}; _Key = edge; _Compare = std::less<edge>; _Alloc = std::allocator<edge>; typename std::_Rb_tree<_Key, _Key, std::_Identity<_Tp>, _Compare, typename __gnu_cxx::__alloc_traits<_Alloc>::rebind<_Key>::other>::const_iterator = std::_Rb_tree_const_iterator<edge>]'
/home/libreliu/quantum-computing/ibm_qx_mapping/src/main.cpp:108:29: required from here
/usr/include/c++/9.2.0/ext/new_allocator.h:145:20: error: new initializer expression list treated as compound expression [-fpermissive]
145 | noexcept(noexcept(::new((void *)__p)
| ^~~~~~~~~~~~~~~~~~
146 | _Up(std::forward<_Args>(__args)...)))
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/9.2.0/ext/new_allocator.h:145:20: error: no matching function for call to 'edge::edge(int&)'
/home/libreliu/quantum-computing/ibm_qx_mapping/src/main.cpp:31:8: note: candidate: 'edge::edge()'
31 | struct edge {
| ^~~~
/home/libreliu/quantum-computing/ibm_qx_mapping/src/main.cpp:31:8: note: candidate expects 0 arguments, 1 provided
/home/libreliu/quantum-computing/ibm_qx_mapping/src/main.cpp:31:8: note: candidate: 'constexpr edge::edge(const edge&)'
/home/libreliu/quantum-computing/ibm_qx_mapping/src/main.cpp:31:8: note: no known conversion for argument 1 from 'int' to 'const edge&'
/home/libreliu/quantum-computing/ibm_qx_mapping/src/main.cpp:31:8: note: candidate: 'constexpr edge::edge(edge&&)'
/home/libreliu/quantum-computing/ibm_qx_mapping/src/main.cpp:31:8: note: no known conversion for argument 1 from 'int' to 'edge&&'
make[2]: *** [CMakeFiles/dd_example.dir/build.make:102: CMakeFiles/dd_example.dir/src/main.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:76: CMakeFiles/dd_example.dir/all] Error 2
make: *** [Makefile:84: all] Error 2
I'm using GCC 9.2.0 and CMake 3.15.5, however in another machine with GCC 7.4.0 (Ubuntu 18.04) I got the similar issue. Is there something wrong with my toolchain?
Hello. I am new to quantum computer and want to try your code to learn about IBM QX architecture mapping. However, although I installed VirtualBox and Ubuntu to compile these files, I got this error:
Could not find MPFR (missing: MPFR_INCLUDES MPFR_LIBRARIES MPFR_VERSION_OK)
(Required is at leaast version "1.0.0")
Call Stack (most recent call first):
/usr/share/cmake-3.10/Modules/FindPackageHandleStandardArgs.cmake:378 (_FPHSA_FAILURE_MESSAGE)
cmake/Modules/FindMPFR.cmake:70 (find_package_handle_standard_args)
CMakeLists.txt:8 (FIND_PACKAGE)
I had spent lots of time on finding the problem, but I still don't know how to solve it, and wonder whether I had to install any other library and how should I do. Thanks.
Dear iic-jku,
Greetings,
My name is Sunghye Park. Currently, I am a master student at POSTECH in Korea.
Since I want to understand your mapping methodology, I've installed a ibm_qx_mapping simulator as your build guide.
But, there is 2 errors during the 'make' in 'build' directory.
Such as
error: no matching function for call to 'edge::edge(int&, int)'
_M_value_field(std::forward<_Args>(__args)...) { }
So, I could solve the error by adding the following code to the part of 'edge' struct in the main.cpp in the src directory.
struct edge {
int v1;
int v2;
edge () {
}
edge (int a, int b): v1 (a), v2 (b) {
}
};
However, when I modified and run the code above, the direction of CNOT gate did not match the direction of the IBM QX5 graph. (For example, Q1 should control Q0, but Q0 controls Q1)
So, I am wondering how I can fix this error in the main.cpp.
I would appreciate your reply.
Best Regards,
Sunghye Park
When trying to run one of the example files, right after compiling the program, I get the following error:
$ ./build/ibm_qx_mapping examples/4gt10-v1_81.qasm
Failed to open file 'qelib1.inc'!
Undefined gate: x
Undefined gate: q
ERROR: unexpected statement: started with [!
I am running it under Linux 64bit.
Thanks
Diogo
I get the following error message:
./build/dd_example examples/one-two-three-v1_99.qasm
Failed to open file 'qelib1.inc'!
Undefined gate: x
Undefined gate: q
ERROR: unexpected statement: started with [!
Am I doing something wrong?
I ran ibm_qx_mapping to generate mapping for qft_10.qasm, the generated code is like below
OPENQASM 2.0;
include "qelib1.inc";
qreg q[16];
creg c[16];
U(1.570796, 0.000000, 3.141593) q[0];
U(0.000000, 0.000000, -0.785400) q[0];
CX q[0],q[1];
U(0.000000, 0.000000, 0.785400) q[0];
CX q[0],q[1];
U(0.000000, 0.000000, -0.392700) q[0];
U(1.570796, 0.000000, 3.141593) q[1];
CX q[1],q[2];
U(pi/2,0,pi) q[1];
U(pi/2,0,pi) q[2];
CX q[1],q[2];
U(pi/2,0,pi) q[1];
U(pi/2,0,pi) q[2];
CX q[1],q[2];
CX q[0],q[1];
U(0.000000, 0.000000, -0.785400) q[2];
U(0.000000, 0.000000, 0.392700) q[0];
CX q[0],q[1];
U(0.000000, 0.000000, -0.196350) q[0];
CX q[2],q[1];
...
However when I try to run qiskit to parse it, it throws the error:
" File "/Users/anaconda2/envs/qc/lib/python3.6/site-packages/qiskit/converters/ast_to_dag.py", line 294, in _process_node
self.dag.apply_operation_back(UBase(*args, element), self.condition)
TypeError: init() takes 4 positional arguments but 5 were given"
The parsing code i use is like below:
qc = QuantumCircuit.from_qasm_file(fn)
It seems qiskit cannot parse U gate as it said there were 5 parameters provided when asked for 4.
Hi,
I have compiled the commit on Nov 26, 2019, with id '490beb7' on Mint 19.2 (with CMake 3.10.2 and g++-7) with no error.
The 'dd_example' file (executive file in build folder) is executed only by determinig an input file :
./dd_example <input_file>
after running this command, I can see the results of mapping on terminal including elementary gates, depth,...
but with passing an ouput file to 'dd_example' command (./dd_example <input_file> <output_file>) I get the 'Usage: ./dd_example <input_file>' message in terminal.
So, I write this issue to report the problem of making output file in '490beb7' commit.
Thanks in advance for your attention.
Midia
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.