Miniqubit
Quantum emulator of the IBM Quantum experience
Install / Use
/learn @valvy/MiniqubitREADME
Miniqbt, a runtime for the IBM Quantum experience
Introduction
IBM research released a quantum computer accessable in the cloud. MiniQbt is a emulator for the IBM quantum experience, with a generic amount of qubits and classical bits. To contribute to MiniQbt please refer to contributing
installation
The best way of installation is to compile the program from source. For this you need to install the following dependencies. Please consult the individual tools for help.
- Eigen3 (Compile from source at the website since some linux distros only have an old version in the repositories)
- CMake
- Git
- Please use for Windows, Visual studio 2015 or later.
For the Python wrapper your need:
- Python development libraries
- Boost-Python
For the Java wrapper you need:
- Java 8
When done create a new build folder and let Cmake unpack everything there. MiniQbt comes with the following options:
| Build Option | Effect | | --- | --- | | ENABLE_EMSCRIPTEN | Instead of compiling to native code, use Webassembly (Requires emc++ ) | | ENABLE_TESTS | Execute Unit tests | | ENABLE_JAVA | Build the Java wrapper | | ENABLE_PYTHON | Build the Python Wrapper |
Building in GNU/Linux
# Clone the project.
git clone git@github.com:valvy/miniqubit.git
cd miniqubit
# Create a build directory.
mkdir build
cd build
# Build with only unit tests.
cmake .. -DENABLE_EMSCRIPTEN=OFF -DENABLE_TESTS=ON -DENABLE_JAVA=OFF -DENABLE_PYTHON=OFF
make
Library usage
C++ Sample code
#include <miniqbt/MiniQbt.hpp>
#include <iostream>
#include <vector>
int main(int argc, char** argv){
using namespace MiniQbt;
const char* src =
"OPENQASM 2.0; \n"
"include \"qelib1.inc\"; \n"
"qreg q[1]; creg c[1]; \n"
"h q[0]; \n"
"measure q[0] -> c[0]; \n";
QasmAsyncInterpreter interpreter;
interpreter.interpret(std::string(src));
while(interpreter.hasErrors()){
std::cout << interpreter.getError() << "\n";
}
QuantumResult result = interpreter.readClassicResult("c");
std::cout << "result of the algorithm: " << result.dataToString();
std::cout << "\n";
}
Python Sample code
from PyMiniQbt import QasmAsyncInterpreter
source = "OPENQASM 2.0; include \"qelib1.inc\"; qreg q[1]; creg c[1]; h q[0]; measure q[0] -> c[0];"
interpreter = QasmAsyncInterpreter()
interpreter.interpret(source)
result = interpreter.readClassicResult("c")
while interpreter.hasErrors():
print(interpreter.getError())
print("result of the algorithm: ")
print(result.dataToString())
JavaScript sample code
"use strict";
const miniqbt = require('./MiniQbt')
// Make sure MiniQbt is properly loaded.
setTimeout(() => {
console.log("Using : " + miniqbt.NAME + " version "+ miniqbt.VERSION)
let vm = new miniqbt.QasmAsyncInterpreter()
vm.interpret("creg cregister[5]; qreg qregister[5];")
vm.interpret("h qregister;")
vm.interpret("measure qregister -> cregister;")
const result = vm.readClassicResult('cregister')
console.log(result.getName() + " resulted in " + result.dataToString() )
},1000)
Java Sample code
import nl.hvanderheijden.miniqbt.Globals;
import nl.hvanderheijden.miniqbt.QasmAsyncInterpreter;
public class Main {
public static void main(String[] args) {
System.out.println(
String.format("%s version %s",
Globals.getName(),
Globals.getVersion()
)
);
QasmAsyncInterpreter interpreter = new QasmAsyncInterpreter();
interpreter.interpret("qreg a[5];");
interpreter.interpret("creg b[5];");
interpreter.interpret("h a;");
interpreter.interpret("measure a -> b;");
while(interpreter.hasErrors()) {
System.out.println(interpreter.getError());
}
for (String i : interpreter.getRegisters()) {
QuantumResult result = interpreter.readClassicResult(i);
System.out.println(result.dataToString());
}
}
}
Related Skills
YC-Killer
2.7kA library of enterprise-grade AI agents designed to democratize artificial intelligence and provide free, open-source alternatives to overvalued Y Combinator startups. If you are excited about democratizing AI access & AI agents, please star ⭐️ this repository and use the link in the readme to join our open source AI research team.
groundhog
398Groundhog's primary purpose is to teach people how Cursor and all these other coding agents work under the hood. If you understand how these coding assistants work from first principles, then you can drive these tools harder (or perhaps make your own!).
last30days-skill
13.8kAI agent skill that researches any topic across Reddit, X, YouTube, HN, Polymarket, and the web - then synthesizes a grounded summary
000-main-rules
Project Context - Name: Interactive Developer Portfolio - Stack: Next.js (App Router), TypeScript, React, Tailwind CSS, Three.js - Architecture: Component-driven UI with a strict separation of conce
