All Projects → mapmeld → Jsquil

mapmeld / Jsquil

Licence: apache-2.0
Quantum computer instructions for JavaScript developers

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Jsquil

Qcgpu
High Performance Tools for Quantum Computing
Stars: ✭ 380 (+783.72%)
Mutual labels:  quantum-computing
Cs Video Courses
List of Computer Science courses with video lectures.
Stars: ✭ 27,209 (+63176.74%)
Mutual labels:  quantum-computing
Pennylane
PennyLane is a cross-platform Python library for differentiable programming of quantum computers. Train a quantum computer the same way as a neural network.
Stars: ✭ 800 (+1760.47%)
Mutual labels:  quantum-computing
Qiskit Textbook
A university quantum algorithms/computation course supplement based on Qiskit
Stars: ✭ 404 (+839.53%)
Mutual labels:  quantum-computing
Yao.jl
Extensible, Efficient Quantum Algorithm Design for Humans.
Stars: ✭ 514 (+1095.35%)
Mutual labels:  quantum-computing
Quirk
A drag-and-drop quantum circuit simulator that runs in your browser. A toy for exploring and understanding small quantum circuits.
Stars: ✭ 593 (+1279.07%)
Mutual labels:  quantum-computing
Grove
Quantum algorithms built using pyQuil.
Stars: ✭ 332 (+672.09%)
Mutual labels:  quantum-computing
Docs
D-Wave Ocean Documentation
Stars: ✭ 41 (-4.65%)
Mutual labels:  quantum-computing
Quantumcomputing
This is an implementation of IBM's Quantum Experience in simulation; a 5-qubit quantum computer with a limited set of gates. Please cite me if you end up using this academically.
Stars: ✭ 534 (+1141.86%)
Mutual labels:  quantum-computing
Projectq
ProjectQ: An open source software framework for quantum computing
Stars: ✭ 688 (+1500%)
Mutual labels:  quantum-computing
Qiskit Api Py
This repository and the qiskit-api-py package are deprecated, and no longer supported. A Python library for the Quantum Experience API
Stars: ✭ 458 (+965.12%)
Mutual labels:  quantum-computing
Qiskit Aqua
Quantum Algorithms & Applications in Python
Stars: ✭ 514 (+1095.35%)
Mutual labels:  quantum-computing
Awesome Quantum Software
Curated list of open-source quantum software projects.
Stars: ✭ 647 (+1404.65%)
Mutual labels:  quantum-computing
Quantumcomputingbook
Companion site for the textbook Quantum Computing: An Applied Approach
Stars: ✭ 386 (+797.67%)
Mutual labels:  quantum-computing
Awesome Ai Books
Some awesome AI related books and pdfs for learning and downloading, also apply some playground models for learning
Stars: ✭ 855 (+1888.37%)
Mutual labels:  quantum-computing
Quilc
The @rigetti optimizing Quil compiler.
Stars: ✭ 336 (+681.4%)
Mutual labels:  quantum-computing
Openqasm
Gate and operation specification for quantum circuits
Stars: ✭ 582 (+1253.49%)
Mutual labels:  quantum-computing
Quantumflow Dev
QuantumFlow: A Quantum Algorithms Development Toolkit
Stars: ✭ 43 (+0%)
Mutual labels:  quantum-computing
Qutip
QuTiP: Quantum Toolbox in Python
Stars: ✭ 985 (+2190.7%)
Mutual labels:  quantum-computing
Qusimpy
A Multi-Qubit Ideal Quantum Computer Simulator
Stars: ✭ 688 (+1500%)
Mutual labels:  quantum-computing

jsquil

Greenkeeper badge

JavaScript interface for writing Quil programs, based on Rigetti Computing's pyQuil package.

Make a list of instructions to run on a hybrid computer with both qubits and classical registers, and then use the measure instruction to store a qubit value onto a classical register.

You can then return the value of these classical registers on each run of your program.

Want more JS and Quantum Computers?

Upgrade to Quantum Peep

Multi-platform, async quantum computing library written in TypeScript

Sample code

Tests based on the example code in pyQuil

import { gates, inits, operations, Program, QVM, Connection } from 'jsquil'

// request API credentials from http://rigetti.com/forest
let c = new Connection({
  user_id: 'USER_ID',
  api_key: 'API_KEY'
});

// connection for QVM Docker container (which I host)
let c2 = new Connection({
  user_id: 'USER_ID',
  api_key: 'API_KEY'
}, 'http://165.227.62.245:5000');

let q = new QVM(c2);

let p = new Program();
// put an X gate on the zeroth qubit
p.inst(gates.X(0));

// store the zeroth qubit's value in the first classical register
p.measure(0, 1);

// p now contains Quil instructions, which look like this:
// p.code()
// >  DECLARE ro BIT[2]
// >  X 0
// >  MEASURE 0 ro[1]

// run the program twice, returning classical registers from each iteration
q.run(p, 2, (err, returns) => {
  // err = null
  // returns = [[1], [1]]
});

Changing the run command to execute a program ten times:

q.run(p, 10, (err, returns) => { });

Two ways to write a series of gate commands:

p.inst(gates.X(0), gates.Y(1), gates.Z(0));
// same as
p.inst(gates.X(0));
p.inst(gates.Y(1));
p.inst(gates.Z(0));

p.code();
> "X 0\nY 1\nZ 0\n"

Quantum Fourier Transform:

p.inst(
  gates.H(2),
  gates.CPHASE(Math.PI / 2, 1, 2),
  gates.H(1),
  gates.CPHASE(Math.PI / 4, 0, 2),
  gates.CPHASE(Math.PI / 2, 0, 1),
  gates.H(0),
  gates.SWAP(0, 2)
);

Initializing a classical register value

p.inst( inits.TRUE(0) );

Operations on classical registers

p.inst(operations.EXCHANGE(0, 1));
// others: NOT, AND, OR, MOVE

Reset, wait, and halt commands:

p.reset();
p.wait();
p.halt();

Looping some instructions while a classical register value is TRUE

let classical_register = 2;
let loop_program = new Program();
loop_program.inst(gates.X(0), gates.H(0));
loop_program.measure(0, classical_register);
p.while_do(classical_register, loop_program);

An if-then-else statement combines multiple program objects and chooses one based on a classical register bit value

let then_branch = new Program();
...
let else_branch = new Program();
...
p.if_then(test_register, then_branch, else_branch);

Adding gate and measurement noise to the QVM, to simulate a quantum computer

let gate_noise = [x, y, z];
let measure_noise = [0.2, 0, 0];
let q = new QVM(connection, gate_noise, measure_noise);

Endpoints

If the endpoint changes:

let c = new Connection({
  user_id: 'USER_ID',
  api_key: 'API_KEY'
}, 'https://endpoint.example.com');

Tests

npm install mocha -g
npm test

License

Apache license (same as pyQuil)

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].