https://github.com/kraks/quantum-compiler
Quantum circuits compiler with staging and continuations
https://github.com/kraks/quantum-compiler
compiler continuation-passing-style continuations multi-stage-programming quantum-circuit-simulator quantum-compiler quantum-computing quantum-programming-language staging
Last synced: 4 months ago
JSON representation
Quantum circuits compiler with staging and continuations
- Host: GitHub
- URL: https://github.com/kraks/quantum-compiler
- Owner: Kraks
- Created: 2023-03-13T02:59:50.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2024-11-19T22:37:46.000Z (about 1 year ago)
- Last Synced: 2025-01-31T09:05:24.408Z (about 1 year ago)
- Topics: compiler, continuation-passing-style, continuations, multi-stage-programming, quantum-circuit-simulator, quantum-compiler, quantum-computing, quantum-programming-language, staging
- Language: Scala
- Homepage:
- Size: 112 KB
- Stars: 15
- Watchers: 4
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# 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](https://andykeep.com/SchemeWorkshop2022/scheme2022-final37.pdf) 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](https://github.com/TiarkRompf/lms-clean)) 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](https://en.wikipedia.org/wiki/Simon%27s_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⟩
```