Quantum Peep

Cross-platform JavaScript module for gate-based quantum computing

npm install quantum-peep
View GitHub

Write once

A quantum algorithm starts out with a small number of qubits, which then have their state modified or interact with each other through quantum logic gates.

Here, we use an X gate and a CNOT gate, measure qubit values, and store each value in classical registers.

let p = new Program();
p.add(Gates.X(0));
p.add(Gates.CNOT(0, 1));
p.measure(0, 1);
p.measure(1, 2);

Run anywhere

Programs can be output using IBM's QASM, Rigetti's Quil, Microsoft's Q#, and Google's Cirq syntax.

s = Gates.S(1);
s.dagger();
s.code('quil')
> 'DAGGER S 1'
s.code('q#')
> 'Adjoint S(1);'
s.code('qasm')
> 'sdg q[1];'

When platforms differ on names or shorthand for a gate, there are multiple aliases with identical outputs.

sdag = Gates.SDAG(1);
sdag.code('q#')
> 'Adjoint S(1);'

Real quantum chips

Quantum-Peep helps send jobs to IBM's and Rigetti's cloud computing services with an easy-to-understand syntax:

let q = new RigettiProcessor({
  api_key: 'aaa', user_id: 'uuu',
  endpoint: 'http://167.99.232.33:5000' });
let runTimes = 10;
q.run(pcode, runTimes, (body) => {
  console.log(body);
});

The given endpoint is a virtual machine for immediate testing. IBM's returns a Task ID which is queued to run on a quantum chip.

Open source

Quantum-Peep is written in TypeScript and is released under an MIT license