Git Product home page Git Product logo

qcc4cp / qcc Goto Github PK

View Code? Open in Web Editor NEW
84.0 11.0 25.0 2.44 MB

Source code for the book "Quantum Computing for Programmers", Cambridge University Press

License: Apache License 2.0

Starlark 1.68% Python 33.46% C++ 64.60% Shell 0.08% Dockerfile 0.19%
quantum-computing factorization grovers-algorithm shors-algorithm deutsch-algorithm deutsch-jozsa-algorithm python solovay-kitaev spectral-decomposition quantum-fourier-transform

qcc's People

Contributors

hundt98847 avatar qcc4cp avatar rhundt avatar xbe 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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

qcc's Issues

Bazel ERROR

Hello,

After following the instructions for compiling the C++ code in Docker, I get the following Bazel error:

`$ docker build -t qcc4cp:latest .
DEPRECATED: The legacy builder is deprecated and will be removed in a future release.
Install the buildx component to build images with BuildKit:
https://docs.docker.com/go/buildx/

Sending build context to Docker daemon 220.1MB
Step 1/27 : FROM debian:11
---> 873181a41b99
Step 2/27 : LABEL maintainer="Abdolhamid Pourghazi [email protected]"
---> Using cache
---> 883cfe428df3
Step 3/27 : LABEL maintainer="Stefan Klessinger [email protected]"
---> Using cache
---> 1bba1a411a0b
Step 4/27 : ENV DEBIAN_FRONTEND noninteractive
---> Using cache
---> de5d6fb41216
Step 5/27 : ENV LANG="C.UTF-8"
---> Using cache
---> 1379171292b9
Step 6/27 : ENV LC_ALL="C.UTF-8"
---> Using cache
---> f3bd7ed972c8
Step 7/27 : RUN apt-get update && apt-get install -y --no-install-recommends build-essential git libpython3-dev python3 python3-pip wget
---> Using cache
---> c058f7ccc312
Step 8/27 : RUN python3 -m pip install absl-py numpy scipy
---> Using cache
---> 3ae8eb401763
Step 9/27 : RUN useradd -m -G sudo -s /bin/bash repro && echo "repro:repro" | chpasswd
---> Using cache
---> b6b00da09dd4
Step 10/27 : USER repro
---> Using cache
---> eb773b7aa90a
Step 11/27 : RUN mkdir -p /home/repro/bin/
---> Using cache
---> 5119a047c1a3
Step 12/27 : RUN wget -O /home/repro/bin/bazel https://github.com/bazelbuild/bazelisk/releases/latest/download/bazelisk-linux-amd64
---> Using cache
---> a7f664877276
Step 13/27 : RUN chmod +x /home/repro/bin/bazel
---> Using cache
---> 8c4c771990c8
Step 14/27 : ENV PATH="/home/repro/bin/:${PATH}"
---> Using cache
---> c51c34440086
Step 15/27 : RUN mkdir -p /home/repro/sources/
---> Using cache
---> 3a898b65d78f
Step 16/27 : WORKDIR /home/repro/sources/
---> Using cache
---> 8439b2897039
Step 17/27 : RUN git clone https://github.com/qcc4cp/qcc.git
---> Using cache
---> ba3894a520d1
Step 18/27 : WORKDIR /home/repro/sources/qcc
---> Using cache
---> 58b7d18fe6fb
Step 19/27 : RUN sed -i 's/python3.7/python3.9/g' WORKSPACE
---> Using cache
---> 67ee9c8e5681
Step 20/27 : WORKDIR /home/repro/sources/qcc/src/lib
---> Using cache
---> dfca1d6daa5d
Step 21/27 : RUN bazel build all
---> Running in d09b99177dde
2023/12/18 14:16:12 Downloading https://releases.bazel.build/7.0.0/release/bazel-7.0.0-linux-x86_64...
Extracting Bazel installation...
Starting local Bazel server and connecting to it...
Computing main repo mapping:
WARNING: --enable_bzlmod is set, but no MODULE.bazel file was found at the workspace root. Bazel will create an empty MODULE.bazel file. Please consider migrating your external dependencies from WORKSPACE to MODULE.bazel. For more details, please refer to bazelbuild/bazel#18958.
Computing main repo mapping:
Computing main repo mapping:
ERROR: /home/repro/sources/qcc/WORKSPACE:1:21: //external:third_party_python: invalid label '/home/repro/sources/qcc/python.BUILD' in attribute 'build_file' in 'new_local_repository' rule: invalid target name '/home/repro/sources/qcc/python.BUILD': target names may not start with '/'
ERROR: /home/repro/sources/qcc/WORKSPACE:8:21: //external:third_party_numpy: invalid label '/home/repro/sources/qcc/numpy.BUILD' in attribute 'build_file' in 'new_local_repository' rule: invalid target name '/home/repro/sources/qcc/numpy.BUILD': target names may not start with '/'
ERROR: Error computing the main repository mapping: Encountered error while reading extension file 'toolchains/local_java_repository.bzl': no such package '@@rules_java_builtin//toolchains': error loading package 'external': Could not load //external package
The command '/bin/sh -c bazel build all' returned a non-zero code: 1
$ `

I get the exact same error when running the compilation outside of Docker following README.Linux.md. I am on Ubuntu 22.04.

I am not a Bazel user and Google so far didn't help.

Compiling lilxgates in MacBook Air M2

Hi!

I tried to run qcc simulator on a MacBook Air with the processor M2. The macOS is Ventura 13.5.2. It works correctly. The python was installed though brew and downloaded by git.

But I can't run it with C++ accelerator, the module returns the message:

**************************************************************`
  WARNING: Could not find 'libxgates.so'.
  Please build it and point PYTHONPATH to it.
  Execution is being re-directed to a Python implementation,
  performance may suffer greatly.
  **************************************************************`

All paths are corrected according libraries place that file WORKSPACE takes into accounts the python positions:

new_local_repository(
    name = "third_party_python",
    build_file = __workspace_dir__ + "/python.BUILD",
    # Configure:
    path = "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/Headers/",
)

new_local_repository(
    name = "third_party_numpy",
    build_file = __workspace_dir__ + "/numpy.BUILD",
    # Configure:
    path = "/Users/maremnev/Library/Python/3.9/lib/python/site-packages/numpy/core/",
)

And variables PATH and PYTHONPATH are corrected too:

export PATH=/Users/maremnev/WorkPlace/qcc:$PATH
export PYTHONPATH=/Users/maremnev/WorkPlace/qcc:$PYTHONPATH

export PYTHONPATH=/Users/maremnev/WorkPlace/qcc/bazel-bin/src/lib:$PYTHONPATH

Command bazel build all returns no errors. But it made in directory qcc/bazel-bin/src/lib files libxgates.a and libxgates.dylib, but python searchs for file libxgates.so.

I guess it's a remainder from Linux.

How to compile the library correctly in Mac? May be it's needed to point the another library in python?

Bazel build ERROR on ubuntu

I am using Linux Ubuntu 22.04.3 LTS (WSL 2) on a windows 11 machine and I have python 3.10, numpy 1.26.3 and bazel 7.0.0 installed.
I modified the WORKSPACE script according to my path to python and numpy, which are respectively:
/usr/include/python3.10
/usr/local/lib/python3.10/dist-packages/numpy/core/

However, when I go in qcc/src/lib and try to build using bazel build all I got this error:

ERROR: /home/username/qcc/WORKSPACE:1:21: //external:third_party_python: invalid label '/home/username/qcc/python.BUILD' in attribute 'build_file' in 'new_local_repository' rule: invalid target name '/home/username/qcc/python.BUILD': target names may not start with '/'
ERROR: /home/username/qcc/WORKSPACE:8:21: //external:third_party_numpy: invalid label '/home/username/qcc/numpy.BUILD' in attribute 'build_file' in 'new_local_repository' rule: invalid target name '/home/username/qcc/numpy.BUILD': target names may not start with '/'
ERROR: Error computing the main repository mapping: Encountered error while reading extension file 'toolchains/jdk_build_file.bzl': no such package '@@rules_java_builtin//toolchains': error loading package 'external': Could not load //external package

SOLUTION

My solution was the following:

  • in the main folder qcc, create a folder called external:
  • move python.BUILD and numpy.BUILD from qcc to qcc/external
  • then modify the WORKSPACE script as follows:
new_local_repository(
    name = "third_party_python",
    build_file = "//external:python.BUILD",
    path = "/usr/include/python3.10",
)

new_local_repository(
    name = "third_party_numpy",
    build_file = "//external:numpy.BUILD",
    path = "/usr/local/lib/python3.10/dist-packages/numpy/core/",
)

This solved the issue for me.
Hope this was helpful, have a greate day :)

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.