Commit e92692b2 authored by Mccaskey, Alex's avatar Mccaskey, Alex
Browse files

Adding docker builds to gitlab ci, updates to readme

parent a8748117
Loading
Loading
Loading
Loading
Loading
+14 −0
Original line number Diff line number Diff line
@@ -51,3 +51,17 @@ docker run_macosx_mojave_bottles:
  - ssh mojave-ci "PATH=/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin bash run_bottle_build.sh $AIDEQC_ACCESS_TOKEN"
  - docker stop $id && docker rm -v $id
  allow_failure: true

docker run_docker_deploy:
  stage: deploy
  only:
    - schedules
  script:
  - cd docker/ci/alpine/qcor && docker build -t qcor/cli . --no-cache
  - cd ../code-server && docker build -t qcor/qcor . --no-cache
  - echo "$REGISTRY_PASSWORD" | docker login -u qcor --password-stdin
  - docker push qcor/cli
  - docker push qcor/qcor
  - docker system prune -f
  - docker rmi -f qcor/qcor qcor/cli
  allow_failure: true
+13 −25
Original line number Diff line number Diff line
@@ -9,42 +9,30 @@
QCOR is a C++ language extension and associated compiler implementation
for hybrid quantum-classical programming.

Documentation
-------------
## Documentation

* [Website and Documentation](https://aide-qc.github.io/deploy)
* [Doxygen Documentation](https://ornl-qci.github.io/qcor-api-docs/)
* [Documentation and User Guides](https://aide-qc.github.io/deploy)
* [Doxygen API Docs](https://ornl-qci.github.io/qcor-api-docs/)

Install
-------
To install `qcor` run the following command from your terminal 
## Installation
To install the `qcor` nightly binaries (for Mac OS X and Linux x86_64) run the following command from your terminal 
```bash
/bin/bash -c "$(curl -fsSL https://aide-qc.github.io/deploy/install.sh)"
```
To use the Python API, be sure to set your `PYTHONPATH`. 
For more details, see [here](https://aide-qc.github.io/deploy/getting_started/).
For more details, see the [full installation documentation page](https://aide-qc.github.io/deploy/getting_started/).

Nightly docker images are also available that serve up a [Theia IDE](https://theia-ide.org/) on port 3000. To use this image, run 
```bash
docker run --security-opt seccomp=unconfined --init -it -p 3000:3000 qcor/qcor
```
and navigate to ``https://localhost:3000`` in your browser to open the IDE and get started with QCOR. 
### Docker Images

For any method of installation, a good way to test your install is to copy and paste the following into your terminal 
Nightly docker images are also available that serve up a [VSCode IDE](https://github.com/cdr/code-server) on port 8080. To use this image, run 
```bash
printf "__qpu__ void f(qreg q) {
  H(q[0]);
  Measure(q[0]);
}
int main() {
  auto q = qalloc(1);
  f(q);
  q.print();
}  " | qcor -qpu qpp -shots 1024 -o test -x c++ -
docker run -it -p 8080:8080 qcor/qcor
```
and then run 
and navigate to ``https://localhost:8080`` in your browser to open the IDE and get started with QCOR. 

Alternatively, you could use the `qcor/cli` image providing simple command-line access to the `qcor` compiler. 
```bash
./test
docker run -it qcor/cli
```

## Cite QCOR 
+13 −2
Original line number Diff line number Diff line
@@ -23,7 +23,18 @@ RUN apk add nodejs openssh-client gnupg bash sudo curl && \
USER 1000
ENV USER=coder
WORKDIR /home/coder
RUN git clone https://github.com/ornl-qci/qcor && cp -r qcor/examples cpp-examples \
   && cp -r qcor/python/examples py-examples && rm -rf qcor 
ADD README.md .
RUN sudo chown coder README.md && sudo chgrp coder README.md \
   && git clone https://github.com/ornl-qci/qcor && cp -r qcor/examples cpp-examples \
   && cp -r qcor/python/examples py-examples && rm -rf qcor \
   && mkdir -p /home/coder/.local/share/code-server/User \
   && printf "{\"workbench.startupEditor\": \"readme\", \"workbench.colorTheme\": \"Monokai Dimmed\", \"workbench.panel.defaultLocation\": \"right\", \"terminal.integrated.shell.linux\": \"bash\", \"files.associations\": {\"*.qasm\": \"cpp\"}" | tee /home/coder/.local/share/code-server/User/settings.json \
   && wget https://github.com/microsoft/vscode-cpptools/releases/download/1.5.1/cpptools-linux.vsix \
   && wget https://github.com/microsoft/vscode-python/releases/download/2020.10.332292344/ms-python-release.vsix \
   && /usr/lib/code-server/bin/code-server --install-extension cpptools-linux.vsix \
   && /usr/lib/code-server/bin/code-server --install-extension ms-python-release.vsix \
   && rm -rf cpptools-linux.vsix ms-python-release.vsix
   
ENV PATH "${PATH}:/usr/lib/code-server/bin"

ENTRYPOINT ["/usr/lib/code-server/bin/code-server", "--bind-addr", "0.0.0.0:8080", "--auth", "none", "."]
+71 −0
Original line number Diff line number Diff line
<img src="https://github.com/ornl-qci/qcor/blob/master/docs/assets/qcor_full_logo.svg?raw=true" alt="qcor_fig" width="600"/>

# Welcome to QCOR

You are using the QCOR web-IDE for heterogeneous quantum-classical computing. <br>
This project provides a pre-built image containing the entire `qcor` compiler stack, including the [`qcor`](https://github.com/ornl-qci/qcor) <br>
C++ compiler and Python quantum JIT environment, the [XACC](https://github.com/eclipse/xacc) framework and high-level Python API, <br>
and the OpenQASM 3 MLIR compiler. 

For much more on the `qcor` platform, check out [docs.aide-qc.org](http://docs.aide-qc.org).

## Getting Started

In the file browser to the left you'll notice a number of example directories. We have provided illustrative examples in C++, Python, <br>
and OpenQASM 3 (via the MLIR compiler). Feel free to try them out! To start, open a Terminal with `CTRL`+<code>\`</code> (single-quote). <br>
From the terminal, you have the `qcor` compiler available in your path as well as the Python bindings for `qcor` and XACC in your `PYTHONPATH`. <br>
Open up the simple `bell.py`, look at it, and run it with 
```bash
$ code-server py-examples/bell.py (or just double-click in file browser)
$ python3 py-examples/bell.py -shots 100
{
    "AcceleratorBuffer": {
        "name": "qrg_ASjHA",
        "size": 2,
        "Information": {},
        "Measurements": {
            "00": 44,
            "11": 56
        }
    }
}
```
To run on IBM or any other physical backend, check out how to provide your [API credentials](https://aide-qc.github.io/deploy/users/remote_qpu_creds/). 

To run a C++ example like [Phase Estimation](https://github.com/ORNL-QCI/qcor/blob/master/examples/qpe/qpe_callable_oracle.cpp), run the following
```bash
$ qcor -shots 100 cpp-examples/qpe/qpe_callable_oracle.cpp
$ ./a.out
X qrg_ASjHA3
H qrg_ASjHA0
H qrg_ASjHA1
H qrg_ASjHA2
CPhase(0.785398) qrg_ASjHA0,qrg_ASjHA3
CPhase(0.785398) qrg_ASjHA1,qrg_ASjHA3
CPhase(0.785398) qrg_ASjHA1,qrg_ASjHA3
CPhase(0.785398) qrg_ASjHA2,qrg_ASjHA3
CPhase(0.785398) qrg_ASjHA2,qrg_ASjHA3
CPhase(0.785398) qrg_ASjHA2,qrg_ASjHA3
CPhase(0.785398) qrg_ASjHA2,qrg_ASjHA3
Swap qrg_ASjHA0,qrg_ASjHA2
H qrg_ASjHA0
CPhase(-1.5708) qrg_ASjHA1,qrg_ASjHA0
H qrg_ASjHA1
CPhase(-1.5708) qrg_ASjHA2,qrg_ASjHA1
CPhase(-0.785398) qrg_ASjHA2,qrg_ASjHA0
H qrg_ASjHA2
Measure qrg_ASjHA0
Measure qrg_ASjHA1
Measure qrg_ASjHA2

{
    "AcceleratorBuffer": {
        "name": "qrg_ASjHA",
        "size": 4,
        "Information": {},
        "Measurements": {
            "100": 100
        }
    }
}
```
 No newline at end of file
+18 −2
Original line number Diff line number Diff line
FROM qcor/llvm-alpine as llvm_install
FROM xacc/alpine
COPY --from=llvm_install /usr/local/aideqc/llvm /usr/local/aideqc/llvm
RUN apk add libc6-compat ninja && git clone https://github.com/ornl-qci/qcor && cd qcor && mkdir build && cd build \
RUN apk add libc6-compat ninja bash sudo curl && git clone https://github.com/ornl-qci/qcor && cd qcor && mkdir build && cd build \
   && cmake .. -G Ninja -DXACC_DIR=/usr/local/aideqc/qcor -DCMAKE_INSTALL_PREFIX=/usr/local/aideqc/qcor -DLLVM_ROOT=/usr/local/aideqc/llvm -DQCOR_EXTRA_COMPILER_FLAGS="-B /usr/lib/gcc/x86_64-alpine-linux-musl/10.3.1 -L /usr/lib/gcc/x86_64-alpine-linux-musl/10.3.1" -DQCOR_EXTRA_HEADERS="/usr/include/c++/10.3.1;/usr/include/c++/10.3.1/x86_64-alpine-linux-musl" \
   && cmake --build . --target install && cd ../.. && rm -rf qcor 
   && cmake --build . --target install && cd ../.. && rm -rf qcor \
   && adduser --gecos '' --disabled-password coder \
   && echo "coder ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers.d/nopasswd \
   && curl -fsSL "https://github.com/boxboat/fixuid/releases/download/v0.5.1/fixuid-0.5.1-linux-amd64.tar.gz" | tar -C /usr/local/bin -xzf - \
   && chown root:root /usr/local/bin/fixuid \
   && chmod 4755 /usr/local/bin/fixuid \
   && mkdir -p /etc/fixuid \
   && printf "user: coder\ngroup: coder\n" > /etc/fixuid/config.yml \
   && rm -rf fixuid-0.5-linux* \
   && ln -s /lib/libc.musl-x86_64.so.1 /lib/ld-linux-x86-64.so.2
   
USER 1000
ENV USER=coder
WORKDIR /home/coder
RUN git clone https://github.com/ornl-qci/qcor && cp -r qcor/examples cpp-examples \
   && cp -r qcor/python/examples py-examples && rm -rf qcor 
ENV PYTHONPATH "${PYTHONPATH}:/usr/local/aideqc/qcor"
ENV PATH "${PATH}:/usr/local/aideqc/qcor/bin"
ENTRYPOINT [ "/bin/bash" ]
 No newline at end of file