Coder Social home page Coder Social logo

kraks / quantum-compiler Goto Github PK

View Code? Open in Web Editor NEW
11.0 4.0 0.0 111 KB

Quantum circuits compiler with staging and continuations

Scala 100.00%
compiler continuation-passing-style continuations multi-stage-programming quantum-circuit-simulator quantum-compiler quantum-computing quantum-programming-language staging

quantum-compiler's Introduction

Quantum Circuits Compiler with Staging

This repository contains various experimental quantum circuit evaluators and compilers. They take a Toffoli-Hadamard quantum circuit as input, and simulates the probability amplitudes of all possible outcomes.

  • The directory src/main/scala/feynman contains various Feynman-style simulators implemented using continuations.

    • QContSim1.scala contains a pure implementation and uses delimited continuations shift/reset (following the Quantum Continuation paper).
    • QContSim2.scala implements an evaluator written in CPS and uses side-effect to perform path summarization.
    • QCompilerCPS.scala is a staged CPS evaluator (written with Lightweight Modular Staging) that can generate C code for simulation.
  • The directory src/main/scala/schrodinger contains various Schrodinger-style simulators implemented with linear algebra computation.

    • Schrodinger.scala is an unstaged implementation.
    • StagedSchrodinger.scala is a staged implementation that specializes over static gate matrices.

Example

To see an example of the compiler in action, run the following command in sbt:

sbt:quantum-lms-compiler> runMain quantum.feynman.staged.TestQC

This will take the circuit for the Simon problem as input and execute the generated C program snippet.cpp. The C program is compiled with g++ -std=c++20 -O3. Running the generated program prints all states and their probability amplitudes:

0.5|0000⟩
0.5|0011⟩
0.5|1100⟩
-0.5|1111⟩

quantum-compiler's People

Contributors

kirshanthans avatar kraks avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

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.