Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for float and double precision data #113

Merged
merged 55 commits into from
Jul 28, 2021
Merged
Show file tree
Hide file tree
Changes from 39 commits
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
175e9b2
Initial reformat and templated of gate tests
mlxd Jul 14, 2021
ae8d7c3
Redefine gate mappings with templates
mlxd Jul 16, 2021
b7d5106
Record given state
mlxd Jul 16, 2021
85fe333
Move all gate classes to become StateVector methods
mlxd Jul 16, 2021
dc70228
Fix compile errors for SV
mlxd Jul 19, 2021
6a4fa76
Refactor gates implementation
mlxd Jul 19, 2021
6d85893
Enable vector param methods
mlxd Jul 19, 2021
dad9c8a
Enable label to gatename map
mlxd Jul 19, 2021
0d6af2f
Support dispatch directly from StateVector class
mlxd Jul 20, 2021
e157b99
Add apply methods to SV class
mlxd Jul 20, 2021
3286f40
Add log2 utility function
mlxd Jul 20, 2021
fe7bf57
Remove old file arch
mlxd Jul 20, 2021
2c0e318
Ensure bindings build support for float and double sizes complex data
mlxd Jul 20, 2021
cdd7814
Remove outdated tests for deleted modules
mlxd Jul 20, 2021
5da9487
Remove old definition headers
mlxd Jul 20, 2021
2ad4801
Tidy dispatch map
mlxd Jul 20, 2021
88a5341
Replace header with correct type
mlxd Jul 20, 2021
f3e4c49
Ensure cpp17 is now used
mlxd Jul 20, 2021
8c03920
Remove unneeded files in compilation
mlxd Jul 20, 2021
6318cc5
Ensure apply args are given in correct order
mlxd Jul 20, 2021
cc06018
Allow make test to be run from working dir without cleaning
mlxd Jul 20, 2021
b608595
Fix cpp formatting
mlxd Jul 20, 2021
6652244
Merge branch 'master' into 7067-templated-float
mlxd Jul 20, 2021
09b786b
Remove old code and fix codefactor complaints
mlxd Jul 20, 2021
810c52f
Add cast to enable wheel build on MacOS
mlxd Jul 20, 2021
a90d9a9
Enable MSVC intrinsics if using Windows
mlxd Jul 20, 2021
a7c80ea
Ensure C++17 as a requirement
mlxd Jul 20, 2021
f627831
Fix compile-time ifdef
mlxd Jul 20, 2021
f90f915
Replace intrinsic with BSR
mlxd Jul 20, 2021
9a5c566
Avoid intrinsics for portability
mlxd Jul 20, 2021
23128d9
Rename log2 function
mlxd Jul 20, 2021
43a5d05
Add support for 64bit and 128 complex numbers from C++ backend
mlxd Jul 21, 2021
4b83854
Update bindings to allow class instantiation and method use
mlxd Jul 21, 2021
2710e4e
Enable support for different precision parameters passed to backend
mlxd Jul 21, 2021
7e31fbb
Fix log2 change
mlxd Jul 21, 2021
05ff35d
Fix binding names
mlxd Jul 21, 2021
b4c1a3f
Remove io from statevector
mlxd Jul 21, 2021
db9d1ed
Refix the log2 -- replace with instrinsics later
mlxd Jul 21, 2021
15fba88
Update format and remove ununsed warnings
mlxd Jul 21, 2021
e8e736d
Merge branch 'master' into 7067-templated-float
mlxd Jul 26, 2021
f91f763
Refactor the testing infrastructure for templated StateVector impleme…
mlxd Jul 26, 2021
1919128
Remove whitespace for CF complaints
mlxd Jul 26, 2021
811953b
Apply static analyser fixes
mlxd Jul 26, 2021
3d886c0
Add imaginary utils
mlxd Jul 26, 2021
8e17ea4
Refactor gate implementation and utility definitions
mlxd Jul 26, 2021
b6c309f
Fix RY gate defn
mlxd Jul 27, 2021
75de30c
Add compile-time complex multiplication functions
mlxd Jul 27, 2021
9ef3f2e
Use gate definition functions in tests and add constexpr where applic…
mlxd Jul 27, 2021
1338696
Remove outdated test utilities and tests
mlxd Jul 27, 2021
27faeb3
Update changelog
mlxd Jul 27, 2021
e1b8cee
Merge branch 'master' into 7067-templated-float
mlxd Jul 28, 2021
d28f5e5
Port ControlledPhaseShift to new simulator structure
mlxd Jul 28, 2021
11d62af
Add ControlledPhaseShift method to bindings
mlxd Jul 28, 2021
dd4ea59
Ensure tests are run using cmake
mlxd Jul 28, 2021
85aad92
Rename label CPhaseShift to ControlledPhasedShift
mlxd Jul 28, 2021
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
9 changes: 3 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,9 @@ set_pennylane_lightning_version("${CMAKE_SOURCE_DIR}/pennylane_lightning/_versio
message(STATUS "pennylane_lightning version ${VERSION_STRING}")
set(PROJECT_VERSION ${VERSION_STRING})

set(CMAKE_CXX_STANDARD 11) # At least C++11 is required
set(CMAKE_CXX_STANDARD 17) # At least C++17 is required
trbromley marked this conversation as resolved.
Show resolved Hide resolved
find_package(OpenMP REQUIRED) # find OpenMP
mlxd marked this conversation as resolved.
Show resolved Hide resolved


if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release)
endif()
Expand Down Expand Up @@ -58,10 +57,8 @@ if ("$ENV{USE_OPENBLAS}" OR "${USE_OPENBLAS}")
target_compile_options(external_dependency INTERFACE "-DOPENBLAS=1")
endif()

pybind11_add_module(lightning_qubit_ops "pennylane_lightning/src/Apply.cpp"
"pennylane_lightning/src/Bindings.cpp"
"pennylane_lightning/src/Gates.cpp"
"pennylane_lightning/src/StateVector.cpp")
pybind11_add_module(lightning_qubit_ops "pennylane_lightning/src/StateVector.cpp"
"pennylane_lightning/src/Bindings.cpp")
target_link_libraries(lightning_qubit_ops PRIVATE external_dependency)
set_target_properties(lightning_qubit_ops PROPERTIES CXX_VISIBILITY_PRESET hidden)

Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ clean-docs:
make -C doc clean

test:
$(PYTHON) $(TESTRUNNER)
$(PYTHON) -I $(TESTRUNNER)

coverage:
@echo "Generating coverage report..."
Expand Down
1 change: 0 additions & 1 deletion bin/format
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ IGNORE_PATTERN = "external"

BASE_CMD = ("clang-format", f"-style={json.dumps(CLANG_FMT_STYLE_CFG)}")


def check_bin():
try:
subprocess.run(
Expand Down
16 changes: 11 additions & 5 deletions pennylane_lightning/lightning_qubit.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
interfaces with C++ for fast linear algebra calculations.
"""
from pennylane.devices import DefaultQubit
from .lightning_qubit_ops import apply
import numpy as np
from pennylane import QubitStateVector, BasisState, DeviceError, QubitUnitary
from .lightning_qubit_ops import apply, StateVectorC64, StateVectorC128
mlxd marked this conversation as resolved.
Show resolved Hide resolved

from ._version import __version__

Expand Down Expand Up @@ -94,10 +94,14 @@ def apply(self, operations, rotations=None, **kwargs):
# State preparation is currently done in Python
if operations: # make sure operations[0] exists
if isinstance(operations[0], QubitStateVector):
self._apply_state_vector(operations[0].parameters[0].copy(), operations[0].wires)
self._apply_state_vector(
operations[0].parameters[0].copy(), operations[0].wires
)
del operations[0]
elif isinstance(operations[0], BasisState):
self._apply_basis_state(operations[0].parameters[0], operations[0].wires)
self._apply_basis_state(
operations[0].parameters[0], operations[0].wires
)
del operations[0]

for operation in operations:
Expand All @@ -116,7 +120,9 @@ def apply(self, operations, rotations=None, **kwargs):
if any(isinstance(r, QubitUnitary) for r in rotations):
super().apply(operations=[], rotations=rotations)
else:
self._state = self.apply_lightning(np.copy(self._pre_rotated_state), rotations)
self._state = self.apply_lightning(
np.copy(self._pre_rotated_state), rotations
)
else:
self._state = self._pre_rotated_state

Expand All @@ -136,7 +142,7 @@ def apply_lightning(self, state, operations):
op_inverse = [o.inverse for o in operations]

state_vector = np.ravel(state)
apply(state_vector, op_names, op_wires, op_param, op_inverse, self.num_wires)
apply(state_vector, op_names, op_wires, op_inverse, op_param)
trbromley marked this conversation as resolved.
Show resolved Hide resolved
return np.reshape(state_vector, state.shape)

@staticmethod
Expand Down
113 changes: 0 additions & 113 deletions pennylane_lightning/src/Apply.cpp

This file was deleted.

114 changes: 0 additions & 114 deletions pennylane_lightning/src/Apply.hpp

This file was deleted.

Loading