Git Product home page Git Product logo

microqiskit's Introduction

MicroQiskit

Qiskit is the well-developed and most feature-rich framework for quantum computing. It allows quantum programs to be created, and then run on either advanced simulator or real prototype quantum devices. Though its obviously a good thing to have many features and support many use-cases, it can sometimes be too much of a good thing!

For this reason we have created MicroQiskit: the smallest and most feature-poor framework for quantum computing. It has all the basic features and only the basic features. Making it much easier to learn, and much easier to get running.

MicroQiskit was initially conceived as a version of Qiskit that could run on microcontroller devices. The strict need for simplicity and a lack of complex dependencies was the main design constraint.

We are now in the process of porting MicroQiskit to other languages. In this regard it serves as a trial version of Qiskit, allowing new users to try it out before they buy into the Python ecosystem. It is not recommended for long-term use, since there is so much that can only be done using the standard version. For this reason, the ports will all allow you to export your quantum jobs in Python-compatible code.

MicroQiskit is written to be as compatible with Qiskit as possible. Learning quantum programming with MicroQiskit is therefore a way to get started with Qiskit. And getting to know Qiskit is a great way to get started with MicroQiskit.

Documentation

Tutorial

Installation

Installation guides for the various versions of MicroQiskit can be found in the corresponding README files.

Template Version

The microqiskit.py file found in this folder is intended as a template version. It contains comments to explain how each part of MicroQiskit works, both to aid understanding and to help in the writing of ports. The MicroPython version is directly constructed from this template.

Differences with Qiskit

Available gates

Quantum gates are added to circuits in MicroQiskit in the same way as in Qiskit. The main difference is that only the gates x, y, z, h, cx, rx, ry and rz can be added to a circuit in MicroQiskit. All others can be created if and when required from this basic set.

During simulation, or when exporting the circuit in a Python-compatible form, it is compiled into the set consisting only of x, h, cx and rx.

Running Circuits

In Qiskit, the way circuits are run must account for the many different possible backends, including various simulators as well as prototype quantum devices. In MicroQiskit, there is only one simulator. As such, the process is reduced to either a single simulate function or a single Simulator class, depending on language. These functions and classes are not present in Qiskit.

microqiskit's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

microqiskit's Issues

Ruby Implementation

Just noting that I have a mostly finished Ruby implementation so other contributors are aware

draw() function

This little function can draw a circuit. I made this a few months ago for the project in the qiskit mentorship program. Not sure if this should be included in microqiskit, but I'm leaving it here, hope someone find this useful.

def draw(self):
  stave = [f"#q{i}" for i in range(self.num_qubits)]

  for gate in self.data:
    if gate[0] == "cx":
      mxlen = max([len(line) for line in stave])
      stave[gate[1]] += ("-" * (mxlen - len(stave[gate[1]]))
                         + ("--" if stave[gate[2]][-2] == "R" else "---") + "*")
      stave[gate[2]] += ("-" * (mxlen - len(stave[gate[2]]))
                         + ("--" if stave[gate[2]][-2] == "R" else "---") + "C")

      for i in range(gate[1] + 1, gate[2]):
        stave[i] += "-" * (mxlen - len(stave[i])) + "---|"

    elif gate[0][0] == "r":
      stave[gate[2]] += ("--" if stave[gate[2]][-2] == "R" else "---") + gate[0].upper()

    else:
      stave[gate[1]] += ("--" if stave[gate[1]][-2] == "R" else "---") + gate[0][0].upper()


  # Auto-measure
  # for l in range(len(stave)):
  #   stave[l] += "-" * (max([len(line) for line in stave]) - len(stave[l])) + "-/m"


  mxlen = max([len(line) for line in stave])
  print("=" * (mxlen + 3))
  for qubit in stave:
    print(qubit)
  print("=" * (mxlen + 3))

Noise-resistant checkerboard

Use this form to contribute the function you created for the Single Qubit Hackathon.

You were challenged to create a new function to procedural generate terrain. Replace the code block below with the function you want to contribute.

# define a function that determines a brightness for any given point
# uses a seed that is a list of four numbers
def get_brightness(x,y,qc,seed):
    qc.data.clear() # empty the circuit
    
    # perform rotations whose angles depend on x and y
    qc.rx( x * pi/seed[0], 0 )
    qc.ry( y * pi/seed[1], 0 )

    # calculate probability for outcome 1
    qc.measure(0,0)
    p = simulate(qc,shots=1000,get='counts')['1']/1000
    # return brightness depending on this probability
    # the chosen values here are fairly arbitrary
    if p>0.7:
        if p<0.8:
            return 1
        elif p<0.9:
            return 2
        else:
            return 3
    else:
        return 0

Describe the type of terrain your function creates
This always creates a checkerboard-like pattern regardless of the users' XY button input, despite the fact there is a random rotation in both axes.

List the contributors

License

Please delete as appropriate to show whether you agree to your contribution being licensed under the Apache 2.0 License and the Qiskit Contribution License Agreement.

I agree

Swift implementation

I have started a Swift implementation for iOS/macOS and have solicited other advocates for collaboration. Just noting it here so other contributors are aware.

Duplicate test_multiqubit()

test_multiqubit is duplicated twice (with minor differences) and the first function has unused variables that leave it doing nothing more than the second.

The first function

def test_multiqubit():
    qc = QuantumCircuit(7,7)
    qc.h(0)
    qc.cx(0,2)
    qc.cx(2,1)
    qc.h(5)
    qc.cx(5,3)
    qc.cx(3,4)
    qc.cx(3,6)
    ket = simulate(qc,get='statevector')
    check = True
    for string in ['0000000','0000111','1111000','1111111']:
        check = check and round(ket[int(string,2)][0],2)==0.50
    assert( check )
    for j in range(7):
        qc.measure(j,j)
    for get in ['counts','probabilities_dict']:
        counts  = simulate(qc,shots=shots,get='counts')
        check = True
        for string in ['0000000','0000111','1111000','1111111']:
            p = counts[string]/shots
            check = check and round(p,2)==0.25
        assert( check )

Second function

def test_multiqubit():
    qc = QuantumCircuit(7,7)
    qc.h(0)
    qc.cx(0,2)
    qc.cx(2,1)
    qc.h(5)
    qc.cx(5,3)
    qc.cx(3,4)
    qc.cx(3,6)
    ket = simulate(qc,get='statevector')
    check = True
    for string in ['0000000','0000111','1111000','1111111']:
        check = check and round(ket[int(string,2)][0],2)==0.50
    assert( check )
    for j in range(7):
        qc.measure(j,j)
    counts  = simulate(qc,shots=shots,get='counts')
    check = True
    for string in ['0000000','0000111','1111000','1111111']:
        p = float(counts[string])/shots
        check = check and round(p,2)==0.25
    assert( check )

Align ports with changes

Changes were made in PR #9.

Specifically

  • Add .name attribute to QuantumCircuit.
  • Rename expected_counts to probabilities_dict

Kotlin implementation

Hello, community!
I've just started to build Kotlin implementation of MicroQiskit for the future plans to play around with it on Android devices. Hope to make a PR in a couple of weeks

cannot get state content when use `simulate(qc,get='counts')`

  1. description of issue: (this is for microqiskit.py file) cannot get state content when use simulate(qc,get='counts') (using others such as probabilities_dict are fine)
  2. python environment: 3.9.4 in jupyter notebook
  3. example code to reproduce this issue:
import microqiskit as mq
myqc = mq.QuantumCircuit(3,3)
myqc.h(1)
myqc.h(2)
res = mq.simulate(myqc,shots=16,get='counts')
print(res)

I am expecting to see
{'000': 4,'010': 4,
'100': 4,'110': 4,
'001': 0,'011': 0,
'101': 0,'111': 0,}

but instead I get

{'000': 16}

Rust implementation

Hi, I've started developing MicroQiskit in Rust which I should finish reasonably soon. I have a question concerning the distribution: most rust libraries are published as crates (like packages in python) on crates.io, making it very easy to add dependencies to a project. Should I implement MicroQiskit as a crate or as just a single file that users can then import? The package route would only generate two additional TOML files.

However, placing it on crates.io means that either I would host a separate GitHub repo with the source, or the owner of this repo would log in to crates.io using GitHub and add the crate as a subdirectory of this repo - ensuring any future changes to the code are reflected on crates.io.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.