This Repo contains the reference implementation of the algoritm used in Qubic.
- CPU: support at least AVX2 instruction set
- OS: Windows, Linux
- Open Qiner.sln
- Build
- Support generation using CMake with below command
# Assume in Qiner folder
mkdir build
cd build
"C:\Program Files\CMake\bin\cmake.exe" -G <Visual Studio Generator>
# Example: C:\Program Files\CMake\bin\cmake.exe" -G "Visual Studio 17 2022"
- Open Qiner.sln in build folder and build
- Open Qiner.sln
- Right click Qiner->[C/C++]->[Code Generation]->[Enable Enhanced Instruction Set] -> [...AVX512] -> OK
Currently support GCC and Clang
- Installed required libraries
For example,
- Ubuntu with GCC
sudo apt install build-essential
- Ubuntu with Clang
sudo apt install build-essential
sudo apt install clang
Run below command
mkdir build
cd build
cmake .. -DCMAKE_BUILD_TYPE=Release
make -j8
Run below command
mkdir build
cd build
CC=clang CXX=clang++ cmake .. -DCMAKE_BUILD_TYPE=Release
make -j8
To enable AVX512, -DENABLE_AVX512=1 need to be parse in the cmake command.
Example,
# GCC
cmake .. -DCMAKE_BUILD_TYPE=Release -DENABLE_AVX512=1
# Clang
CC=clang CXX=clang++ cmake .. -DCMAKE_BUILD_TYPE=Release -DENABLE_AVX512=1
Qiner <IP> <Identity> [<number of threads>]
- number of threads: Optional, if not parse default number of cores will be used
- The
random2generator will be used consistently across the entire pipeline. - Each neuron can hold a value of
-1,0, or1. - Synapse weights range within the continuous interval ([-1, 1]).
- Every neuron has exactly
2Moutgoing synapses. Synapses with zero weight represent no connection. - A synapse is considered to be owned by the neuron from which it originates.
- A mining seed is used to initialize the random values of both input and output neurons.
- The nonce and public key determine:
- The random placement of input and output neurons on a ring,
- The weights of synapses,
- The method for selecting synapses during the evolution step.
- Symbols,
- S: evolution step
- P: max neurons population
- R: the number of mismatch between expected output and computed ouput
Given nonce and pubkey as seeds, and constants K, L, N, 2M:
- Initialize
K + Lneurons arranged in a ring structure.Kinput neurons andLoutput neurons are placed at random positions on the ring.
- Initialize input and output neuron values randomly.
- Initialize weights of
2Msynapses with random values in the range[-1, 1](i.e.,-1,0, or1). - Convert neuron values to trits:
- Keep
1as is. - Change
0to-1. - This step occurs only once.
- Keep
- Run initial tick simulation to initialize the
Rvalue.
- For each neuron, compute the new value as:
new_value = sum(weight × connected_neuron_value) - Clamp each neuron's value to the range
[-1, 1]. - Stop the tick simulation if any of the following conditions are met:
- All output neurons have non-zero values.
Nticks have passed.- No neuron values change.
- Compute the initial
R_best— the number of non-matching output bits. - Repeat the following mutation steps up to
Stimes:- Randomly pick a synapse and change its weight:
- Increase or decrease it by
1(i.e., ±1). - If the new weight is within
[-1, 1], proceed. - If the new weight becomes
-2or2:- Revert the weight to its original value.
- Insert a new neuron immediately after the connected neuron.
- The new neuron:
- Copies all incoming synapses from the original neuron.
- Copies only the mutated outgoing synapse; all others are set to
0.
- Remove any synapses exceeding the
2Mlimit per neuron.
- Increase or decrease it by
- Randomly pick a synapse and change its weight:
- Remove any neurons (except input/output) that:
- Have all zero incoming synapses, or
- Have all zero outgoing synapses.
- Stop the evolution if the number of neurons reaches the population limit
P. - Run Tick Simulation again.
- Compute the new
Rvalue:- If
R > R_best, discard the mutation. - If
R ≤ R_best, accept the mutation and updateR_best = R.
- If