This repository contains implementations and tools for probabilistic computing using p-bits. The setup instructions below will guide you through cloning the repository, setting up a virtual environment, and ensuring proper configuration for running the project.
First, clone the repository to your local machine:
git clone https://github.com/YOUR_GITHUB_USERNAME/YOUR_REPO_NAME.git
cd YOUR_REPO_NAMEEnsure you have Python 3.8+ installed, then create a virtual environment:
python -m venv .venv.venv\Scripts\activate✅ If you see .venv in your terminal prompt, your environment is activated!
This script ensures your project directory is included in PYTHONPATH automatically. Append the working directory to the venv activate.bat and Activate.ps1 files.
post-venv-setup.batRun the following command to install all required Python packages:
pip install -r requirements.txtIf using Poetry, install dependencies with:
poetry installRun these tests to confirm everything is working:
python -c "import sys; print(sys.path)"You should see a path similar to:
'C:\repositories\ProbabilisticComputing'
python -c "import numpy; import pandas; import matplotlib; print('All packages installed!')"If everything is correct, you’ll see:
All packages installed!
To run your scripts or Jupyter Notebooks, first activate the virtual environment:
.venv\Scripts\activate # Windows
source .venv/bin/activate # macOS/LinuxThen execute:
python your_script.pyor open Jupyter Notebook:
jupyter notebookWhen you're done, deactivate the virtual environment:
deactivateIf PYTHONPATH is not set, manually run:
echo $PYTHONPATH # macOS/Linux
echo %PYTHONPATH% # WindowsIf empty, re-run:
bash post-venv-setup.sh # macOS/Linux
post-venv-setup.bat # WindowsEnsure all dependencies are installed:
pip install -r requirements.txtPython scripts placed under the Scripts folder are used to generate parameters, simulate the probabilistic circuit, and plotting the output.
-
comparison.py
Loads CSV data from FPGA and Python Boltzmann simulations, merges them based on common labels, and generates plots comparing normalized probability distributions. It supports saving the plots automatically. -
CustomScripts.py
Contains utility functions for:- Converting between bipolar and binary representations.
- Calculating fixed-point ranges.
- Generating SystemVerilog initialization code (e.g., seed generation, parameter formatting).
-
generate_bar_plots.py
Reads simulation output CSV files, processes the data according to a provided label mapping, and generates bar plots showing the probability distribution of output cases. It can also export the computed counts to CSV. -
generate_weight_from_logic.py
Scans a designatedCircuit_Libraryfolder for NPZ files containing circuit weight data, extracts bias vectors (h) and weight matrices (J), and constructs a weight library. It also includes a function to compute overall circuit weights from a logic circuit description. -
simulate_p_circuit.py
Implements functions to:- Compute binary energy for given states.
- Generate Boltzmann distributions based on Ising-like energy models.
- Simulate p-bit dynamics using both iterative updates and direct Boltzmann sampling.
- Plot the resulting probability distributions from simulations.