Skip to content

PlanQK/QBM

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

QBM

Repo containing the source code for a Qiskit Implementation of a quantum version of a restricted Boltzmann Machine (QBM). Inside the src folder are multiple Python files.

  • QBMData.py: File containing the class for storing and retrieving data used in the context of the algorithm. This includes static parameters as the number of data and ancilla qubits, as well as dynamic parameters that make up the model and have to be optimized.
  • QBMBuilder.py: File containing the Class for building and executing a parametrized QBM circuit for an avaiable Qiskit Backend. The circuit is transpiled and saved as attribute for the chosen backend after the prepare_qbm-method has been called. Wave function of interest can be generated via the get_state_amplitudes-mehod, which returns a dictionary with binary states as keys and the corresponding amplitudes as values.
  • ExpValClass.py: File containing the Class for post-processing. Evaluates quantities related to an input Hamiltonian w.r.t. some input wave function, defined by state_amplitudes obtained from QBMBuilder methods. Also includes a method for evaluating the analytic gradient in a vectorized form, used for the optimization scheme of choice.
  • helpers.py: File containing helper functions for the classes defined above, as well as utilities for numerically finding groundstates via the matrix representation of a Hamiltonian.
  • visualize_distribution: File containing functions for verifying and visualizing that the correct state distribution was generated by QBMBuilder-methods.
  • program.py: File containing a function for a optimizing the QBM with gradient descent. Can be run as module to optimize the QBM parameters for some Hamiltonian.
  • requirements.txt: Lists the necessary python packages with their versions.

Run QBM

In your local python environment, run the following commands for optimizing the QBM parameters for some input Hamiltonian:

git clone https://github.com/PlanQK/QBM.git
cd QBM
pip install -r requirement.txt
python -m program

This will automatically install required files and execute the last few lines within program.py. Within the input directory two example inputs are provided. The 2_qubit_x_hamiltonian.json file describes a simple Hamiltonian whose groundstate can not be approximated efficiently using the proposed sign node.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages