Skip to content

jdanielescanez/quantum-solver

Repository files navigation

QuantumSolver

Quantum Solver Logo

QuantumSolver

A little quantum toolset developed using Qiskit
Explore the docs »

Table of Contents

Getting started

Warning

The toolset uses your personal IBM Quantum Experience token to access to the IBM hardware. You can access to your API token or generate another one here.

You can also use the Guest Mode which only allows you to run quantum circuits in simulators.

Download and install

This installation has been tested in the Linux distribution environment: Ubuntu 22.04.1.

# Update and install
sudo apt update && sudo apt upgrade

sudo apt install -y make build-essential libssl-dev zlib1g-dev \
libbz2-dev libreadline-dev libsqlite3-dev wget curl llvm libncurses5-dev \
libncursesw5-dev xz-utils tk-dev libffi-dev liblzma-dev python3-openssl \
git

# Pyenv installation
git clone https://github.com/pyenv/pyenv.git ~/.pyenv
echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bashrc
echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bashrc
echo 'eval "$(pyenv init --path)"' >> ~/.bashrc

It is now important to restart the terminal

reset

Python 3.8.12 installation

pyenv install 3.8.12
pyenv global 3.8.12

NVM installation

wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash
exec bash -l

Node 19.0.1 installation

nvm install node
nvm install 19.0.1
nvm use 19.0.1

QuantumSolver Installation

git clone https://github.com/jdanielescanez/quantum-solver.git
cd quantum-solver
python -m pip install -e .
cd web
npm install

Command Line Interface

QuantumSolver Basic

This main program allows the execution of the circuits corresponding to the basic quantum algorithms: Radom Generation Number, Deutsch-Jozsa, Bernstein-Vazirani, Grover (2-qubits), Quantum Teleportation and Superdense Coding.

python3 src/main_quantum_solver.py [optional IBMQ_TOKEN]

QuantumSolver Subroutine

The main Subroutine program allows running more complex algorithms that require preprocessing of the parameters, and postprocessing of the output from the repeated execution of the defined circuits.

python3 src/main_subroutine.py [optional IBMQ_TOKEN]

QuantumSolver Crypto

This main program gives the option to run a simulation of the following quantum cryptographic protocols: BB84, E91, B92, Six-State, a Quantum Substitute for RSA and Quantum Elgamal.

python3 src/main_crypto.py [optional IBMQ_TOKEN]

QuantumSolver AI

python3 src/main_ai.py

Web Interface

Backend

cd web
python3 src/flask-server/server.py

Frontend

cd web
npm run dev

Screenshots

Home Page
Home Page
Token Page
Token Page
Main Menu Page
Main Menu Page
Run Page
Run Page
Run Experimental Mode Page
Run Experimental Mode Page

How to contribute to QuantumSolver?

QuantumSolver Basic

Creates a derived class (whose name is the name of the algorithm in upper camel case format) in the src/algorithms directory from the abstract class QAlgorithm. To do this, you can copy and paste the simplest algorithm file found in the QRand library, changing the data to suit the circuit you want to implement. The data you must change, besides the name of the file itself (which should be the name of the class in snake case format):

  • Algorithm name
  • Brief description of the problem to be solved
  • List of parameter objects, indicating for each of them the type, a brief description and a warning about the allowed values
  • A method that given a counts result of the execution of the circuit extracts the result
  • A lambda function that parses the entered parameters
  • A method that checks the validity of the entered parameters
  • A method that returns the parameterized circuit itself based on the parameters

It may seem an exahusive list, but following the QAlgorithm template (and especially its simpler implementation in QRand) it is quite simple. If you have any questions in this regard, follow the examples intuitively, open an issue or contact the developers.

Once the derived class has been created, to add it to QuantumSolver just add it to the QAlgorithmManager in the src/algorithms/qalgorithmm_manager.py directory. In the imported libraries add a line:

from algorithms.algorithm_file_name import AlgorithmClass

Finally, add to the array of available algorithms your contribution:

self.algorithms = [
      QRand(),
      DeutschJozsa(),
      BernsteinVazirani(),
      Grover(),
      QuantumTeleportation(),
      SuperdenseCoding(),
      AlgorithmClass()
    ]

In this way, the protocol will be available both in the QuantumSolver Basic command line interface and in the web interface. Consider making a Pull Request for the changes to be made publicly effective.

QuantumSolver Subroutine

To contribute to this module, the procedure is completely analogous to that of QuantumSolver Basic. It has two minor differences:

  • It uses SubroutineManager (src/subroutine/subroutine_manager.py) instead of AlgorithmManager.
  • The QSubroutine class has two more methods than QAlgorithm:
    • One for preprocessing, where you must place the instructions you want to practice to the parameters before becoming part of the input to the circuit constructor.
    • Another one of postprocessing, where the instructions that transform the output of the repeated execution of the circuit (counts) in the final result of the algorithm to be implemented are included.

The approach taken in the first simple derivative class for the Quantum Phase Estimation algorithm can be clearly seen.

QuantumSolver Crypto

Follow the example implementation of any of the previously defined protocols (we recommend the use of BB84 as an initial template). To add your quantum cryptography protocol to QuantumSolver just add your created class to the protocols array of the CyrptoManager class of the srcrypto_manager.py file.

  1. Add the import of your protocol
from crypto.name_dir.name_file import CryptoProtocol
  1. Adds the protocol class to the array
self.protocols = [
  BB84(token),
  E91(token),
  B92(token),
  SixState(token),
  RsaSubstitute(token),
  ElGamal(token),
  CryptoProtocol(token)
]

With these steps, your protocol can be simulated from the main program src/main_crypto.py. Consider making a Pull Request for the changes to be made publicly effective.

QuantumSolver Composer

Any complex classical circuit procedure can be defined from existing circuits or by creating new primitives. This module is still in the experimental phase.

Documentation

QuantumSolver documentation is available at https://jdanielescanez.github.io/quantum-solver/.

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •