openqasm / qe-compiler

An MLIR based compiler dynamic circuit compiler for real-time control systems supporting OpenQASM 3
Other
46 stars 15 forks source link

Add a new simulator target #147

Closed ibm-wakizaka closed 11 months ago

ibm-wakizaka commented 1 year ago

This PR will be divided into smaller PRs:

Summary

Add a simulator target for simulator using Aer runtime API.

Details

Add a pass that convert QUIR and OQ3 dialects to LLVM's standard dialect that calls Aer functions. Currently all features in OpenQASM3 are not supported. The supported features is listed below:

Please see sample qasm files in target_simulator/test/Conversion.

Requirements

We need a dynamic library libaer.so to run a generated object file.

How to use

$ qss-compiler program.qasm --target simulator --emit=sim -o program.o --config your.cfg --num-shots=1
$ clang program.o -laer -o program
$ ./program 

Note that we may have to additional options to identify the location of libaer.so when generating an executable file with clang.

ibm-wakizaka commented 1 year ago

I have to change the test scripts (test_compile.py, ...) for the simulator target. I'll update them in a few days.

ibm-wakizaka commented 1 year ago

@taalexander @mhillenbrand @hhorii This PR is very huge and seems to contain several features so I will split it into some smaller PRs and close this PR.