npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

quantum-peep

v3.2.3

Published

Quantum computer programming

Downloads

14

Readme

Quantum-Peep

Greenkeeper badge

Work in progress - build quantum programs that are platform-agnostic - compile for IBM's QASM, Rigetti's Quil, Microsoft's Q#, or Google's Cirq.

Example code

import { Gates, Program, RigettiProcessor, IBMProcessor } from 'quantum-peep';

// write your quantum gates and measurements into a program
let p = new Program();
p.add(Gates.X(1));
p.measure(1, 2);

// get Microsoft's Q# code
p.code('q#');

// get Python code for Google Cirq
p.code('cirq');

// run on Rigetti QVM Docker container
// You can use my server here (does not receive API key or User ID credentials)
// For actual QPUs, register for Rigetti Forest and use their endpoint, api_key, and user_id
let q = new RigettiProcessor({
  endpoint: 'http://167.99.232.33:5000',
  api_key: 'aaa',
  user_id: 'uuu'
});
let runTimes = 10;
q.run(p, runTimes, (body) => {
  console.log(JSON.parse(body));
});

// fetch device options + status from https://forest-server.qcs.rigetti.com/devices
q.devices((deviceInfo) => {
  // { "Aspen-4": { "is_online": false, ... }, "Aspen-3": { ... } }
});

// run on IBM quantum chip
let q2 = new IBMProcessor({
  login: secrets.ibm.token,
  processor: 'ibmqx4'
});
// fetch device options + status from https://quantumexperience.ng.bluemix.net/api/Backends/ibmqx4
// uses given processor type
q2.devices((deviceInfo) => {
  // { "id": "ibmqx4", "status": "on", ... }
});
q2.run(p, runTimes, (body) => {
  console.log(JSON.parse(body));
});

More complex gates

// gate names from different platforms are equivalent
Gates.CNOT(control, target);
Gates.CX(control, target);

// swap operations
Gates.SWAP(qubit1, qubit2);
Gates.CSWAP(conditional, qubit1, qubit2);
// ISWAP and PSWAP are only one-step operations in Quil? Advice welcome

// phase gates: phase is a radian value
// use this shorthand to express on several different platforms

import { pi_multipled_by, pi_divided_by } from 'quantum-peep';
Gates.RX(pi_multiplied_by(0.45), qubit1);
Gates.RY(pi_divided_by(2), qubit2);

Bonus features

Output a circuit diagram with this library ported from QISKit Python: https://github.com/mapmeld/quantum-circuit-viz

import { textViz } from 'quantum-circuit-viz';
...
program.add(Gates.X(1));
program.measure(1, 2);
textViz(program);
        ┌───┐┌─┐
q_1: |0>┤ X ├┤M├
        └───┘└╥┘
 c_2: 0 ══════╩═

Goals

  • work with experimental results from APIs
  • more complex conditional / GOTO output in assembly languages
  • async/queue support: for newer APIs which put programs in a queue
  • browser JS distribution: easier use in web apps

Language references

IBM's QISkit (for Python and JS) compile to OpenQASM: https://github.com/Qiskit/openqasm and Cloud reference: https://github.com/Qiskit/qiskit-js/tree/master/packages/qiskit-cloud

Rigetti's pyQuil (and the previous jsQuil project) compile to Quil: http://docs.rigetti.com/en/stable/compiler.html

Microsoft Q# https://docs.microsoft.com/en-us/quantum/language/?view=qsharp-preview

Google Cirq https://github.com/quantumlib/Cirq

License

Open source, MIT license