atilag / statevector-simulator

Quantum Computer statevector simulator made with Rust and love by one hardcore Qiskit member

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

WASM Quantum State Vector Simulator

This is an ideal (no noise) quantum state vector simulator written in Rust and compiled to WebAssembly so it can be embeded in a webpage (or any other WASM host). The www directory has been used for testing, benchmarking and comparison reasons.

Build Status

Usage | Install Build Chat

Built with 🦀 by The Qiskit community

Usage

-- index.js:
import * as wasm from "statevector-simulator";

let circuit = [
  {
    "type": "standard",
    "label": "u3",
    "qasm": "u3(pi/2,pi/2,pi/2)q[0]",
    "qubits": [{ "qRegIndex": 0, "qRegLabel": "q", "bit": 0 }],
    "cbits": [],
    "params": [
      { "label": "theta", "value": "pi/2" },
      { "label": "phi", "value": "pi/2" },
      { "label": "lambda", "value": "pi/2" }
    ]
  },
  {
    "type": "cx",
    "label": "cx",
    "qasm": "cxq[0],q[1]",
    "qubits": [
      { "qRegIndex": 0, "qRegLabel": "q", "bit": 0 },
      { "qRegIndex": 0, "qRegLabel": "q", "bit": 1 }
    ],
    "controlQubits": [{ "qRegIndex": 0, "qRegLabel": "q", "bit": 0 }],
    "cbits": [],
    "qubitParams": [
      { "param": "c", "qubit": { "qRegIndex": 0, "qRegLabel": "q", "bit": 0 } },
      { "param": "t", "qubit": { "qRegIndex": 0, "qRegLabel": "q", "bit": 1 } }
    ]
  },
  {
    "type": "measure",
    "qasm": "measureq[0]->c[0]",
    "label": "measure",
    "qubits": [{ "qRegIndex": 0, "qRegLabel": "q", "bit": 0 }],
    "cbits": [{ "cRegIndex": 0, "cRegLabel": "c", "bit": 0 }]
  }
  ,
  {
    "type": "measure",
    "qasm": "measureq[1]->c[1]",
    "label": "measure",
    "qubits": [{ "qRegIndex": 0, "qRegLabel": "q", "bit": 1 }],
    "cbits": [{ "cRegIndex": 0, "cRegLabel": "c", "bit": 1 }]
  }
];

let circuit_regs = {
  cRegs: [{ "name": "c", "size": "2" }],
  qRegs: [{ "name": "q", "size": "2" }]
};

wasm.simulate(circuit, circuit_regs, 1024 /* shots */, 69 /* seed */);

Install

npm install statevector-simulator

🛠 Build with wasm-pack build

wasm-pack build

About

Quantum Computer statevector simulator made with Rust and love by one hardcore Qiskit member

License:Apache License 2.0


Languages

Language:JavaScript 85.2%Language:Rust 14.6%Language:HTML 0.1%