Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
77 commits
Select commit Hold shift + click to select a range
9a61224
Re-squash of Qrack integration (#1)
WrathfulSpatula Jan 27, 2019
36ef86c
Upstream diff revert squash (#4)
WrathfulSpatula Jan 27, 2019
935d1d6
Updating Travis config for upstream compat.
WrathfulSpatula Jan 27, 2019
a0ff942
Triggering CI
WrathfulSpatula Jan 27, 2019
1c746a7
Uni. ctrl. debugging and coverage (#5)
WrathfulSpatula Jan 29, 2019
d1653ea
Updating CI for fork compatibility
WrathfulSpatula Jan 29, 2019
40e4c6c
Decompositions coverage
WrathfulSpatula Jan 29, 2019
1513fb5
ProjectQ v0.4.2
damiansteiger Jan 31, 2019
72de7e9
Merge branch 'develop' into upstream_qrack_integration
WrathfulSpatula Feb 5, 2019
1658e08
Triggering CI
WrathfulSpatula Feb 5, 2019
56c07b7
Relaxing state prep tolerance for SimulaQron
WrathfulSpatula Feb 6, 2019
a80bf31
Qrack installation notes in README
WrathfulSpatula Mar 2, 2019
1487423
Fixing Qrack links in README
WrathfulSpatula Mar 2, 2019
096666a
Clarification of typical use cases for Qrack
WrathfulSpatula Mar 2, 2019
9566f54
QubitOperator support (#6)
WrathfulSpatula Mar 2, 2019
a595cd0
Coverage
WrathfulSpatula Mar 2, 2019
1d7e14a
Implements time evolution (pending PR on Qrack repo) (#7)
WrathfulSpatula Mar 3, 2019
fdf95be
Coverage (redundant gate handler)
WrathfulSpatula Mar 3, 2019
70ca781
Adding support for precompiled Qrack OCL programs (#9)
WrathfulSpatula May 9, 2019
0642a12
Merge branch 'develop' into upstream_qrack_integration
WrathfulSpatula May 9, 2019
e15477c
Testing approx. compare for phase estimation
WrathfulSpatula May 10, 2019
66f4e6c
No need to copy most vectors, for Qrack method signatures (#10)
WrathfulSpatula May 11, 2019
9dcc0bc
Triggering CI
WrathfulSpatula May 11, 2019
ff0c76b
Fixing memory leak
WrathfulSpatula May 11, 2019
03e6858
Fixing OCL device selection
WrathfulSpatula May 25, 2019
ab1c3dc
Increasing tolerance on phase estimation test
WrathfulSpatula May 25, 2019
58a04d5
Compatibility with Qrack updates (#11)
WrathfulSpatula Jun 20, 2019
9d5747c
Triggering CI
WrathfulSpatula Jun 21, 2019
2b1691a
Upstream update (#13)
WrathfulSpatula Oct 5, 2019
1e8d676
Restoring unit test (after debugging Qrack)
WrathfulSpatula Oct 6, 2019
47061b8
Merge branch 'develop' into upstream_qrack_integration
WrathfulSpatula Nov 10, 2019
5782bff
Testing tolerance
WrathfulSpatula Nov 10, 2019
36d772f
Testing tolerance
WrathfulSpatula Nov 10, 2019
7adcce1
Disabling state prep test for 4 qubits
WrathfulSpatula Nov 10, 2019
f828363
Tolerance on uniformly controlled gates, and temporarily disabling Py…
WrathfulSpatula Nov 13, 2019
7a9f20d
Updating Travis
WrathfulSpatula Nov 13, 2019
51fd684
Init empty simulator list
WrathfulSpatula Nov 13, 2019
67c6403
QPE() tolerances
WrathfulSpatula Nov 13, 2019
1a9b7c6
Phase tolerance
WrathfulSpatula Nov 13, 2019
d637fc7
Test tolerance
WrathfulSpatula Dec 13, 2019
2559eb0
Merge branch 'upstream_qrack_integration' into qrack_unit_tests
WrathfulSpatula Dec 13, 2019
eaa2704
Uni. Ctrld. amplitude agnostic unit test
WrathfulSpatula Dec 14, 2019
faa2158
New normalization API
WrathfulSpatula Dec 31, 2019
e878bb7
Qrack API update: ApplySingleBit
WrathfulSpatula Jan 13, 2020
ea9ccd9
Merge branch 'develop' of https://github.com/ProjectQ-Framework/Proje…
WrathfulSpatula Jan 19, 2020
b270fbf
Accommodating new unit tests, with Qrack
WrathfulSpatula Jan 19, 2020
1ca0f0f
Merge branch 'upstream_qrack_integration' into qrack_unit_tests
WrathfulSpatula Jan 19, 2020
12e5ca9
Optional xFail on QPE tests, after long history of problems
WrathfulSpatula Jan 26, 2020
fce5921
Bumped version number to 0.5.0
Takishima Feb 19, 2020
6860e6d
Merge branch 'release/0.5.0'
Takishima Feb 19, 2020
1fe4f0b
Time evolution decomposition arbitrary phase factors
WrathfulSpatula Feb 20, 2020
87fe6fb
Revert last commit
WrathfulSpatula Feb 21, 2020
cec7452
Remove unneeded test
Takishima Feb 28, 2020
f7f57a1
Fix error in examples/ibm.py
Takishima Feb 28, 2020
f5d43e9
Add documentation for **kwargs for CircuitDrawerMatplotlib
Takishima Feb 20, 2020
32513f1
Update setup.py license header
Takishima Mar 19, 2020
f4a82f2
Merge pull request #359 from ProjectQ-Framework/release/0.5.0
Takishima Mar 23, 2020
f3b1e06
Merge from upstream (#15)
WrathfulSpatula Apr 19, 2020
3ad9456
Merge from upstream (#16)
WrathfulSpatula Apr 19, 2020
851ed3e
Merge from upstream (#17)
WrathfulSpatula Apr 19, 2020
5e4b0d5
Update .travis.yml
WrathfulSpatula Apr 19, 2020
3694416
Update .travis.yml
WrathfulSpatula Apr 19, 2020
081f144
Removing QFusion layer
WrathfulSpatula May 1, 2020
cfa2470
Merge branch 'qrack_unit_tests' of https://github.com/vm6502q/project…
WrathfulSpatula May 1, 2020
c602996
Removing QFusion
WrathfulSpatula May 1, 2020
3021ab1
Merge branch 'qrack_unit_tests' into upstream_qrack_integration
WrathfulSpatula May 1, 2020
dd8199f
Bumped version to v0.5.1
Takishima May 7, 2020
1920531
Merge branch 'master' into release/0.5.1
Takishima Jun 5, 2020
659304d
Merge pull request #369 from Takishima/release/0.5.1
Takishima Jun 5, 2020
9c79dc0
Updating Qrack API
WrathfulSpatula Jun 13, 2020
6dff373
Fix merge from upstream
WrathfulSpatula Aug 2, 2020
5911c2c
Merging from upstream
WrathfulSpatula Aug 2, 2020
88a8706
Remove penmp
WrathfulSpatula Aug 2, 2020
bd18e01
Fix merge conflict
WrathfulSpatula Aug 2, 2020
f45e985
Add QUnitMulti simulator option
WrathfulSpatula Aug 2, 2020
0711e11
Fixing syntax error
WrathfulSpatula Aug 2, 2020
1eac4b1
Update on the ibmq client (#379) (#19) (#20)
WrathfulSpatula Nov 17, 2020
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
4 changes: 3 additions & 1 deletion .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,6 +40,8 @@ install:
- pip$PY install coveralls
- CC=g++-7 pip$PY install revkit
- if [ "${PYTHON:0:1}" = "3" ]; then pip$PY install dormouse; fi
- 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 vm6502q/ProjectQ
- pip$PY install -e .

before_script:
Expand Down
9 changes: 9 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,15 @@ This allows users to
- export quantum programs as circuits (using TikZ)
- get resource estimates

Building with the Qrack Simulator
---------------------------------

The `Qrack <https://github.com/vm6502q/qrack>`__ simulator library provides optional GPU support for ProjectQ and may improve performance, portability, and/or memory efficiency. Depending partially on build options and hardware, Qrack generally trades off a small amount of floating point precision for speed, memory usage, and/or the ability to backport to 32-bit hardware and simpler instruction sets. To use it with ProjectQ, first install Qrack, according to the instructions in that project's README and `documentation <https://qrack.readthedocs.io/en/latest/start.html>`_. When you have built Qrack with the desired settings, "make install" in the build directory.

With Qrack installed, you can use it as the default ProjectQ simulator by simply building and installing ProjectQ with the `--with-qracksimulator` global option. This exchanges the Qrack simulator for the default ProjectQ C++ simulator, throughout. Any application which would rely on the default C++ simulator should then automatically use the Qrack simulator instead.

Note that Qrack does not support any nonunitary operations available in the default C++ simulator. To keep integer math unitary, the integer multiplication operation uses the more significant half of the multiplication operation register as a "carry" sub-register, which is measured and then zeroed at the beginning of a multiplication operation.

Examples
--------

Expand Down
2 changes: 1 addition & 1 deletion projectq/_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@
# limitations under the License.

"""Define version number here and read it from setup.py automatically"""
__version__ = "0.5.0"
__version__ = "0.5.1"
9 changes: 8 additions & 1 deletion projectq/backends/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
* 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).
Expand All @@ -32,3 +32,10 @@
from ._resource import ResourceCounter
from ._ibm import IBMBackend
from ._aqt import AQTBackend

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
37 changes: 14 additions & 23 deletions projectq/backends/_ibm/_ibm_http_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ def _authenticate(self, token=None):
def _run(self, info, device):
"""
Run the quantum code to the IBMQ machine.
Update since March2020: only protocol available is what they call
Update since September 2020: only protocol available is what they call
'object storage' where a job request via the POST method gets in
return a url link to which send the json data. A final http validates
the data communication.
Expand Down Expand Up @@ -162,19 +162,10 @@ def _run(self, info, device):
**json_step1)
request.raise_for_status()
r_json = request.json()
download_endpoint_url = r_json['objectStorageInfo'][
'downloadQObjectUrlEndpoint']
upload_endpoint_url = r_json['objectStorageInfo'][
'uploadQobjectUrlEndpoint']
upload_url = r_json['objectStorageInfo']['uploadUrl']
execution_id = r_json['id']

# STEP2: WE USE THE ENDPOINT TO GET THE UPLOT LINK
json_step2 = {'allow_redirects': True, 'timeout': (5.0, None)}
request = super(IBMQ, self).get(upload_endpoint_url, **json_step2)
request.raise_for_status()
r_json = request.json()

# STEP3: WE USE THE ENDPOINT TO GET THE UPLOT LINK
# STEP2: WE UPLOAD THE CIRCUIT DATA
n_classical_reg = info['nq']
# hack: easier to restrict labels to measured qubits
n_qubits = n_classical_reg # self.backends[device]['nq']
Expand All @@ -194,7 +185,7 @@ def _run(self, info, device):
data += ('"parameter_binds": [], "memory_slots": '
+ str(n_classical_reg))
data += (', "n_qubits": ' + str(n_qubits)
+ '}, "schema_version": "1.1.0", ')
+ '}, "schema_version": "1.2.0", ')
data += '"type": "QASM", "experiments": [{"config": '
data += '{"n_qubits": ' + str(n_qubits) + ', '
data += '"memory_slots": ' + str(n_classical_reg) + '}, '
Expand All @@ -205,31 +196,31 @@ def _run(self, info, device):
data += '"clbit_labels": ' + str(c_label).replace('\'', '\"') + ', '
data += '"memory_slots": ' + str(n_classical_reg) + ', '
data += '"creg_sizes": [["c", ' + str(n_classical_reg) + ']], '
data += ('"name": "circuit0"}, "instructions": ' + instruction_str
data += ('"name": "circuit0", "global_phase": 0}, "instructions": ' + instruction_str
+ '}]}')

json_step3 = {
json_step2 = {
'data': data,
'params': {
'access_token': None
},
'timeout': (5.0, None)
}
request = super(IBMQ, self).put(r_json['url'], **json_step3)
request = super(IBMQ, self).put(upload_url, **json_step2)
request.raise_for_status()

# STEP4: CONFIRM UPLOAD
json_step4 = {
# STEP3: CONFIRM UPLOAD
json_step3 = {
'data': None,
'json': None,
'timeout': (self.timeout, None)
}
upload_data_url = upload_endpoint_url.replace('jobUploadUrl',
'jobDataUploaded')
request = super(IBMQ, self).post(upload_data_url, **json_step4)

upload_data_url = urljoin(_API_URL,
'Network/ibm-q/Groups/open/Projects/main/Jobs/'+str(execution_id)
+'/jobDataUploaded')
request = super(IBMQ, self).post(upload_data_url, **json_step3)
request.raise_for_status()
r_json = request.json()
execution_id = upload_endpoint_url.split('/')[-2]

return execution_id

Expand Down
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