Git Product home page Git Product logo

qcor's People

Contributors

1tnguyen avatar amirebrahimi avatar ausbin avatar danclaudino avatar kharazit avatar moar55 avatar spowers avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

qcor's Issues

random seg fault in antlr-gen pyxasmparser

(gdb) bt
#0  0x00007ffff6907a08 in ?? () from /lib/x86_64-linux-gnu/libgcc_s.so.1
#1  0x00007ffff6908d53 in ?? () from /lib/x86_64-linux-gnu/libgcc_s.so.1
#2  0x00007ffff690974d in _Unwind_Find_FDE () from /lib/x86_64-linux-gnu/libgcc_s.so.1
#3  0x00007ffff6905848 in ?? () from /lib/x86_64-linux-gnu/libgcc_s.so.1
#4  0x00007ffff6906a10 in ?? () from /lib/x86_64-linux-gnu/libgcc_s.so.1
#5  0x00007ffff6906f89 in _Unwind_RaiseException () from /lib/x86_64-linux-gnu/libgcc_s.so.1
#6  0x00007ffff69bb78c in __cxa_throw () from /lib/x86_64-linux-gnu/libstdc++.so.6
#7  0x00007ffff4458eb3 in pyxasm::pyxasmParser::expr_stmt (this=0x7fffffff8cb0) at ../handlers/token_collector/pyxasm/generated/pyxasmParser.cpp:2272
#8  0x00007ffff445819f in pyxasm::pyxasmParser::small_stmt (this=0x7fffffff8cb0) at ../handlers/token_collector/pyxasm/generated/pyxasmParser.cpp:2017
#9  0x00007ffff445788c in pyxasm::pyxasmParser::simple_stmt (this=0x7fffffff8cb0) at ../handlers/token_collector/pyxasm/generated/pyxasmParser.cpp:1888
#10 0x00007ffff444f1f8 in pyxasm::pyxasmParser::single_input (this=0x7fffffff8cb0) at ../handlers/token_collector/pyxasm/generated/pyxasmParser.cpp:128
#11 0x00007ffff44b9b99 in qcor::PyXasmTokenCollector::collect (this=0x7fffe806dd70, PP=..., Toks=..., bufferNames=std::vector of length 1, capacity 1 = {...}, ss=...)
    at ../handlers/token_collector/pyxasm/pyxasm_token_collector.cpp:188
#12 0x00007fffe1e44d10 in qcor::run_token_collector (PP=..., Toks=..., bufferNames=std::vector of length 1, capacity 1 = {...}) at ../handlers/token_collector/token_collector_util.cpp:198
#13 0x00007fffe5652a1e in qcor::QCORSyntaxHandler::GetReplacement (this=0x7fffffffa040, PP=..., kernel_name="ansatz", program_arg_types=std::vector of length 2, capacity 2 = {...}, 
    program_parameters=std::vector of length 2, capacity 2 = {...}, bufferNames=std::vector of length 1, capacity 1 = {...}, Toks=..., OS=..., add_het_map_ctor=true)
    at ../handlers/qcor_syntax_handler.cpp:85
#14 0x00007fffe682e219 in qcor::QJIT::run_syntax_handler (this=0x1e6fed0, 
    kernel_src="__qpu__ void ansatz(qreg q,double theta) {\nusing qcor::pyxasm;\n\n", ' ' <repeats 12 times>, "X(q[0])\n", ' ' <repeats 12 times>, "Ry(q[1], theta)\n", ' ' <repeats 12 times>, "CX(q[1], q[0])\n}\n", add_het_map_kernel_ctor=true) at runtime/jit/qcor_jit.cpp:218

asserts in quantum kernels

__qpu__ void hwe(qreg q, std::vector<double> x, const int layers, 
                    std::vector<std::pair<int,int>> cnot_coupling) {
    assert(x.size() == layers*q.size()*5);
... 
}

we should try to support asserts like the above in quantum kernels. right now this is a compile error

<built-in>:21:154: error: use of undeclared identifier 'extension__'
( static_cast < bool > ( x . size ( ) == layers * q . size ( ) * 5 ) ? void ( 0 ) : assert_fail ( "x.size() == layers*q.size()*5" , "hwe_test.cpp" , 3 , extension__ PRETTY_FUNCTION__ ) ) ; 

installation error on Mac

I followed the instructions for installation and got the error below:

ld: library not found for -lqir-qrt
clang-12: error: linker command failed with exit code 1 (use -v to see invocation)
None
1

Internal QRT calls to make LLVM IR re-writing easier

Create internal runtime functions that make it easier on us to map XACC IR to LLVM IR qrt calls. We should have a kernel preamble function call, a simplified function for creating qrt calls, and a end submission call.

  • A call to run initialize and setNameAndStore in one shot
  • A call that takes inst name string, qreg name, and integer indices (easier than creating qreg[] in IR)
  • A call that submits if execute on

single-qubit-gate-merging results in incorrect result for ccnot.cpp

I'm seeing the following results for compiling examples/unitary/ccnot.cpp with opt = 1

{
    "AcceleratorBuffer": {
        "name": "qreg_DCnZQHYUmN",
        "size": 3,
        "Information": {},
        "Measurements": {
            "000": 10,
            "001": 142,
            "010": 166,
            "011": 179,
            "100": 175,
            "101": 46,
            "110": 205,
            "111": 101
        }
    }
}

and the correct result without optimization

{
    "AcceleratorBuffer": {
        "name": "qreg_goULRASYIr",
        "size": 3,
        "Information": {},
        "Measurements": {
            "011": 1024
        }
    }
}

I tried all the level 1 passes individually to see what was causing the error, only thing that caused the incorrect results was single-qubit-merge.

@tnguyen-ornl

qcor observable algebra

Must figure out how to do this in a syntactically efficient manner, that can be used in C or C++

Support C++ syntactic sugar in quantum kernels

  • Ability to pass literals to kernels:
    e.g. __qpu__ void myKernel(qreg q, int varName), we should be able to call myKernel(q, 0) (passes 0 to varName).
    Currently, we need to assign literal to a local variable before passing it to the function argument.

  • Ability to assign classical function return values to local classical variables.
    e.g.

std::vector<double> myLocalArray = someFunc(...); // someFunc is strictly classical

Currently, this is not available/not reliable.
We can work around this by modifying the function signature to take the local variable by reference and update it rather than returning a value.

  • Ability to do fully-classical conditional.
    e.g.
__qpu__ void myKernel(qreg q, int switchVar) {
	if (switchVar != 0) {
		// Do something, e.g. add gates
	}
}

Maybe related to the above, early return should also be nice.

e.g.

__qpu__ void myKernel(qreg q, int switchVar) {
    if (swicthVar == 0) {
       return;
    }
   // Gates when switchVar != 0
}

QuantumKernels -> unitary matrix representation

In Python, we should enable it so that one can extract the unitary matrix representation of an evaluated quantum kernel

@qjit
def ansatz(q : qreg, theta : float):
   ...

u_mat = ansatz.as_unitary_matrix(q, 2.2)

Similarly, in C++

auto u_mat = ansatx::as_unitary_matrix(q,2.2);

To do this, we could start by porting the https://github.com/eclipse/xacc/blob/master/quantum/plugins/algorithms/gradient_strategies/autodiff/Autodiff.cpp visitor implementation to qcor_utils

slow compile times mac os x

for a simple test problem, I am noticing on the Mojave CI that qcor compile times are much slower than on Linux with brew or apt-get.

@tnguyen-ornl will you look into this separately on your Mojave install?

Develop IR Pass that unrolls quantum for loops

We want to take something like

for (int i = 0; i < n; i++) {
  H(q[i]);
} 

to

for (int i = 0; i < 1; i++) {
  H(q[0]);
  H(q[1]);
  H(q[2]);
  ...
  H(q[n-1]);
}

when we know at compile time what n is.

Look into LoopInfoWrapperPass

Rigetti QCS install

Rigetti QCS has moved to a access model whereby you have a JupyterLab IDE, no more VM with sudo access.

The VM is not bad, 32gb RAM and 8 cores, Ubuntu 20.04.

You cannot run the aide-qc install script as is, it requires sudo.

You can clone deploy and dpkg -x xacc . to install locally. Problem is that the qcor executable has hard-coded paths.

qjit kernel name = 't', symbols not found __cxx_global_var_init

When I try to just in time compile a kernel with name 't' (any function body content), I get a weird symbol not found error coming out of the jit code

def t(q : qreg):
    H(q[0])
    CNOT(q[0], q[1])
    CNOT(q[1], q[2])
    Measure(q[0])
    Measure(q[1])
    Measure(q[2])
Failure value returned from cantFail wrapped call
Symbols not found: [ __cxx_global_var_init ]
UNREACHABLE executed at /usr/local/aideqc/llvm/include/llvm/Support/Error.h:749!
Aborted (core dumped)

random seg fault for pyxasmparser from antlr

(gdb) bt
#0  0x00007ffff6907a08 in ?? () from /lib/x86_64-linux-gnu/libgcc_s.so.1
#1  0x00007ffff6908d53 in ?? () from /lib/x86_64-linux-gnu/libgcc_s.so.1
#2  0x00007ffff690974d in _Unwind_Find_FDE () from /lib/x86_64-linux-gnu/libgcc_s.so.1
#3  0x00007ffff6905848 in ?? () from /lib/x86_64-linux-gnu/libgcc_s.so.1
#4  0x00007ffff6906a10 in ?? () from /lib/x86_64-linux-gnu/libgcc_s.so.1
#5  0x00007ffff6906f89 in _Unwind_RaiseException () from /lib/x86_64-linux-gnu/libgcc_s.so.1
#6  0x00007ffff69bb78c in __cxa_throw () from /lib/x86_64-linux-gnu/libstdc++.so.6
#7  0x00007ffff4458eb3 in pyxasm::pyxasmParser::expr_stmt (this=0x7fffffff8cb0) at ../handlers/token_collector/pyxasm/generated/pyxasmParser.cpp:2272
#8  0x00007ffff445819f in pyxasm::pyxasmParser::small_stmt (this=0x7fffffff8cb0) at ../handlers/token_collector/pyxasm/generated/pyxasmParser.cpp:2017
#9  0x00007ffff445788c in pyxasm::pyxasmParser::simple_stmt (this=0x7fffffff8cb0) at ../handlers/token_collector/pyxasm/generated/pyxasmParser.cpp:1888
#10 0x00007ffff444f1f8 in pyxasm::pyxasmParser::single_input (this=0x7fffffff8cb0) at ../handlers/token_collector/pyxasm/generated/pyxasmParser.cpp:128
#11 0x00007ffff44b9b99 in qcor::PyXasmTokenCollector::collect (this=0x7fffe806dd70, PP=..., Toks=..., bufferNames=std::vector of length 1, capacity 1 = {...}, ss=...)
    at ../handlers/token_collector/pyxasm/pyxasm_token_collector.cpp:188
#12 0x00007fffe1e44d10 in qcor::run_token_collector (PP=..., Toks=..., bufferNames=std::vector of length 1, capacity 1 = {...}) at ../handlers/token_collector/token_collector_util.cpp:198
#13 0x00007fffe5652a1e in qcor::QCORSyntaxHandler::GetReplacement (this=0x7fffffffa040, PP=..., kernel_name="ansatz", program_arg_types=std::vector of length 2, capacity 2 = {...}, 
    program_parameters=std::vector of length 2, capacity 2 = {...}, bufferNames=std::vector of length 1, capacity 1 = {...}, Toks=..., OS=..., add_het_map_ctor=true)
    at ../handlers/qcor_syntax_handler.cpp:85
#14 0x00007fffe682e219 in qcor::QJIT::run_syntax_handler (this=0x1e6fed0, 
    kernel_src="__qpu__ void ansatz(qreg q,double theta) {\nusing qcor::pyxasm;\n\n", ' ' <repeats 12 times>, "X(q[0])\n", ' ' <repeats 12 times>, "Ry(q[1], theta)\n", ' ' <repeats 12 times>, "CX(q[1], q[0])\n}\n", add_het_map_kernel_ctor=true) at runtime/jit/qcor_jit.cpp:218

qcor set credentials for remote processor

We should hook up the qcor executable to provide a --credentials or something like that would take the name of the accelerator, and any other info to write the appropriate .*_config file.

qcor --set-credentials ibm --hub ibm-q-ornl --group ornl --project PROJECT

There should also be an --update-credentials to change some of this info.

All non-entry quantum kernels should be annotated with __attribute__((always_inline))

For IR Passes, we really want to flatten entry level quantum kernels (those whose parent or caller is regular function / not quantum / something like main()). This will make it easier on us to figure out the flattened qasm qrt calls and map to XACC IR. This flattening can be accomplished via function inlining. This link seems to suggest that clang will automatically accomplish this for functions annotated with __attribute__((always_inline)) https://lists.llvm.org/pipermail/llvm-dev/2018-May/123425.html.

We should be able to add this attribute to non-entry kernels in the token_collector_util.cpp file.

KernelBuilder data type for Python API

We should provide a way to build quantum kernels programmatically (similar to other packages circuit types).

This should be a high-level wrapper around either the QJIT work or the xacc IRProvider.

It should alternately allow a user to provide a unitary matrix and delegate to a desired circuit synthesis strategy.

It should be treated just like a standard quantum kernel function, exposing some kind of call operation.

You should be able to declaratively provide kernel arguments or variables.

get -> create

things like getObservable should be createObservable

QCOR error when compiling in the source file directory

Steps to reproduce:

  • Navigate to qcor/examples/qrt folder.
  • Execute qcor -o deuteron_qpp -qpu qpp deuteron_task_initiate.cpp
  • QCOR successfully generates deuteron_qpp executable.
  • Re-execute qcor -o deuteron_qpp -qpu qpp deuteron_task_initiate.cpp
  • QCOR compilation failed with the error:
deuteron_task_initiate.cpp:1:10: fatal error: 'qcor.hpp' file not found
#include "qcor.hpp"
         ^~~~~~~~~~
1 error generated.
None
1

We need to delete the file deuteron_qpp to get it to work again.

bug - llvm module cache in /usr/local/xacc

if we install with apt-get, then the install directory will be /usr/local/xacc, which will have root permissions, and anyone using python or qjit will not be able to cache or read llvm module bitcode files. Need to update qjit to cache to the home directory.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.