-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Elijah Pelofske
committed
May 30, 2021
0 parents
commit 7e874c9
Showing
169 changed files
with
33,392 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
name: CI Tests | ||
on: | ||
# Triggers the workflow on push or pull request events | ||
pull_request: | ||
push: | ||
# Allows you to run this workflow manually from the Actions tab | ||
workflow_dispatch: | ||
|
||
jobs: | ||
test: | ||
name: Tests Linux | ||
runs-on: "ubuntu-latest" | ||
defaults: | ||
run: | ||
shell: bash -l {0} | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: conda-incubator/setup-miniconda@v2 | ||
with: | ||
activate-environment: anaconda-client-env | ||
python-version: 3.7.3 | ||
auto-activate-base: True | ||
- name: Install Dependencies and pyQBTNs | ||
run: | | ||
conda info | ||
conda list | ||
python setup.py install | ||
- name: Run the Unittests | ||
run: | | ||
cd tests && python -m unittest TestMatrixFactorizationClassical.py | ||
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,146 @@ | ||
.DS_Store | ||
# contains the data for the project | ||
# data/ | ||
# swap files | ||
*.swp | ||
|
||
# Created by https://www.toptal.com/developers/gitignore/api/python | ||
# Edit at https://www.toptal.com/developers/gitignore?templates=python | ||
|
||
### Python ### | ||
# Byte-compiled / optimized / DLL files | ||
__pycache__/ | ||
*.py[cod] | ||
*$py.class | ||
|
||
# C extensions | ||
*.so | ||
|
||
# Distribution / packaging | ||
.Python | ||
build/ | ||
develop-eggs/ | ||
dist/ | ||
downloads/ | ||
eggs/ | ||
.eggs/ | ||
lib/ | ||
lib64/ | ||
parts/ | ||
sdist/ | ||
var/ | ||
wheels/ | ||
pip-wheel-metadata/ | ||
share/python-wheels/ | ||
*.egg-info/ | ||
.installed.cfg | ||
*.egg | ||
MANIFEST | ||
|
||
# PyInstaller | ||
# Usually these files are written by a python script from a template | ||
# before PyInstaller builds the exe, so as to inject date/other infos into it. | ||
*.manifest | ||
*.spec | ||
|
||
# Installer logs | ||
pip-log.txt | ||
pip-delete-this-directory.txt | ||
|
||
# Unit test / coverage reports | ||
htmlcov/ | ||
.tox/ | ||
.nox/ | ||
.coverage | ||
.coverage.* | ||
.cache | ||
nosetests.xml | ||
coverage.xml | ||
*.cover | ||
*.py,cover | ||
.hypothesis/ | ||
.pytest_cache/ | ||
|
||
# Translations | ||
*.mo | ||
*.pot | ||
|
||
# Django stuff: | ||
*.log | ||
local_settings.py | ||
db.sqlite3 | ||
db.sqlite3-journal | ||
|
||
# Flask stuff: | ||
instance/ | ||
.webassets-cache | ||
|
||
# Scrapy stuff: | ||
.scrapy | ||
|
||
# Sphinx documentation | ||
docs/_build/ | ||
|
||
# PyBuilder | ||
target/ | ||
|
||
# Jupyter Notebook | ||
.ipynb_checkpoints | ||
|
||
# IPython | ||
profile_default/ | ||
ipython_config.py | ||
|
||
# pyenv | ||
.python-version | ||
|
||
# pipenv | ||
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. | ||
# However, in case of collaboration, if having platform-specific dependencies or dependencies | ||
# having no cross-platform support, pipenv may install dependencies that don't work, or not | ||
# install all needed dependencies. | ||
#Pipfile.lock | ||
|
||
# PEP 582; used by e.g. github.com/David-OConnor/pyflow | ||
__pypackages__/ | ||
|
||
# Celery stuff | ||
celerybeat-schedule | ||
celerybeat.pid | ||
|
||
# SageMath parsed files | ||
*.sage.py | ||
|
||
# Environments | ||
.env | ||
.venv | ||
env/ | ||
venv/ | ||
ENV/ | ||
env.bak/ | ||
venv.bak/ | ||
|
||
# Spyder project settings | ||
.spyderproject | ||
.spyproject | ||
|
||
# Rope project settings | ||
.ropeproject | ||
|
||
# mkdocs documentation | ||
/site | ||
|
||
# mypy | ||
.mypy_cache/ | ||
.dmypy.json | ||
dmypy.json | ||
|
||
# Pyre type checker | ||
.pyre/ | ||
|
||
# pytype static type analyzer | ||
.pytype/ | ||
|
||
# End of https://www.toptal.com/developers/gitignore/api/python | ||
|
||
|
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,25 @@ | ||
This program is open source under the BSD-3 License. | ||
Redistribution and use in source and binary forms, with or without modification, are permitted | ||
provided that the following conditions are met: | ||
1. Redistributions of source code must retain the above copyright notice, this list of conditions and | ||
the following disclaimer. | ||
|
||
2.Redistributions in binary form must reproduce the above copyright notice, this list of conditions | ||
and the following disclaimer in the documentation and/or other materials provided with the | ||
distribution. | ||
|
||
3.Neither the name of the copyright holder nor the names of its contributors may be used to endorse | ||
or promote products derived from this software without specific prior written permission. | ||
|
||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS | ||
IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | ||
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR | ||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | ||
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | ||
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; | ||
OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, | ||
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR | ||
OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF | ||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
|
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,150 @@ | ||
# pyQBTNs - Python Quantum Boolean Tensor Networks | ||
|
||
<div align="center", style="font-size: 50px"> | ||
|
||
[![Build Status](https://github.com/lanl/pyQBTNs/actions/workflows/ci_tests.yml/badge.svg?branch=main)](https://github.com/lanl/pyCP_APR/actions/workflows/ci_tests.yml/badge.svg?branch=main) [![License](https://img.shields.io/badge/License-BSD%203--Clause-blue.svg)](https://img.shields.io/badge/License-BSD%203--Clause-blue.svg) [![Python Version](https://img.shields.io/badge/python-v3.7.3-blue)](https://img.shields.io/badge/python-v3.7.3-blue) [![DOI](https://img.shields.io/badge/DOI-10.5281%2Fzenodo.0000000-blue.svg)](https://doi.org/10.5281/zenodo.???????) | ||
|
||
</div> | ||
|
||
This software was developed as a tool to factor tensors using quantum annealers. | ||
Right now this software includes 5 different tensor factorization methods, making up three distinct types of tensor networks. | ||
The software allows the user to specify local solvers that do not require a connection to a quantum annealer, but still solve the optimization problems the annealer would solve during the factorization algorithm. | ||
In order to use a D-Wave quantum annealer as the solver for this software, the user must set up a D-Wave configuration file. The methodology used in pyQBTNs was introduced by Pelofske et al. in [1]. | ||
|
||
<div align="center", style="font-size: 50px"> | ||
|
||
### [:information_source: Documentation](https://lanl.github.io/pyQBTNs/)   [:orange_book: Examples](examples/)   [:page_facing_up: Paper](https://arxiv.org/pdf/2103.07399.pdf) | ||
|
||
</div> | ||
|
||
## Installation | ||
|
||
#### Option 1: Install using pip | ||
```shell | ||
pip install git+https://github.com/lanl/pyQBTNs | ||
``` | ||
#### Option 2: Install from source | ||
```shell | ||
git clone https://github.com/lanl/pyQBTNs | ||
cd qbtns | ||
conda create --name pyQBTNs python=3.7.3 | ||
source activate pyQBTNs | ||
python setup.py install | ||
``` | ||
|
||
|
||
## Setup and Verify D-Wave connection | ||
1. Install [pyQBTNs](#installation). | ||
2. Sign up with [D-Wave Leap](https://cloud.dwavesys.com/leap/signup/). | ||
- Make sure that you have at least 1 minute of QPU time on your free acccount. | ||
3. Set up [D-Wave config file](https://docs.ocean.dwavesys.com/en/stable/overview/sapi.html). | ||
- You can use either an **Advantage** system or a **2000Q** system, but NOT a **Hybrid** solver | ||
4. Run an example: | ||
```shell | ||
cd tests | ||
python -m unittest TestMatrixFactorizationQuantum.py | ||
``` | ||
**Note:** For more detailed description of the D-Wave setup process see the [tutorials](tutorials/) or the [example notebook on D-Wave](examples/D-Wave.ipynb). | ||
|
||
## Example Usage | ||
```python | ||
import numpy as np | ||
from pyQBTNs import QBTNs | ||
|
||
qbtns = QBTNs(factorization_method="Matrix_Factorization") | ||
|
||
X = np.random.choice(a=[False, True], size=(10, 10)) | ||
|
||
qbtns.fit(X, 2) | ||
|
||
score = qbtns.get_score() | ||
print(score) | ||
``` | ||
|
||
## Prerequisites | ||
- [Anaconda](https://docs.anaconda.com/anaconda/install/)(Optional) | ||
- decorator==4.3.0 | ||
- dwave-ocean-sdk>=3.3.0 | ||
- numpy==1.19.2 | ||
- tensorly>=0.4.5 | ||
- sympy==1.7.1 | ||
- networkx>=2.5 | ||
- nimfa>=1.4.0 | ||
- scikit-learn==0.24.1 | ||
- matplotlib>=3.4.2 | ||
- Pillow>=8.2.0 | ||
|
||
|
||
## How to Cite pyQBTNs? | ||
```latex | ||
@MISC{Pelofske2021_pyQBTNs, | ||
author = {E. {Pelofske} and H. {Djidjev} and D. {O'Malley} and M. E. {Eren} and G. {Hahn} and B. S. {Alexandrov}}, | ||
title = {pyQBTNs}, | ||
year = {2021}, | ||
publisher = {GitHub}, | ||
journal = {GitHub repository}, | ||
doi = {10.5281/zenodo.???????}, | ||
howpublished = {\url{https://github.com/lanl/pyQBTNs}} | ||
} | ||
@misc{pelofske2021boolean, | ||
title={Boolean Hierarchical Tucker Networks on Quantum Annealers}, | ||
author={Elijah Pelofske and Georg Hahn and Daniel O'Malley and Hristo N. Djidjev and Boian S. Alexandrov}, | ||
year={2021}, | ||
eprint={2103.07399}, | ||
archivePrefix={arXiv}, | ||
primaryClass={quant-ph} | ||
} | ||
``` | ||
|
||
|
||
## Authors | ||
- [Elijah Pelofske](mailto:[email protected]): Information Sciences, Los Alamos National Laboratory | ||
- [Hristo Djidjev](mailto:[email protected]): Information Sciences, Los Alamos National Laboratory | ||
- [Dan O'Malley](mailto:[email protected]): Computational Earth Science, Los Alamos National Laboratory | ||
- [Maksim E. Eren](mailto:[email protected]): Advanced Research in Cyber Systems, Los Alamos National Laboratory | ||
- Georg Hahn | ||
- [Boian S. Alexandrov](mailto:[email protected]): Theoretical Division, Los Alamos National Laboratory | ||
|
||
## Copyright Notice: | ||
© 2021. Triad National Security, LLC. All rights reserved. | ||
This program was produced under U.S. Government contract 89233218CNA000001 for Los Alamos | ||
National Laboratory (LANL), which is operated by Triad National Security, LLC for the U.S. | ||
Department of Energy/National Nuclear Security Administration. All rights in the program are | ||
reserved by Triad National Security, LLC, and the U.S. Department of Energy/National Nuclear | ||
Security Administration. The Government is granted for itself and others acting on its behalf a | ||
nonexclusive, paid-up, irrevocable worldwide license in this material to reproduce, prepare | ||
derivative works, distribute copies to the public, perform publicly and display publicly, and to permit | ||
others to do so. | ||
|
||
**LANL C Number: C21027** | ||
|
||
## License: | ||
This program is open source under the BSD-3 License. | ||
Redistribution and use in source and binary forms, with or without modification, are permitted | ||
provided that the following conditions are met: | ||
1. Redistributions of source code must retain the above copyright notice, this list of conditions and | ||
the following disclaimer. | ||
|
||
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions | ||
and the following disclaimer in the documentation and/or other materials provided with the | ||
distribution. | ||
|
||
3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse | ||
or promote products derived from this software without specific prior written permission. | ||
|
||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS | ||
IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | ||
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR | ||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | ||
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | ||
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; | ||
OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, | ||
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR | ||
OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF | ||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
|
||
|
||
## References | ||
[1] Pelofske, E., Hahn, G., O'Malley, D., Djidjev, H. N., & Alexandrov, B. S. (2021). Boolean Hierarchical Tucker Networks on Quantum Annealers. arXiv preprint arXiv:2103.07399. |
Oops, something went wrong.