All Projects → cduck → feynman_path

cduck / feynman_path

Licence: MIT license
Visualization tool for the Feynman Path Integral applied to quantum circuits

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to feynman path

Qml
Introductions to key concepts in quantum machine learning, as well as tutorials and implementations from cutting-edge QML research.
Stars: ✭ 174 (+427.27%)
Mutual labels:  quantum-computing
YaoBase.jl
Abstract type and interface definition for quantum circuit blocks.
Stars: ✭ 17 (-48.48%)
Mutual labels:  quantum-computing
QCompress-1
Quantum Autoencoder Implementation using Forest and OpenFermion
Stars: ✭ 20 (-39.39%)
Mutual labels:  quantum-computing
Awesome Quantum Ml
Curated list of awesome papers and resources in quantum machine learning
Stars: ✭ 190 (+475.76%)
Mutual labels:  quantum-computing
MPPIController
Robot Controls Course Project
Stars: ✭ 28 (-15.15%)
Mutual labels:  path-integral
New-ML-Data-Science-Framework-Tutorials-By-EJ
Internet's Most Popular Tutorials on Fresh-off-the-shelf ML & Data Science Technologies, Authored by Yours Truly.
Stars: ✭ 18 (-45.45%)
Mutual labels:  quantum-computing
Pytket
Python module for interfacing with the CQC t|ket> library of quantum software
Stars: ✭ 162 (+390.91%)
Mutual labels:  quantum-computing
qc portfolio optimization
A program that implements the portfolio optimization experiments using a hybrid quantum computing algorithm from arXiv:1911.05296. The code was developed as part of the 2020 Quantum mentorship program. Many thanks to my mentor Guoming Wang from Zapata Computing!
Stars: ✭ 21 (-36.36%)
Mutual labels:  quantum-computing
sqaod
Solvers/annealers for simulated quantum annealing on CPU and CUDA(NVIDIA GPU).
Stars: ✭ 66 (+100%)
Mutual labels:  quantum-computing
QuantumInformation.jl
A Julia package for numerical computation in quantum information theory
Stars: ✭ 81 (+145.45%)
Mutual labels:  quantum-computing
Qulacs
Variational Quantum Circuit Simulator for Quantum Computation Research
Stars: ✭ 192 (+481.82%)
Mutual labels:  quantum-computing
Artiq
A leading-edge control system for quantum information experiments
Stars: ✭ 245 (+642.42%)
Mutual labels:  quantum-computing
qcec
MQT QCEC - A tool for Quantum Circuit Equivalence Checking
Stars: ✭ 64 (+93.94%)
Mutual labels:  quantum-computing
Qsim
Schrödinger and Schrödinger-Feynman simulators for quantum circuits.
Stars: ✭ 190 (+475.76%)
Mutual labels:  quantum-computing
Qu.js
Quantum Computing for Humans!
Stars: ✭ 15 (-54.55%)
Mutual labels:  quantum-computing
Quimb
A python library for quantum information and many-body calculations including tensor networks.
Stars: ✭ 170 (+415.15%)
Mutual labels:  quantum-computing
tket
Source code for the TKET quantum compiler, Python bindings and utilities
Stars: ✭ 172 (+421.21%)
Mutual labels:  quantum-computing
public research
Publicly available research done by BOHR.TECHNOLOGY.
Stars: ✭ 16 (-51.52%)
Mutual labels:  quantum-computing
QuAlgorithmZoo.jl
A curated implementation of quantum algorithms with Yao.jl
Stars: ✭ 78 (+136.36%)
Mutual labels:  quantum-computing
QSimulator.jl
Unitary and Lindbladian evolution in Julia
Stars: ✭ 19 (-42.42%)
Mutual labels:  quantum-computing

Feynman Path Sum Diagram for Quantum Circuits

A visualization tool for the Feynman Path Sum applied to quantum circuits. The path integral formulation is an interpretation of quantum mechanics that can aid in understanding superposition and interference.

Path sum:

Circuit diagram:

How to read a path sum diagram:

  • Time flows from left to right as gates are executed on qubits.
  • Arrows transition from one state to another and traversing the arrows gives a path to an output.
  • Two diverging arrows indicate a split into two potential outcomes.
  • An orange arrow indicates a negative sign is added to that outcome.
  • When two arrows converge, the amplitudes are summed.
  • Quantum interference is when positive and negative amplitudes cancel in this sum.
  • The rightmost column lists the possible measurement outcomes along with the final probability amplitudes of measuring each outcome.

See also: Bloch sphere visualization

Install

feynman_path is available on PyPI:

python3 -m pip install feynman_path

Prerequisites

Several non-python tools are used to generate the graphics and various output formats. These non-python dependencies are listed below and platform-specific installation instructions can be found here.

  • LaTeX: A distribution of LaTeX that provides the pdflatex command needs to be installed separately. Used to generate the gate and state labels.
  • pdf2svg: Used to convert the LaTeX expressions into SVG elements.
  • Inkscape (optional): Only required to convert the output to PDF format.
  • Cairo (optional): Only required to convert the output to PNG format.

Ubuntu

sudo apt install texlive pdf2svg inkscape libcairo2  # Or texlive-latex-recommended, or texlive-latex-extra

macOS

Using homebrew:

brew install --cask mactex inkscape
brew install pdf2svg cairo

Usage

This package provides a command line tool to generate diagrams.

Examples

feynman_path interference 2 h0 cnot0,1 z1 h0 h1 cnot1,0 h1

feynman_path interference 2 h0 cnot0,1 z1 h0 h1 cnot1,0 h1 --circuit

Command line options

$ feynman_path -h
usage: feynman_path [-h] [--svg] [--png] [--pdf] [--sequence] [--circuit]
                    [--scale SCALE] [--verbose]
                    name n_qubits gate [gate ...]

Renders a Feynman path sum diagram for a sequence of quantum gates.

positional arguments:
  name           The file name to save (excluding file extension)
  n_qubits       The number of qubits in the quantum circuit
  gate           List of gates to apply (e.g. h0 z1 cnot0,1)

optional arguments:
  -h, --help     show this help message and exit
  --svg          Save diagram as an SVG image (default)
  --png          Save diagram as a PNG image
  --pdf          Save diagram as a PDF document
  --sequence     Save a sequence of images that build up the diagram from left
                 to right as <name>-nn.svg/png/pdf
  --circuit      Save a standard quantum circuit diagram named
                 <name>-circuit.svg/png/pdf instead of a Feynman path diagram
  --scale SCALE  Scales the resolution of the diagram when saved as a PNG
  --verbose      Print extra progress information

Python Package

feynman_path also provides a Python 3 package as an alternative to the command line tool. Diagrams can be viewed directly in a Jupyter notebook or saved.

import feynman_path

n_qubits = 3
font = 12
ws_label = 4+0.55*n_qubits  # Label width relative to font size
w_time = 60+ws_label*font  # Diagram column width
f = feynman_path.Diagram(
    n_qubits, font=font, ws_label=ws_label, w_time=w_time)

f.perform_h(0)
f.perform_cnot(0, 1)
f.perform_z(1)
f.perform_cnot(1, 2, pre_latex=r'\color{red!80!black}')
f.perform_h(0)
f.perform_h(1)
f.perform_cnot(1, 0)

f.draw()  # Display in Jupyter
f.draw().saveSvg('output.svg')  # Save SVG
f.draw().setPixelScale(2).savePng('output.png')  # Save PNG
import latextools
latextools.svg_to_pdf(f.draw()).save('output.pdf')  # Save PDF

See examples/render_examples.py for more example code.

Examples

Using the CNOT gate to entangle qubits

The CNOT gate (⋅–⨁) can be used to entangle two qubits, creating a Bell pair, but for certain input qubit states, the CNOT will have no effect.

Create a Bell pair by using a CNOT on the |+0⟩ state (q0=|+⟩, q1=|0⟩):

Note the output (rightmost) column is an entangled state: |00⟩+|11⟩

feynman_path no-entanglement 2 h0 cnot0,1 h0 h1

Fail to create a bell pair by using a CNOT on the |++⟩ state (q0=|+⟩, q1=|+⟩):

feynman_path no-entanglement 2 h0 h1 cnot0,1 h0 h1

Note the output (rightmost) column is a separable state: |00⟩

Copying an intermediate qubit state onto an ancilla ruins interference

In classical computing, it is common to inspect intermediate steps of a computation. This can be very useful for debugging. In quantum computing however, this destroys the effect of interference. We can use a CNOT gate (⋅–⨁) to copy an intermediate value onto another qubit to inspect later. Shown below, copying the intermediate value of q1 to q2 changes the output of q0, q1.

Original circuit that compute the output q0=1, q1=0:

feynman_path interference 2 h0 cnot0,1 z1 h0 h1 cnot1,0 h1

The addition of CNOT1,2 to inspect the intermediate value of q1 changes the output of q0:

Note how the path diagram is the same except the arrows at H1 are now split into the upper and lower halves of the diagram and don't interfere anymore.

feynman_path no-interference 3 h0 cnot0,1 z1 cnot1,2 h0 h1 cnot1,0 h1
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].