Skip to content

Commit

Permalink
Updating theory
Browse files Browse the repository at this point in the history
  • Loading branch information
WrathfulSpatula committed Apr 2, 2018
1 parent 6e9fdf2 commit b6134f7
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
2 changes: 1 addition & 1 deletion docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ Introduction

Qrack is a C++ quantum bit simulator, with the ability to support arbitrary numbers of entangled qubits - up to system limitations. Suitable for embedding in other projects, the :cpp:class:`Qrack::CoherentUnit` contains a full and performant collection of standard quantum gates, as well as variations suitable for register operations and arbitrary rotations.

As a demonstration of the :cpp:class:`Qrack::CoherentUnit` implementation, a MOS-6502 microprocessor [MOS-6502]_ virtual machine has been modified with a set of new opcodes supporting quantum operations. The `vm6502q <https://github.com/vm6502q/vm6502q>`_ virtual machine exposes new integrated quantum opcodes such as a Grover Search [Grover]_ across a page of memory. These programs are demonstrated in the `examples <https://github.com/vm6502q/examples>`_ repository.
As a demonstration of the :cpp:class:`Qrack::CoherentUnit` implementation, a MOS-6502 microprocessor [MOS-6502]_ virtual machine has been modified with a set of new opcodes supporting quantum operations. The `vm6502q <https://github.com/vm6502q/vm6502q>`_ virtual machine exposes new integrated quantum opcodes such as Hadamard transforms and an X-indexed LDA, with the X register in superposition, across a page of memory. An assembly example of a Grover's search with a simple oracle function is demonstrated in the <https://github.com/vm6502q/examples>`_ repository.

Finally, a `6502 toolchain <https://github.com/vm6502q/cc65>`_ - based on CC65 `CC65 <http://cc65.github.io/doc/>`_ - has been modified and enhanced to support both the new opcodes - for the assembler - as well as :ref:`c-syntax-enhancements-ref`. This is performed primarily as sandbox/exploratory work to help clarify what quantum computational software engineering might look like as the hardware reaches commoditization.

Expand Down
23 changes: 20 additions & 3 deletions docs/theory.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ Quantum Computational Basics
.. [Susskind] `Modern Physics: Quantum Mechanics, by Dr. Leonard Susskind <https://www.youtube.com/watch?v=2h1E3YJMKfA>`_
.. [WiredSummary] `Wired's Overview of the Industry <https://www.wired.com/story/the-era-of-quantum-computing-is-here-outlook-cloudy/>`_
.. [AlgoZoo] `Quantum Algorithm Zoo <https://math.nist.gov/quantum/zoo/>`_
.. [QC10th] `Quantum Computing 10th Edition - Nielson and Chung <http://www-reynal.ensea.fr/docs/iq/QC10th.pdf>`_
.. [QC10th] `Quantum Computing 10th Edition - Nielson and Chuang <http://www-reynal.ensea.fr/docs/iq/QC10th.pdf>`_
.. [QAVLA] `Quantum Algorithms via Linear Algebra: A Primer - Lipton and Regan <http://mmrc.amss.cas.cn/tlb/201702/W020170224608149911380.pdf>`_
Grover Search Algorithm
~~~~~~~~~~~~~~~~~~~~~~~
Expand Down Expand Up @@ -42,9 +43,25 @@ By collecting :math:`x_n` into a complex number array (called :cpp:member:`Qrack
std::unique_ptr<Complex16[]> sv(new Complex16[1 << qBitCount]);
The :cpp:func:`Qrack::CoherentUnit::Apply2x2()` method applies a :math:`2\times2` matrix against the complex number, for example from an :cpp:func:`Qrack::CoherentUnit::X()` gate.
The :cpp:func:`Qrack::CoherentUnit::Apply2x2()` method applies a :math:`2\times2` matrix against the state vector, for example from an :cpp:func:`Qrack::CoherentUnit::X()` gate. If we apply a gate only to the second bit, then the :math:`2\times2` matrix operation is acted in parallel pairings of all states where all bits are the same except for the second bit. Pairs of states where all bits are the same, except the second bit pairs values of `0` and `1`, can be independently acted on by the :math:`2\times2` matrix in parallel. For example, for two bits, acting on the right-hand bit, the pairings would be :math:`\rvert00\rangle` with :math:`\rvert01\rangle`, and :math:`\rvert10\rangle` with :math:`\rvert11\rangle`. Uninvolved bits are held the same and iterated over, while the bit acted upon is drawn into pairs `0` and `1`. This gives a set of sub-state vectors with only two components, which can be multiplied by the :math:`2\times2` matrix.

.. TODO: Add additional commentary breaking apart how Apply2x2 works, and what it iterates over.
Extending to register-like operations, say we want to apply a bitwise ``NOT`` or ``X`` operation on the right-hand register of 8 bits. We simply apply the ``NOT`` operation simultaneously on all of the right-hand bits in all entangled input states.

Say we have a `Qrack::CoherentUnit` called `qReg` with the following initial state:

.. math:: \rvert\psi_0\rangle = \frac{1}{\sqrt{2}} \rvert(01010101)\ (11111110)\rangle - \frac{1}{\sqrt{2}} \rvert(10101010)\ (00000000)\rangle

We act the ``X`` operation on the right-hand 8 bits:

.. code-block:: cpp
qReg->X(8, 8);
This is like acting a ``NOT`` operation on the right-hand 8 bits in every superposed state, in parallel:

.. math:: \rvert\psi_1\rangle = \frac{1}{\sqrt{2}} \rvert(01010101)\ (00000001)\rangle - \frac{1}{\sqrt{2}} \rvert(10101010)\ (11111111)\rangle

This is again an "embarrassingly parallel" operation. Some bits are completely uninvolved and these bits are passed unchanged in each state from input to output. Bits acted on by the register operation have a one-to-one mapping between input and states. This can all be handled through transformation via bit masks on the input state permutation index. Register-like methods generally all use bitmasks to separate involved bits from uninvolved bits, transform the involved bits like above, and use the bit transformation to map state vector coefficients to new positions in the vector, in a unitary manner. (Note that the operation amounts to swapping coefficients in correspondence with the bitmask transforms, not directly acting bitwise operations on the raw representation of the state itself. The state is represented as a set of double precision complex coeffecients, not bits.)


6502 Reference Documents
Expand Down

0 comments on commit b6134f7

Please sign in to comment.