-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docker container + project housekeep (#178)
* house keeping + docker updates * update run run container echo * add examples submodule * updates workflows and manifest * point to correct package entry in setuptools * try hyphen convention * update manifest and pyproject * fixed typing & headers format * keep version fixed * update changelog
- Loading branch information
Showing
39 changed files
with
320 additions
and
2,689 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[submodule "examples"] | ||
path = examples | ||
url = https://github.com/qBraid/qbraid-lab-demo.git |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
include *.txt *.md | ||
recursive-include docs *.rst *.py *.png *.ico *.txt | ||
include README.md | ||
recursive-include docs *.rst *.py *.png *.ico | ||
recursive-include qbraid_qir *.py | ||
include qbraid_qir/py.typed | ||
prune docs/build/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
#!/bin/bash | ||
|
||
# Copyright (C) 2023 qBraid | ||
# Copyright (C) 2024 qBraid | ||
# | ||
# This file is part of the qBraid-SDK | ||
# | ||
|
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
#!/bin/bash | ||
|
||
# Copyright (C) 2023 qBraid | ||
# Copyright (C) 2024 qBraid | ||
# | ||
# This file is part of the qBraid-SDK | ||
# | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,22 @@ | ||
# Copyright (C) 2024 qBraid Development Team. | ||
# Distributed under terms of the GNU General Public License v3. | ||
FROM jupyter/base-notebook:python-3.11 | ||
|
||
FROM ubuntu:24.04 | ||
|
||
LABEL maintainer="qBraid Development Team <[email protected]>" | ||
LABEL description="Flexible environment with Jupyter, Rust, LLVM, and qir-runner" | ||
LABEL licenses="GNU General Public License v3.0" | ||
LABEL title="qBraid-QIR x QIR bytecode runner" | ||
LABEL description="Flexible environment with qBraid-QIR and the QIR-Runner (built from source)." | ||
LABEL version="1.0" | ||
|
||
USER root | ||
ENV USER=qbraid | ||
|
||
ENV HOME=/home/$USER | ||
|
||
RUN apt-get update --yes && \ | ||
apt-get install --yes --no-install-recommends \ | ||
# Basic utilities | ||
vim git curl jq pkg-config lsb-release wget software-properties-common gnupg \ | ||
sudo vim git curl jq pkg-config lsb-release wget software-properties-common gnupg \ | ||
# SSL related dependencies | ||
openssl libssl-dev \ | ||
# Build dependencies | ||
|
@@ -23,11 +28,17 @@ RUN apt-get update --yes && \ | |
# LLVM dependencies | ||
clang-format clang-tidy clang-tools clang clangd libc++-dev libc++1 libc++abi-dev \ | ||
libc++abi1 libclang-dev libclang1 liblldb-dev libllvm-ocaml-dev libomp-dev \ | ||
libomp5 lld lldb llvm-dev llvm-runtime llvm python3-clang && \ | ||
libomp5 lld lldb llvm-dev llvm-runtime llvm python3-clang \ | ||
libpolly-18-dev libzstd-dev \ | ||
# Python interpreter and package managers | ||
cargo python3 python3-pip python3-venv && \ | ||
apt-get clean && \ | ||
rm -rf /var/lib/apt/lists/* | ||
|
||
USER $NB_UID | ||
RUN useradd -ms /bin/bash $USER && \ | ||
echo "$USER ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers | ||
|
||
USER $USER | ||
|
||
# Install Rustup: https://www.rust-lang.org/tools/install | ||
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y | ||
|
@@ -39,11 +50,9 @@ USER root | |
RUN bash -c "$(wget -O - https://apt.llvm.org/llvm.sh)" | ||
|
||
RUN git clone https://github.com/qir-alliance/qir-runner.git /opt/qir-runner && \ | ||
chown -R $NB_UID:$NB_GID /opt/qir-runner && \ | ||
mkdir -p $(pip cache dir) && \ | ||
fix-permissions $(pip cache dir) | ||
chown -R $USER:$USER /opt/qir-runner | ||
|
||
USER $NB_UID | ||
USER $USER | ||
|
||
WORKDIR /opt/qir-runner | ||
|
||
|
@@ -52,9 +61,11 @@ RUN cargo install llvmenv && \ | |
|
||
ENV PATH="/opt/qir-runner/target/release:${PATH}" | ||
|
||
RUN pip install qbraid qbraid-qir[cirq,qasm3] qbraid-core[runner] && \ | ||
rm -rf $(pip cache dir)/* | ||
WORKDIR /work | ||
|
||
USER root | ||
RUN python3 -m venv venv && \ | ||
venv/bin/python3 -m pip install --upgrade pip && \ | ||
venv/bin/python3 -m pip install qbraid qbraid-qir[cirq,qasm3] qbraid-core[runner] && \ | ||
rm -rf $(venv/bin/python3 -m pip cache dir) | ||
|
||
WORKDIR $HOME | ||
COPY --chown=USER:USER ./examples examples |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
# QIR Runner Docker Container | ||
|
||
This Docker image provides an environment for testing and executing Quantum Intermediate Representation (QIR) | ||
bytecode programs with the [qir-runner](https://github.com/qir-alliance/qir-runner/tree/main) package. | ||
|
||
## Build & run image | ||
|
||
To build the QIR runner image, run the following command: | ||
|
||
```bash | ||
./build.sh | ||
``` | ||
|
||
To start the container, use the following command: | ||
|
||
```bash | ||
./run.sh <container_name> | ||
``` | ||
|
||
To access an interactive shell inside the running container: | ||
|
||
```bash | ||
./exec.sh <container_name> | ||
``` | ||
|
||
## Verify setup with bell circuit example | ||
|
||
Once inside the running container, activate the Python virtual environment that contains `qbraid-qir` by running: | ||
|
||
```bash | ||
source /work/venv/bin/activate | ||
``` | ||
|
||
Next, run one of the example scripts to verify the setup: | ||
|
||
```bash | ||
python3 /work/examples/cirq_bell.py | ||
``` | ||
|
||
This should output something similar to: | ||
|
||
```bash | ||
Cirq Circuit: | ||
0: ───H───@───M─── | ||
│ │ | ||
1: ───────X───M─── | ||
|
||
Running on: QirRunner(seed=None, exec_path=/opt/qir-runner/target/release/qir-runner, version=0.7.4) | ||
|
||
Result: {...,'measurementCounts': {'00': 5, '11': 5}, 'runnerVersion': '0.7.4', 'runnerSeed': None} | ||
``` | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#!/bin/bash | ||
|
||
# Copyright (C) 2024 qBraid Development Team. | ||
# Distributed under terms of the GNU General Public License v3. | ||
|
||
docker build --platform linux/amd64 -t qbraid/qir-runner . |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# Copyright (C) 2024 qBraid | ||
# | ||
# This file is part of qbraid-qir | ||
# | ||
# Qbraid-qir is free software released under the GNU General Public License v3 | ||
# or later. You can redistribute and/or modify it under the terms of the GPL v3. | ||
# See the LICENSE file in the project root or <https://www.gnu.org/licenses/gpl-3.0.html>. | ||
# | ||
# THERE IS NO WARRANTY for qbraid-qir, as per Section 15 of the GPL v3. | ||
|
||
""" | ||
Example of running a Cirq circuit on the QIR bytecode runner. | ||
""" | ||
|
||
import cirq | ||
from qbraid.runtime import QirRunner | ||
|
||
from qbraid_qir.cirq import cirq_to_qir | ||
|
||
q0, q1 = cirq.LineQubit.range(2) | ||
circuit = cirq.Circuit(cirq.H(q0), cirq.CNOT(q0, q1), cirq.measure(q0, q1)) | ||
|
||
print(f"Cirq Circuit: \n{circuit}") | ||
|
||
module = cirq_to_qir(circuit, name="bell") | ||
|
||
sim = QirRunner() | ||
|
||
print(f"\nRunning on: {repr(sim)}") | ||
|
||
result = sim.run(module.bitcode, shots=10) | ||
|
||
print(f"\nResult: {result}") |
Oops, something went wrong.