Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
97 commits
Select commit Hold shift + click to select a range
24d0cbf
ProjectQ v0.4.1
damiansteiger Aug 26, 2018
dff2082
Adding Qrack simulator
WrathfulSpatula Nov 2, 2018
4431fb3
Simplifying QrackSimulator
WrathfulSpatula Nov 2, 2018
21c4590
Debugging Qrack simulator
WrathfulSpatula Nov 2, 2018
9c65f61
Debugging QrackSimulator
WrathfulSpatula Nov 2, 2018
bf11cff
is_available for no-matrix gates
WrathfulSpatula Nov 2, 2018
8025fe4
Debugging cheat
WrathfulSpatula Nov 3, 2018
31a9e03
Debugging set_wavefunction
WrathfulSpatula Nov 3, 2018
2b46b89
Debugging mapper
WrathfulSpatula Nov 3, 2018
4ba337c
QUnit
WrathfulSpatula Nov 3, 2018
a52e7d5
Debugging amplitude return type
WrathfulSpatula Nov 4, 2018
d804247
Working Qrack unit tests
WrathfulSpatula Nov 5, 2018
bd163f4
Addition gates
WrathfulSpatula Nov 6, 2018
3ad0943
Debugging Qrack math
WrathfulSpatula Nov 6, 2018
74fb0d8
Qrack multiply and divide
WrathfulSpatula Nov 8, 2018
fda27bb
Mul/div is_availabledebugging
WrathfulSpatula Nov 8, 2018
b0a2a7e
Mul/div is_available debugging
WrathfulSpatula Nov 8, 2018
da50581
Setup options and docs
WrathfulSpatula Nov 8, 2018
9c6989f
Docs debugging and directory restructure
WrathfulSpatula Nov 8, 2018
7e6e9ea
Fixing Qrack path
WrathfulSpatula Nov 8, 2018
ef1e794
Debugging qracksim tests
WrathfulSpatula Nov 8, 2018
4f1f0b9
Support systems without OpenCL
Nov 10, 2018
f1c6782
First of several required fixes to the python test code
Nov 10, 2018
3f0cf3f
Merge pull request #1 from bennbollay/qrack_simulator
WrathfulSpatula Nov 10, 2018
55516cc
Support for non-OpenCL QUnit fallback
WrathfulSpatula Nov 10, 2018
35c90c5
All OpenCL Qrack pytests pass
WrathfulSpatula Nov 10, 2018
900b3f1
Removing pytest settings.json
WrathfulSpatula Nov 10, 2018
8f5ec3c
Skip tests if not --with-qracksimulator
WrathfulSpatula Nov 10, 2018
515360f
Testing Travis --with-qracksimulator
WrathfulSpatula Nov 10, 2018
c2e3be6
Testing Travis --with-qracksimulator
WrathfulSpatula Nov 10, 2018
3d1dfef
Merge branch 'develop' into qrack_simulator
WrathfulSpatula Nov 10, 2018
3fdf41a
Moving Travis Qrack folder
WrathfulSpatula Nov 10, 2018
15b3f32
Coverage
WrathfulSpatula Nov 11, 2018
733bda5
Coverage
WrathfulSpatula Nov 11, 2018
7089b52
Coverage
WrathfulSpatula Nov 11, 2018
8eb1b29
Coverage
WrathfulSpatula Nov 11, 2018
dd391f7
Coverage
WrathfulSpatula Nov 11, 2018
217547b
Flipping reversed amplitudes (bug was fixed in Qrack)
WrathfulSpatula Nov 11, 2018
49ddc70
Adding 'QFusion' intermediate gate fusion layer
WrathfulSpatula Nov 18, 2018
62e5b33
QUnit Cohere peer relationship, for Qrack PR
WrathfulSpatula Jan 5, 2019
78d8c41
Removing extraneous generated file from versioning
WrathfulSpatula Jan 8, 2019
11ade5c
Merge pull request #2 from WrathfulSpatula/qrack_accuracy_branch
WrathfulSpatula Jan 8, 2019
54e0cf2
Merge branch 'develop' into qrack_simulator
WrathfulSpatula Jan 8, 2019
442c572
\d read as invalid escape sequence
WrathfulSpatula Jan 8, 2019
096f1bb
\d read as invalid escape sequence
WrathfulSpatula Jan 8, 2019
9c043e1
'Cohere' becomes 'Compose'
WrathfulSpatula Jan 10, 2019
769d787
Merge pull request #3 from WrathfulSpatula/cohere_compose_naming
WrathfulSpatula Jan 11, 2019
c1402cf
Merge branch 'develop' into qrack_simulator
WrathfulSpatula Jan 11, 2019
010ccf3
Merge branch 'develop' into qrack_simulator
WrathfulSpatula Jan 12, 2019
aeaf392
Separating QrackSimulator files/directory
WrathfulSpatula Jan 12, 2019
a0266e9
Optional Qrack Simulator build supersedes default simulator
WrathfulSpatula Jan 12, 2019
04075e1
Changing constant math tests
WrathfulSpatula Jan 12, 2019
c6ec756
Fixing CI directory
WrathfulSpatula Jan 12, 2019
f74704b
Fixing CI directory
WrathfulSpatula Jan 12, 2019
815d586
Testing constant math CI failure (doesn't reproduce on local machine)
WrathfulSpatula Jan 12, 2019
d8b6416
Widening float equality tolerances, where reasonable
WrathfulSpatula Jan 12, 2019
e74ca15
Qrack skips time evolution tests
WrathfulSpatula Jan 12, 2019
7694161
Qrack skips unsupported operations tests
WrathfulSpatula Jan 12, 2019
14919c7
Conditionally remove low_level_gates filter from test
WrathfulSpatula Jan 12, 2019
b220cf7
Remaining decomposition test failures skipped
WrathfulSpatula Jan 12, 2019
48b3648
Merge branch 'develop' into qrack_simulator
WrathfulSpatula Jan 15, 2019
c4118c8
Merge pull request #4 from WrathfulSpatula/simulaqron_projectq_qrack_…
WrathfulSpatula Jan 15, 2019
7a51630
Pointing CI to repo directory
WrathfulSpatula Jan 15, 2019
a7edf25
CI and README for this fork
WrathfulSpatula Jan 15, 2019
a922542
Merge pull request #5 from WrathfulSpatula/personal_master_update
WrathfulSpatula Jan 15, 2019
551b38f
Fixing new README links
WrathfulSpatula Jan 15, 2019
1ee8edf
Fixing new links in README
WrathfulSpatula Jan 15, 2019
45d8608
Passing 0 and 1 control qubit uni. ctrl. tests
WrathfulSpatula Jan 20, 2019
5550a1a
Temporary branch for Travis
WrathfulSpatula Jan 20, 2019
e500658
Temporary folder for Travis
WrathfulSpatula Jan 20, 2019
759e90e
Uni. ctrl. base case should use mapped bit
WrathfulSpatula Jan 20, 2019
0c56459
Passing uni. ctrl. test, but controls seem to be sorted
WrathfulSpatula Jan 21, 2019
23e59c2
Merge pull request #6 from WrathfulSpatula/uniformly_controlled_gates
WrathfulSpatula Jan 21, 2019
2876e01
Fixing Travis after merge
WrathfulSpatula Jan 21, 2019
4b8fd1f
Still test default simulator when Qrack is included
WrathfulSpatula Jan 21, 2019
984fb5a
Use default simulator for time evolution tests
WrathfulSpatula Jan 21, 2019
7473a39
Use default simulator for QubitOperator tests
WrathfulSpatula Jan 21, 2019
3375439
Test decompositions with both C++ simulators (and remove Qrack repo b…
WrathfulSpatula Jan 21, 2019
137fc2d
Fixing decomps. pytest parameterization
WrathfulSpatula Jan 21, 2019
33a491e
Adding to coverage for uniformly controlled gates
WrathfulSpatula Jan 21, 2019
a698f7f
Builds with double and float Qrack (testing double in CI)
WrathfulSpatula Jan 23, 2019
840f9fb
Fixing mem leak and alloc safety
WrathfulSpatula Jan 23, 2019
3f44c35
See comment about Qrack mult. carry
WrathfulSpatula Jan 23, 2019
15f99d1
Adding direct state prep. support from Qrack simulator
WrathfulSpatula Jan 23, 2019
3953b1f
StatePreparation coverage
WrathfulSpatula Jan 23, 2019
e52b38d
StatePreparation coverage
WrathfulSpatula Jan 23, 2019
9bd1fde
Triggering coveralls
WrathfulSpatula Jan 23, 2019
56b24be
StatePrep. check for zero or empty container
WrathfulSpatula Jan 23, 2019
b8a46b4
StatePrep. coverage debugging
WrathfulSpatula Jan 23, 2019
4d8b5f8
Changing random engine in Qrack repo
WrathfulSpatula Jan 24, 2019
df69908
Pointing Travis to master branch of Qrack, after merge
WrathfulSpatula Jan 24, 2019
39ce7d1
Removing QFusion layer
WrathfulSpatula Jan 25, 2019
b705d4e
set_wavefunction does not need to reallocate
WrathfulSpatula Jan 25, 2019
6a35425
Reverting unnecessary changes in diff from debugging
WrathfulSpatula Jan 27, 2019
ba9fe9c
Reverting unnecessary changes in diff from debugging (#2)
WrathfulSpatula Jan 27, 2019
1a3a99d
1e-9 tolerance still needed for float accuracy in SimulaQron
WrathfulSpatula Jan 27, 2019
3d35ba0
Merge branch 'master' into qrack_simulator
WrathfulSpatula Jan 27, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
sudo: false
sudo: true
language: python
matrix:
include:
Expand Down Expand Up @@ -40,7 +40,9 @@ install:
- pip$PY install coveralls
- CC=g++-7 pip$PY install revkit
- if [ "${PYTHON:0:1}" = "3" ]; then pip$PY install dormouse; fi
- pip$PY install -e .
- cd ../.. && git clone https://github.com/vm6502q/qrack.git
- cd qrack && mkdir _build && cd _build && cmake .. && sudo make install && cd ../.. && sudo rm -r qrack && cd WrathfulSpatula/ProjectQ
- pip$PY install -e . --global-option="--with-qracksimulator"

# command to run tests
script: export OMP_NUM_THREADS=1 && pytest projectq --cov projectq
Expand Down
6 changes: 6 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@ This allows users to
- export quantum programs as circuits (using TikZ)
- get resource estimates

This Fork
---------
This fork maintains support for the `Qrack <https://github.com/vm6502q/qrack>`__ simulator framework as an optional back end. To use Qrack with ProjectQ, checkout the Qrack repo. Build and install Qrack. Then, build ProjectQ with the optional global flag "--with-qracksimulator" passed to setup.py.

This has been successfully tested in the context of a `SimulaQron <https://github.com/SoftwareQuTech/SimulaQron>`__-> ProjectQ -> Qrack stack with at least two physical nodes, with many logical nodes distributed between them. Qrack is the base quantum node simulator, ProjectQ is the compiler, and SimulaQron provides simulation or emulation of a quantum network. To reproduce this stack, as stated above, just install Qrack and use a copy of ProjectQ built and installed with the global flag "--with-qracksimulator", for SimulaQron.

Examples
--------

Expand Down
1 change: 1 addition & 0 deletions docs/projectq.backends.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ backends
projectq.backends.ClassicalSimulator
projectq.backends.ResourceCounter
projectq.backends.IBMBackend
projectq.backends.QrackSimulator


Module contents
Expand Down
11 changes: 9 additions & 2 deletions projectq/backends/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,20 @@
* a debugging tool to print all received commands (CommandPrinter)
* a circuit drawing engine (which can be used anywhere within the compilation
chain)
* a simulator with emulation capabilities
* internal and external simulators with emulation capabilities
* a resource counter (counts gates and keeps track of the maximal width of the
circuit)
* an interface to the IBM Quantum Experience chip (and simulator).
"""
from ._printer import CommandPrinter
from ._circuits import CircuitDrawer
from ._sim import Simulator, ClassicalSimulator
from ._sim import ClassicalSimulator
from ._resource import ResourceCounter
from ._ibm import IBMBackend

try:
# Try to import the Qrack Simulator, if it exists.
from ._qracksim import Simulator
except ImportError:
# If the Qrack Simulator isn't built, import the default ProjectQ simulator.
from ._sim import Simulator
15 changes: 15 additions & 0 deletions projectq/backends/_qracksim/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Copyright 2017 ProjectQ-Framework (www.projectq.ch)
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from ._simulator import Simulator
120 changes: 120 additions & 0 deletions projectq/backends/_qracksim/_cpp/intrin/alignedallocator.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
// Copyright (C) 2012 Andreas Hehn <hehn@phys.ethz.ch>.

// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#pragma once

#ifdef _WIN32
#include <malloc.h>
#else
#include <cstdlib>
#endif
#include <cstddef>
#include <memory>
#include <new>

#if __cplusplus < 201103L
#define noexcept
#endif


template <typename T, unsigned int Alignment>
class aligned_allocator
{
public:
typedef T* pointer;
typedef T const* const_pointer;
typedef T& reference;
typedef T const& const_reference;
typedef T value_type;
typedef std::size_t size_type;
typedef std::ptrdiff_t difference_type;

template <typename U>
struct rebind
{
typedef aligned_allocator<U, Alignment> other;
};

aligned_allocator() noexcept {}
aligned_allocator(aligned_allocator const&) noexcept {}
template <typename U>
aligned_allocator(aligned_allocator<U, Alignment> const&) noexcept
{
}

pointer allocate(size_type n)
{
pointer p;


#ifdef _WIN32
p = reinterpret_cast<pointer>(_aligned_malloc(n * sizeof(T), Alignment));
if (p == 0) throw std::bad_alloc();
#else
if (posix_memalign(reinterpret_cast<void**>(&p), Alignment, n * sizeof(T)))
throw std::bad_alloc();
#endif
return p;
}

void deallocate(pointer p, size_type) noexcept
{
#ifdef _WIN32
_aligned_free(p);
#else
std::free(p);
#endif
}

size_type max_size() const noexcept
{
std::allocator<T> a;
return a.max_size();
}

#if __cplusplus >= 201103L
template <typename C, class... Args>
void construct(C* c, Args&&... args)
{
new ((void*)c) C(std::forward<Args>(args)...);
}
#else
void construct(pointer p, const_reference t) { new ((void*)p) T(t); }
#endif

template <typename C>
void destroy(C* c)
{
c->~C();
}

bool operator==(aligned_allocator const&) const noexcept { return true; }
bool operator!=(aligned_allocator const&) const noexcept { return false; }
template <typename U, unsigned int UAlignment>
bool operator==(aligned_allocator<U, UAlignment> const&) const noexcept
{
return false;
}

template <typename U, unsigned int UAlignment>
bool operator!=(aligned_allocator<U, UAlignment> const&) const noexcept
{
return true;
}
};

#if __cplusplus < 201103L
#undef noexcept
#endif

Loading